documentation.d.ts 3.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477
  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 ignore 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. * @param order is a reserved parameter and is ignore for now
  3859. * @returns the current unchanged quaternion
  3860. */
  3861. toEulerAnglesToRef(result: Vector3): Quaternion;
  3862. /**
  3863. * Updates the given rotation matrix with the current quaternion values
  3864. * @param result defines the target matrix
  3865. * @returns the current unchanged quaternion
  3866. */
  3867. toRotationMatrix(result: Matrix): Quaternion;
  3868. /**
  3869. * Updates the current quaternion from the given rotation matrix values
  3870. * @param matrix defines the source matrix
  3871. * @returns the current updated quaternion
  3872. */
  3873. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3874. /**
  3875. * Creates a new quaternion from a rotation matrix
  3876. * @param matrix defines the source matrix
  3877. * @returns a new quaternion created from the given rotation matrix values
  3878. */
  3879. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3880. /**
  3881. * Updates the given quaternion with the given rotation matrix values
  3882. * @param matrix defines the source matrix
  3883. * @param result defines the target quaternion
  3884. */
  3885. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3886. /**
  3887. * Returns the dot product (float) between the quaternions "left" and "right"
  3888. * @param left defines the left operand
  3889. * @param right defines the right operand
  3890. * @returns the dot product
  3891. */
  3892. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3893. /**
  3894. * Checks if the two quaternions are close to each other
  3895. * @param quat0 defines the first quaternion to check
  3896. * @param quat1 defines the second quaternion to check
  3897. * @returns true if the two quaternions are close to each other
  3898. */
  3899. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3900. /**
  3901. * Creates an empty quaternion
  3902. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3903. */
  3904. static Zero(): Quaternion;
  3905. /**
  3906. * Inverse a given quaternion
  3907. * @param q defines the source quaternion
  3908. * @returns a new quaternion as the inverted current quaternion
  3909. */
  3910. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3911. /**
  3912. * Inverse a given quaternion
  3913. * @param q defines the source quaternion
  3914. * @param result the quaternion the result will be stored in
  3915. * @returns the result quaternion
  3916. */
  3917. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3918. /**
  3919. * Creates an identity quaternion
  3920. * @returns the identity quaternion
  3921. */
  3922. static Identity(): Quaternion;
  3923. /**
  3924. * Gets a boolean indicating if the given quaternion is identity
  3925. * @param quaternion defines the quaternion to check
  3926. * @returns true if the quaternion is identity
  3927. */
  3928. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3929. /**
  3930. * Creates a quaternion from a rotation around an axis
  3931. * @param axis defines the axis to use
  3932. * @param angle defines the angle to use
  3933. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3934. */
  3935. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3936. /**
  3937. * Creates a rotation around an axis and stores it into the given quaternion
  3938. * @param axis defines the axis to use
  3939. * @param angle defines the angle to use
  3940. * @param result defines the target quaternion
  3941. * @returns the target quaternion
  3942. */
  3943. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3944. /**
  3945. * Creates a new quaternion from data stored into an array
  3946. * @param array defines the data source
  3947. * @param offset defines the offset in the source array where the data starts
  3948. * @returns a new quaternion
  3949. */
  3950. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3951. /**
  3952. * Updates the given quaternion "result" from the starting index of the given array.
  3953. * @param array the array to pull values from
  3954. * @param offset the offset into the array to start at
  3955. * @param result the quaternion to store the result in
  3956. */
  3957. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3958. /**
  3959. * Create a quaternion from Euler rotation angles
  3960. * @param x Pitch
  3961. * @param y Yaw
  3962. * @param z Roll
  3963. * @returns the new Quaternion
  3964. */
  3965. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3966. /**
  3967. * Updates a quaternion from Euler rotation angles
  3968. * @param x Pitch
  3969. * @param y Yaw
  3970. * @param z Roll
  3971. * @param result the quaternion to store the result
  3972. * @returns the updated quaternion
  3973. */
  3974. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3975. /**
  3976. * Create a quaternion from Euler rotation vector
  3977. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3978. * @returns the new Quaternion
  3979. */
  3980. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3981. /**
  3982. * Updates a quaternion from Euler rotation vector
  3983. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3984. * @param result the quaternion to store the result
  3985. * @returns the updated quaternion
  3986. */
  3987. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3988. /**
  3989. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3990. * @param yaw defines the rotation around Y axis
  3991. * @param pitch defines the rotation around X axis
  3992. * @param roll defines the rotation around Z axis
  3993. * @returns the new quaternion
  3994. */
  3995. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3996. /**
  3997. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3998. * @param yaw defines the rotation around Y axis
  3999. * @param pitch defines the rotation around X axis
  4000. * @param roll defines the rotation around Z axis
  4001. * @param result defines the target quaternion
  4002. */
  4003. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4004. /**
  4005. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4006. * @param alpha defines the rotation around first axis
  4007. * @param beta defines the rotation around second axis
  4008. * @param gamma defines the rotation around third axis
  4009. * @returns the new quaternion
  4010. */
  4011. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4012. /**
  4013. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4014. * @param alpha defines the rotation around first axis
  4015. * @param beta defines the rotation around second axis
  4016. * @param gamma defines the rotation around third axis
  4017. * @param result defines the target quaternion
  4018. */
  4019. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4020. /**
  4021. * 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)
  4022. * @param axis1 defines the first axis
  4023. * @param axis2 defines the second axis
  4024. * @param axis3 defines the third axis
  4025. * @returns the new quaternion
  4026. */
  4027. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4028. /**
  4029. * 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
  4030. * @param axis1 defines the first axis
  4031. * @param axis2 defines the second axis
  4032. * @param axis3 defines the third axis
  4033. * @param ref defines the target quaternion
  4034. */
  4035. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4036. /**
  4037. * Interpolates between two quaternions
  4038. * @param left defines first quaternion
  4039. * @param right defines second quaternion
  4040. * @param amount defines the gradient to use
  4041. * @returns the new interpolated quaternion
  4042. */
  4043. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4044. /**
  4045. * Interpolates between two quaternions and stores it into a target quaternion
  4046. * @param left defines first quaternion
  4047. * @param right defines second quaternion
  4048. * @param amount defines the gradient to use
  4049. * @param result defines the target quaternion
  4050. */
  4051. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4052. /**
  4053. * Interpolate between two quaternions using Hermite interpolation
  4054. * @param value1 defines first quaternion
  4055. * @param tangent1 defines the incoming tangent
  4056. * @param value2 defines second quaternion
  4057. * @param tangent2 defines the outgoing tangent
  4058. * @param amount defines the target quaternion
  4059. * @returns the new interpolated quaternion
  4060. */
  4061. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4062. }
  4063. /**
  4064. * Class used to store matrix data (4x4)
  4065. */
  4066. export class Matrix {
  4067. /**
  4068. * Gets the precision of matrix computations
  4069. */
  4070. static get Use64Bits(): boolean;
  4071. private static _updateFlagSeed;
  4072. private static _identityReadOnly;
  4073. private _isIdentity;
  4074. private _isIdentityDirty;
  4075. private _isIdentity3x2;
  4076. private _isIdentity3x2Dirty;
  4077. /**
  4078. * Gets the update flag of the matrix which is an unique number for the matrix.
  4079. * It will be incremented every time the matrix data change.
  4080. * You can use it to speed the comparison between two versions of the same matrix.
  4081. */
  4082. updateFlag: number;
  4083. private readonly _m;
  4084. /**
  4085. * Gets the internal data of the matrix
  4086. */
  4087. get m(): DeepImmutable<Float32Array | Array<number>>;
  4088. /** @hidden */
  4089. _markAsUpdated(): void;
  4090. /** @hidden */
  4091. private _updateIdentityStatus;
  4092. /**
  4093. * Creates an empty matrix (filled with zeros)
  4094. */
  4095. constructor();
  4096. /**
  4097. * Check if the current matrix is identity
  4098. * @returns true is the matrix is the identity matrix
  4099. */
  4100. isIdentity(): boolean;
  4101. /**
  4102. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4103. * @returns true is the matrix is the identity matrix
  4104. */
  4105. isIdentityAs3x2(): boolean;
  4106. /**
  4107. * Gets the determinant of the matrix
  4108. * @returns the matrix determinant
  4109. */
  4110. determinant(): number;
  4111. /**
  4112. * Returns the matrix as a Float32Array or Array<number>
  4113. * @returns the matrix underlying array
  4114. */
  4115. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4116. /**
  4117. * Returns the matrix as a Float32Array or Array<number>
  4118. * @returns the matrix underlying array.
  4119. */
  4120. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4121. /**
  4122. * Inverts the current matrix in place
  4123. * @returns the current inverted matrix
  4124. */
  4125. invert(): Matrix;
  4126. /**
  4127. * Sets all the matrix elements to zero
  4128. * @returns the current matrix
  4129. */
  4130. reset(): Matrix;
  4131. /**
  4132. * Adds the current matrix with a second one
  4133. * @param other defines the matrix to add
  4134. * @returns a new matrix as the addition of the current matrix and the given one
  4135. */
  4136. add(other: DeepImmutable<Matrix>): Matrix;
  4137. /**
  4138. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4139. * @param other defines the matrix to add
  4140. * @param result defines the target matrix
  4141. * @returns the current matrix
  4142. */
  4143. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4144. /**
  4145. * Adds in place the given matrix to the current matrix
  4146. * @param other defines the second operand
  4147. * @returns the current updated matrix
  4148. */
  4149. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4150. /**
  4151. * Sets the given matrix to the current inverted Matrix
  4152. * @param other defines the target matrix
  4153. * @returns the unmodified current matrix
  4154. */
  4155. invertToRef(other: Matrix): Matrix;
  4156. /**
  4157. * add a value at the specified position in the current Matrix
  4158. * @param index the index of the value within the matrix. between 0 and 15.
  4159. * @param value the value to be added
  4160. * @returns the current updated matrix
  4161. */
  4162. addAtIndex(index: number, value: number): Matrix;
  4163. /**
  4164. * mutiply the specified position in the current Matrix by a value
  4165. * @param index the index of the value within the matrix. between 0 and 15.
  4166. * @param value the value to be added
  4167. * @returns the current updated matrix
  4168. */
  4169. multiplyAtIndex(index: number, value: number): Matrix;
  4170. /**
  4171. * Inserts the translation vector (using 3 floats) in the current matrix
  4172. * @param x defines the 1st component of the translation
  4173. * @param y defines the 2nd component of the translation
  4174. * @param z defines the 3rd component of the translation
  4175. * @returns the current updated matrix
  4176. */
  4177. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4178. /**
  4179. * Adds the translation vector (using 3 floats) in the current matrix
  4180. * @param x defines the 1st component of the translation
  4181. * @param y defines the 2nd component of the translation
  4182. * @param z defines the 3rd component of the translation
  4183. * @returns the current updated matrix
  4184. */
  4185. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4186. /**
  4187. * Inserts the translation vector in the current matrix
  4188. * @param vector3 defines the translation to insert
  4189. * @returns the current updated matrix
  4190. */
  4191. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4192. /**
  4193. * Gets the translation value of the current matrix
  4194. * @returns a new Vector3 as the extracted translation from the matrix
  4195. */
  4196. getTranslation(): Vector3;
  4197. /**
  4198. * Fill a Vector3 with the extracted translation from the matrix
  4199. * @param result defines the Vector3 where to store the translation
  4200. * @returns the current matrix
  4201. */
  4202. getTranslationToRef(result: Vector3): Matrix;
  4203. /**
  4204. * Remove rotation and scaling part from the matrix
  4205. * @returns the updated matrix
  4206. */
  4207. removeRotationAndScaling(): Matrix;
  4208. /**
  4209. * Multiply two matrices
  4210. * @param other defines the second operand
  4211. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4212. */
  4213. multiply(other: DeepImmutable<Matrix>): Matrix;
  4214. /**
  4215. * Copy the current matrix from the given one
  4216. * @param other defines the source matrix
  4217. * @returns the current updated matrix
  4218. */
  4219. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4220. /**
  4221. * Populates the given array from the starting index with the current matrix values
  4222. * @param array defines the target array
  4223. * @param offset defines the offset in the target array where to start storing values
  4224. * @returns the current matrix
  4225. */
  4226. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4227. /**
  4228. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4229. * @param other defines the second operand
  4230. * @param result defines the matrix where to store the multiplication
  4231. * @returns the current matrix
  4232. */
  4233. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4234. /**
  4235. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4236. * @param other defines the second operand
  4237. * @param result defines the array where to store the multiplication
  4238. * @param offset defines the offset in the target array where to start storing values
  4239. * @returns the current matrix
  4240. */
  4241. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4242. /**
  4243. * Check equality between this matrix and a second one
  4244. * @param value defines the second matrix to compare
  4245. * @returns true is the current matrix and the given one values are strictly equal
  4246. */
  4247. equals(value: DeepImmutable<Matrix>): boolean;
  4248. /**
  4249. * Clone the current matrix
  4250. * @returns a new matrix from the current matrix
  4251. */
  4252. clone(): Matrix;
  4253. /**
  4254. * Returns the name of the current matrix class
  4255. * @returns the string "Matrix"
  4256. */
  4257. getClassName(): string;
  4258. /**
  4259. * Gets the hash code of the current matrix
  4260. * @returns the hash code
  4261. */
  4262. getHashCode(): number;
  4263. /**
  4264. * Decomposes the current Matrix into a translation, rotation and scaling components
  4265. * @param scale defines the scale vector3 given as a reference to update
  4266. * @param rotation defines the rotation quaternion given as a reference to update
  4267. * @param translation defines the translation vector3 given as a reference to update
  4268. * @returns true if operation was successful
  4269. */
  4270. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4271. /**
  4272. * Gets specific row of the matrix
  4273. * @param index defines the number of the row to get
  4274. * @returns the index-th row of the current matrix as a new Vector4
  4275. */
  4276. getRow(index: number): Nullable<Vector4>;
  4277. /**
  4278. * Sets the index-th row of the current matrix to the vector4 values
  4279. * @param index defines the number of the row to set
  4280. * @param row defines the target vector4
  4281. * @returns the updated current matrix
  4282. */
  4283. setRow(index: number, row: Vector4): Matrix;
  4284. /**
  4285. * Compute the transpose of the matrix
  4286. * @returns the new transposed matrix
  4287. */
  4288. transpose(): Matrix;
  4289. /**
  4290. * Compute the transpose of the matrix and store it in a given matrix
  4291. * @param result defines the target matrix
  4292. * @returns the current matrix
  4293. */
  4294. transposeToRef(result: Matrix): Matrix;
  4295. /**
  4296. * Sets the index-th row of the current matrix with the given 4 x float values
  4297. * @param index defines the row index
  4298. * @param x defines the x component to set
  4299. * @param y defines the y component to set
  4300. * @param z defines the z component to set
  4301. * @param w defines the w component to set
  4302. * @returns the updated current matrix
  4303. */
  4304. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4305. /**
  4306. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4307. * @param scale defines the scale factor
  4308. * @returns a new matrix
  4309. */
  4310. scale(scale: number): Matrix;
  4311. /**
  4312. * Scale the current matrix values by a factor to a given result matrix
  4313. * @param scale defines the scale factor
  4314. * @param result defines the matrix to store the result
  4315. * @returns the current matrix
  4316. */
  4317. scaleToRef(scale: number, result: Matrix): Matrix;
  4318. /**
  4319. * Scale the current matrix values by a factor and add the result to a given matrix
  4320. * @param scale defines the scale factor
  4321. * @param result defines the Matrix to store the result
  4322. * @returns the current matrix
  4323. */
  4324. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4325. /**
  4326. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4327. * @param ref matrix to store the result
  4328. */
  4329. toNormalMatrix(ref: Matrix): void;
  4330. /**
  4331. * Gets only rotation part of the current matrix
  4332. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4333. */
  4334. getRotationMatrix(): Matrix;
  4335. /**
  4336. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4337. * @param result defines the target matrix to store data to
  4338. * @returns the current matrix
  4339. */
  4340. getRotationMatrixToRef(result: Matrix): Matrix;
  4341. /**
  4342. * Toggles model matrix from being right handed to left handed in place and vice versa
  4343. */
  4344. toggleModelMatrixHandInPlace(): void;
  4345. /**
  4346. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4347. */
  4348. toggleProjectionMatrixHandInPlace(): void;
  4349. /**
  4350. * Creates a matrix from an array
  4351. * @param array defines the source array
  4352. * @param offset defines an offset in the source array
  4353. * @returns a new Matrix set from the starting index of the given array
  4354. */
  4355. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4356. /**
  4357. * Copy the content of an array into a given matrix
  4358. * @param array defines the source array
  4359. * @param offset defines an offset in the source array
  4360. * @param result defines the target matrix
  4361. */
  4362. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4363. /**
  4364. * Stores an array into a matrix after having multiplied each component by a given factor
  4365. * @param array defines the source array
  4366. * @param offset defines the offset in the source array
  4367. * @param scale defines the scaling factor
  4368. * @param result defines the target matrix
  4369. */
  4370. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4371. /**
  4372. * Gets an identity matrix that must not be updated
  4373. */
  4374. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4375. /**
  4376. * Stores a list of values (16) inside a given matrix
  4377. * @param initialM11 defines 1st value of 1st row
  4378. * @param initialM12 defines 2nd value of 1st row
  4379. * @param initialM13 defines 3rd value of 1st row
  4380. * @param initialM14 defines 4th value of 1st row
  4381. * @param initialM21 defines 1st value of 2nd row
  4382. * @param initialM22 defines 2nd value of 2nd row
  4383. * @param initialM23 defines 3rd value of 2nd row
  4384. * @param initialM24 defines 4th value of 2nd row
  4385. * @param initialM31 defines 1st value of 3rd row
  4386. * @param initialM32 defines 2nd value of 3rd row
  4387. * @param initialM33 defines 3rd value of 3rd row
  4388. * @param initialM34 defines 4th value of 3rd row
  4389. * @param initialM41 defines 1st value of 4th row
  4390. * @param initialM42 defines 2nd value of 4th row
  4391. * @param initialM43 defines 3rd value of 4th row
  4392. * @param initialM44 defines 4th value of 4th row
  4393. * @param result defines the target matrix
  4394. */
  4395. 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;
  4396. /**
  4397. * Creates new matrix from a list of values (16)
  4398. * @param initialM11 defines 1st value of 1st row
  4399. * @param initialM12 defines 2nd value of 1st row
  4400. * @param initialM13 defines 3rd value of 1st row
  4401. * @param initialM14 defines 4th value of 1st row
  4402. * @param initialM21 defines 1st value of 2nd row
  4403. * @param initialM22 defines 2nd value of 2nd row
  4404. * @param initialM23 defines 3rd value of 2nd row
  4405. * @param initialM24 defines 4th value of 2nd row
  4406. * @param initialM31 defines 1st value of 3rd row
  4407. * @param initialM32 defines 2nd value of 3rd row
  4408. * @param initialM33 defines 3rd value of 3rd row
  4409. * @param initialM34 defines 4th value of 3rd row
  4410. * @param initialM41 defines 1st value of 4th row
  4411. * @param initialM42 defines 2nd value of 4th row
  4412. * @param initialM43 defines 3rd value of 4th row
  4413. * @param initialM44 defines 4th value of 4th row
  4414. * @returns the new matrix
  4415. */
  4416. 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;
  4417. /**
  4418. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4419. * @param scale defines the scale vector3
  4420. * @param rotation defines the rotation quaternion
  4421. * @param translation defines the translation vector3
  4422. * @returns a new matrix
  4423. */
  4424. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4425. /**
  4426. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4427. * @param scale defines the scale vector3
  4428. * @param rotation defines the rotation quaternion
  4429. * @param translation defines the translation vector3
  4430. * @param result defines the target matrix
  4431. */
  4432. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4433. /**
  4434. * Creates a new identity matrix
  4435. * @returns a new identity matrix
  4436. */
  4437. static Identity(): Matrix;
  4438. /**
  4439. * Creates a new identity matrix and stores the result in a given matrix
  4440. * @param result defines the target matrix
  4441. */
  4442. static IdentityToRef(result: Matrix): void;
  4443. /**
  4444. * Creates a new zero matrix
  4445. * @returns a new zero matrix
  4446. */
  4447. static Zero(): Matrix;
  4448. /**
  4449. * Creates a new rotation matrix for "angle" radians around the X axis
  4450. * @param angle defines the angle (in radians) to use
  4451. * @return the new matrix
  4452. */
  4453. static RotationX(angle: number): Matrix;
  4454. /**
  4455. * Creates a new matrix as the invert of a given matrix
  4456. * @param source defines the source matrix
  4457. * @returns the new matrix
  4458. */
  4459. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4460. /**
  4461. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4462. * @param angle defines the angle (in radians) to use
  4463. * @param result defines the target matrix
  4464. */
  4465. static RotationXToRef(angle: number, result: Matrix): void;
  4466. /**
  4467. * Creates a new rotation matrix for "angle" radians around the Y axis
  4468. * @param angle defines the angle (in radians) to use
  4469. * @return the new matrix
  4470. */
  4471. static RotationY(angle: number): Matrix;
  4472. /**
  4473. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4474. * @param angle defines the angle (in radians) to use
  4475. * @param result defines the target matrix
  4476. */
  4477. static RotationYToRef(angle: number, result: Matrix): void;
  4478. /**
  4479. * Creates a new rotation matrix for "angle" radians around the Z axis
  4480. * @param angle defines the angle (in radians) to use
  4481. * @return the new matrix
  4482. */
  4483. static RotationZ(angle: number): Matrix;
  4484. /**
  4485. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4486. * @param angle defines the angle (in radians) to use
  4487. * @param result defines the target matrix
  4488. */
  4489. static RotationZToRef(angle: number, result: Matrix): void;
  4490. /**
  4491. * Creates a new rotation matrix for "angle" radians around the given axis
  4492. * @param axis defines the axis to use
  4493. * @param angle defines the angle (in radians) to use
  4494. * @return the new matrix
  4495. */
  4496. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4497. /**
  4498. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4499. * @param axis defines the axis to use
  4500. * @param angle defines the angle (in radians) to use
  4501. * @param result defines the target matrix
  4502. */
  4503. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4504. /**
  4505. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4506. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4507. * @param from defines the vector to align
  4508. * @param to defines the vector to align to
  4509. * @param result defines the target matrix
  4510. */
  4511. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4512. /**
  4513. * Creates a rotation matrix
  4514. * @param yaw defines the yaw angle in radians (Y axis)
  4515. * @param pitch defines the pitch angle in radians (X axis)
  4516. * @param roll defines the roll angle in radians (Z axis)
  4517. * @returns the new rotation matrix
  4518. */
  4519. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4520. /**
  4521. * Creates a rotation matrix and stores it in a given matrix
  4522. * @param yaw defines the yaw angle in radians (Y axis)
  4523. * @param pitch defines the pitch angle in radians (X axis)
  4524. * @param roll defines the roll angle in radians (Z axis)
  4525. * @param result defines the target matrix
  4526. */
  4527. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4528. /**
  4529. * Creates a scaling matrix
  4530. * @param x defines the scale factor on X axis
  4531. * @param y defines the scale factor on Y axis
  4532. * @param z defines the scale factor on Z axis
  4533. * @returns the new matrix
  4534. */
  4535. static Scaling(x: number, y: number, z: number): Matrix;
  4536. /**
  4537. * Creates a scaling matrix and stores it in a given matrix
  4538. * @param x defines the scale factor on X axis
  4539. * @param y defines the scale factor on Y axis
  4540. * @param z defines the scale factor on Z axis
  4541. * @param result defines the target matrix
  4542. */
  4543. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4544. /**
  4545. * Creates a translation matrix
  4546. * @param x defines the translation on X axis
  4547. * @param y defines the translation on Y axis
  4548. * @param z defines the translationon Z axis
  4549. * @returns the new matrix
  4550. */
  4551. static Translation(x: number, y: number, z: number): Matrix;
  4552. /**
  4553. * Creates a translation matrix and stores it in a given matrix
  4554. * @param x defines the translation on X axis
  4555. * @param y defines the translation on Y axis
  4556. * @param z defines the translationon Z axis
  4557. * @param result defines the target matrix
  4558. */
  4559. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4560. /**
  4561. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4562. * @param startValue defines the start value
  4563. * @param endValue defines the end value
  4564. * @param gradient defines the gradient factor
  4565. * @returns the new matrix
  4566. */
  4567. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4568. /**
  4569. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4570. * @param startValue defines the start value
  4571. * @param endValue defines the end value
  4572. * @param gradient defines the gradient factor
  4573. * @param result defines the Matrix object where to store data
  4574. */
  4575. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4576. /**
  4577. * Builds a new matrix whose values are computed by:
  4578. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4579. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4580. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4581. * @param startValue defines the first matrix
  4582. * @param endValue defines the second matrix
  4583. * @param gradient defines the gradient between the two matrices
  4584. * @returns the new matrix
  4585. */
  4586. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4587. /**
  4588. * Update a matrix to values which are computed by:
  4589. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4590. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4591. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4592. * @param startValue defines the first matrix
  4593. * @param endValue defines the second matrix
  4594. * @param gradient defines the gradient between the two matrices
  4595. * @param result defines the target matrix
  4596. */
  4597. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4598. /**
  4599. * 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"
  4600. * This function works in left handed mode
  4601. * @param eye defines the final position of the entity
  4602. * @param target defines where the entity should look at
  4603. * @param up defines the up vector for the entity
  4604. * @returns the new matrix
  4605. */
  4606. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4607. /**
  4608. * 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".
  4609. * This function works in left handed mode
  4610. * @param eye defines the final position of the entity
  4611. * @param target defines where the entity should look at
  4612. * @param up defines the up vector for the entity
  4613. * @param result defines the target matrix
  4614. */
  4615. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4616. /**
  4617. * 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"
  4618. * This function works in right handed mode
  4619. * @param eye defines the final position of the entity
  4620. * @param target defines where the entity should look at
  4621. * @param up defines the up vector for the entity
  4622. * @returns the new matrix
  4623. */
  4624. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4625. /**
  4626. * 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".
  4627. * This function works in right handed mode
  4628. * @param eye defines the final position of the entity
  4629. * @param target defines where the entity should look at
  4630. * @param up defines the up vector for the entity
  4631. * @param result defines the target matrix
  4632. */
  4633. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4634. /**
  4635. * Create a left-handed orthographic projection matrix
  4636. * @param width defines the viewport width
  4637. * @param height defines the viewport height
  4638. * @param znear defines the near clip plane
  4639. * @param zfar defines the far clip plane
  4640. * @returns a new matrix as a left-handed orthographic projection matrix
  4641. */
  4642. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4643. /**
  4644. * Store a left-handed orthographic projection to a given matrix
  4645. * @param width defines the viewport width
  4646. * @param height defines the viewport height
  4647. * @param znear defines the near clip plane
  4648. * @param zfar defines the far clip plane
  4649. * @param result defines the target matrix
  4650. */
  4651. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4652. /**
  4653. * Create a left-handed orthographic projection matrix
  4654. * @param left defines the viewport left coordinate
  4655. * @param right defines the viewport right coordinate
  4656. * @param bottom defines the viewport bottom coordinate
  4657. * @param top defines the viewport top coordinate
  4658. * @param znear defines the near clip plane
  4659. * @param zfar defines the far clip plane
  4660. * @returns a new matrix as a left-handed orthographic projection matrix
  4661. */
  4662. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4663. /**
  4664. * Stores a left-handed orthographic projection into a given matrix
  4665. * @param left defines the viewport left coordinate
  4666. * @param right defines the viewport right coordinate
  4667. * @param bottom defines the viewport bottom coordinate
  4668. * @param top defines the viewport top coordinate
  4669. * @param znear defines the near clip plane
  4670. * @param zfar defines the far clip plane
  4671. * @param result defines the target matrix
  4672. */
  4673. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4674. /**
  4675. * Creates a right-handed orthographic projection matrix
  4676. * @param left defines the viewport left coordinate
  4677. * @param right defines the viewport right coordinate
  4678. * @param bottom defines the viewport bottom coordinate
  4679. * @param top defines the viewport top coordinate
  4680. * @param znear defines the near clip plane
  4681. * @param zfar defines the far clip plane
  4682. * @returns a new matrix as a right-handed orthographic projection matrix
  4683. */
  4684. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4685. /**
  4686. * Stores a right-handed orthographic projection into a given matrix
  4687. * @param left defines the viewport left coordinate
  4688. * @param right defines the viewport right coordinate
  4689. * @param bottom defines the viewport bottom coordinate
  4690. * @param top defines the viewport top coordinate
  4691. * @param znear defines the near clip plane
  4692. * @param zfar defines the far clip plane
  4693. * @param result defines the target matrix
  4694. */
  4695. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4696. /**
  4697. * Creates a left-handed perspective projection matrix
  4698. * @param width defines the viewport width
  4699. * @param height defines the viewport height
  4700. * @param znear defines the near clip plane
  4701. * @param zfar defines the far clip plane
  4702. * @returns a new matrix as a left-handed perspective projection matrix
  4703. */
  4704. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4705. /**
  4706. * Creates a left-handed perspective projection matrix
  4707. * @param fov defines the horizontal field of view
  4708. * @param aspect defines the aspect ratio
  4709. * @param znear defines the near clip plane
  4710. * @param zfar defines the far clip plane
  4711. * @returns a new matrix as a left-handed perspective projection matrix
  4712. */
  4713. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4714. /**
  4715. * Stores a left-handed perspective projection into a given matrix
  4716. * @param fov defines the horizontal field of view
  4717. * @param aspect defines the aspect ratio
  4718. * @param znear defines the near clip plane
  4719. * @param zfar defines the far clip plane
  4720. * @param result defines the target matrix
  4721. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4722. */
  4723. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4724. /**
  4725. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4726. * @param fov defines the horizontal field of view
  4727. * @param aspect defines the aspect ratio
  4728. * @param znear defines the near clip plane
  4729. * @param zfar not used as infinity is used as far clip
  4730. * @param result defines the target matrix
  4731. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4732. */
  4733. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4734. /**
  4735. * Creates a right-handed perspective projection matrix
  4736. * @param fov defines the horizontal field of view
  4737. * @param aspect defines the aspect ratio
  4738. * @param znear defines the near clip plane
  4739. * @param zfar defines the far clip plane
  4740. * @returns a new matrix as a right-handed perspective projection matrix
  4741. */
  4742. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4743. /**
  4744. * Stores a right-handed perspective projection into a given matrix
  4745. * @param fov defines the horizontal field of view
  4746. * @param aspect defines the aspect ratio
  4747. * @param znear defines the near clip plane
  4748. * @param zfar defines the far clip plane
  4749. * @param result defines the target matrix
  4750. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4751. */
  4752. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4753. /**
  4754. * Stores a right-handed perspective projection into a given matrix
  4755. * @param fov defines the horizontal field of view
  4756. * @param aspect defines the aspect ratio
  4757. * @param znear defines the near clip plane
  4758. * @param zfar not used as infinity is used as far clip
  4759. * @param result defines the target matrix
  4760. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4761. */
  4762. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4763. /**
  4764. * Stores a perspective projection for WebVR info a given matrix
  4765. * @param fov defines the field of view
  4766. * @param znear defines the near clip plane
  4767. * @param zfar defines the far clip plane
  4768. * @param result defines the target matrix
  4769. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4770. */
  4771. static PerspectiveFovWebVRToRef(fov: {
  4772. upDegrees: number;
  4773. downDegrees: number;
  4774. leftDegrees: number;
  4775. rightDegrees: number;
  4776. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4777. /**
  4778. * Computes a complete transformation matrix
  4779. * @param viewport defines the viewport to use
  4780. * @param world defines the world matrix
  4781. * @param view defines the view matrix
  4782. * @param projection defines the projection matrix
  4783. * @param zmin defines the near clip plane
  4784. * @param zmax defines the far clip plane
  4785. * @returns the transformation matrix
  4786. */
  4787. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4788. /**
  4789. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4790. * @param matrix defines the matrix to use
  4791. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4792. */
  4793. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4794. /**
  4795. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4796. * @param matrix defines the matrix to use
  4797. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4798. */
  4799. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4800. /**
  4801. * Compute the transpose of a given matrix
  4802. * @param matrix defines the matrix to transpose
  4803. * @returns the new matrix
  4804. */
  4805. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4806. /**
  4807. * Compute the transpose of a matrix and store it in a target matrix
  4808. * @param matrix defines the matrix to transpose
  4809. * @param result defines the target matrix
  4810. */
  4811. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4812. /**
  4813. * Computes a reflection matrix from a plane
  4814. * @param plane defines the reflection plane
  4815. * @returns a new matrix
  4816. */
  4817. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4818. /**
  4819. * Computes a reflection matrix from a plane
  4820. * @param plane defines the reflection plane
  4821. * @param result defines the target matrix
  4822. */
  4823. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4824. /**
  4825. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4826. * @param xaxis defines the value of the 1st axis
  4827. * @param yaxis defines the value of the 2nd axis
  4828. * @param zaxis defines the value of the 3rd axis
  4829. * @param result defines the target matrix
  4830. */
  4831. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4832. /**
  4833. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4834. * @param quat defines the quaternion to use
  4835. * @param result defines the target matrix
  4836. */
  4837. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4838. }
  4839. /**
  4840. * @hidden
  4841. */
  4842. export class TmpVectors {
  4843. static Vector2: Vector2[];
  4844. static Vector3: Vector3[];
  4845. static Vector4: Vector4[];
  4846. static Quaternion: Quaternion[];
  4847. static Matrix: Matrix[];
  4848. }
  4849. }
  4850. declare module BABYLON {
  4851. /**
  4852. * Defines potential orientation for back face culling
  4853. */
  4854. export enum Orientation {
  4855. /**
  4856. * Clockwise
  4857. */
  4858. CW = 0,
  4859. /** Counter clockwise */
  4860. CCW = 1
  4861. }
  4862. /** Class used to represent a Bezier curve */
  4863. export class BezierCurve {
  4864. /**
  4865. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4866. * @param t defines the time
  4867. * @param x1 defines the left coordinate on X axis
  4868. * @param y1 defines the left coordinate on Y axis
  4869. * @param x2 defines the right coordinate on X axis
  4870. * @param y2 defines the right coordinate on Y axis
  4871. * @returns the interpolated value
  4872. */
  4873. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4874. }
  4875. /**
  4876. * Defines angle representation
  4877. */
  4878. export class Angle {
  4879. private _radians;
  4880. /**
  4881. * Creates an Angle object of "radians" radians (float).
  4882. * @param radians the angle in radians
  4883. */
  4884. constructor(radians: number);
  4885. /**
  4886. * Get value in degrees
  4887. * @returns the Angle value in degrees (float)
  4888. */
  4889. degrees(): number;
  4890. /**
  4891. * Get value in radians
  4892. * @returns the Angle value in radians (float)
  4893. */
  4894. radians(): number;
  4895. /**
  4896. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4897. * @param a defines first point as the origin
  4898. * @param b defines point
  4899. * @returns a new Angle
  4900. */
  4901. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4902. /**
  4903. * Gets a new Angle object from the given float in radians
  4904. * @param radians defines the angle value in radians
  4905. * @returns a new Angle
  4906. */
  4907. static FromRadians(radians: number): Angle;
  4908. /**
  4909. * Gets a new Angle object from the given float in degrees
  4910. * @param degrees defines the angle value in degrees
  4911. * @returns a new Angle
  4912. */
  4913. static FromDegrees(degrees: number): Angle;
  4914. }
  4915. /**
  4916. * This represents an arc in a 2d space.
  4917. */
  4918. export class Arc2 {
  4919. /** Defines the start point of the arc */
  4920. startPoint: Vector2;
  4921. /** Defines the mid point of the arc */
  4922. midPoint: Vector2;
  4923. /** Defines the end point of the arc */
  4924. endPoint: Vector2;
  4925. /**
  4926. * Defines the center point of the arc.
  4927. */
  4928. centerPoint: Vector2;
  4929. /**
  4930. * Defines the radius of the arc.
  4931. */
  4932. radius: number;
  4933. /**
  4934. * Defines the angle of the arc (from mid point to end point).
  4935. */
  4936. angle: Angle;
  4937. /**
  4938. * Defines the start angle of the arc (from start point to middle point).
  4939. */
  4940. startAngle: Angle;
  4941. /**
  4942. * Defines the orientation of the arc (clock wise/counter clock wise).
  4943. */
  4944. orientation: Orientation;
  4945. /**
  4946. * Creates an Arc object from the three given points : start, middle and end.
  4947. * @param startPoint Defines the start point of the arc
  4948. * @param midPoint Defines the midlle point of the arc
  4949. * @param endPoint Defines the end point of the arc
  4950. */
  4951. constructor(
  4952. /** Defines the start point of the arc */
  4953. startPoint: Vector2,
  4954. /** Defines the mid point of the arc */
  4955. midPoint: Vector2,
  4956. /** Defines the end point of the arc */
  4957. endPoint: Vector2);
  4958. }
  4959. /**
  4960. * Represents a 2D path made up of multiple 2D points
  4961. */
  4962. export class Path2 {
  4963. private _points;
  4964. private _length;
  4965. /**
  4966. * If the path start and end point are the same
  4967. */
  4968. closed: boolean;
  4969. /**
  4970. * Creates a Path2 object from the starting 2D coordinates x and y.
  4971. * @param x the starting points x value
  4972. * @param y the starting points y value
  4973. */
  4974. constructor(x: number, y: number);
  4975. /**
  4976. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4977. * @param x the added points x value
  4978. * @param y the added points y value
  4979. * @returns the updated Path2.
  4980. */
  4981. addLineTo(x: number, y: number): Path2;
  4982. /**
  4983. * 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.
  4984. * @param midX middle point x value
  4985. * @param midY middle point y value
  4986. * @param endX end point x value
  4987. * @param endY end point y value
  4988. * @param numberOfSegments (default: 36)
  4989. * @returns the updated Path2.
  4990. */
  4991. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4992. /**
  4993. * Closes the Path2.
  4994. * @returns the Path2.
  4995. */
  4996. close(): Path2;
  4997. /**
  4998. * Gets the sum of the distance between each sequential point in the path
  4999. * @returns the Path2 total length (float).
  5000. */
  5001. length(): number;
  5002. /**
  5003. * Gets the points which construct the path
  5004. * @returns the Path2 internal array of points.
  5005. */
  5006. getPoints(): Vector2[];
  5007. /**
  5008. * Retreives the point at the distance aways from the starting point
  5009. * @param normalizedLengthPosition the length along the path to retreive the point from
  5010. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5011. */
  5012. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5013. /**
  5014. * Creates a new path starting from an x and y position
  5015. * @param x starting x value
  5016. * @param y starting y value
  5017. * @returns a new Path2 starting at the coordinates (x, y).
  5018. */
  5019. static StartingAt(x: number, y: number): Path2;
  5020. }
  5021. /**
  5022. * Represents a 3D path made up of multiple 3D points
  5023. */
  5024. export class Path3D {
  5025. /**
  5026. * an array of Vector3, the curve axis of the Path3D
  5027. */
  5028. path: Vector3[];
  5029. private _curve;
  5030. private _distances;
  5031. private _tangents;
  5032. private _normals;
  5033. private _binormals;
  5034. private _raw;
  5035. private _alignTangentsWithPath;
  5036. private readonly _pointAtData;
  5037. /**
  5038. * new Path3D(path, normal, raw)
  5039. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5040. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5041. * @param path an array of Vector3, the curve axis of the Path3D
  5042. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5043. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5044. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5045. */
  5046. constructor(
  5047. /**
  5048. * an array of Vector3, the curve axis of the Path3D
  5049. */
  5050. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5051. /**
  5052. * Returns the Path3D array of successive Vector3 designing its curve.
  5053. * @returns the Path3D array of successive Vector3 designing its curve.
  5054. */
  5055. getCurve(): Vector3[];
  5056. /**
  5057. * Returns the Path3D array of successive Vector3 designing its curve.
  5058. * @returns the Path3D array of successive Vector3 designing its curve.
  5059. */
  5060. getPoints(): Vector3[];
  5061. /**
  5062. * @returns the computed length (float) of the path.
  5063. */
  5064. length(): number;
  5065. /**
  5066. * Returns an array populated with tangent vectors on each Path3D curve point.
  5067. * @returns an array populated with tangent vectors on each Path3D curve point.
  5068. */
  5069. getTangents(): Vector3[];
  5070. /**
  5071. * Returns an array populated with normal vectors on each Path3D curve point.
  5072. * @returns an array populated with normal vectors on each Path3D curve point.
  5073. */
  5074. getNormals(): Vector3[];
  5075. /**
  5076. * Returns an array populated with binormal vectors on each Path3D curve point.
  5077. * @returns an array populated with binormal vectors on each Path3D curve point.
  5078. */
  5079. getBinormals(): Vector3[];
  5080. /**
  5081. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5082. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5083. */
  5084. getDistances(): number[];
  5085. /**
  5086. * Returns an interpolated point along this path
  5087. * @param position the position of the point along this path, from 0.0 to 1.0
  5088. * @returns a new Vector3 as the point
  5089. */
  5090. getPointAt(position: number): Vector3;
  5091. /**
  5092. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5093. * @param position the position of the point along this path, from 0.0 to 1.0
  5094. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5095. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5096. */
  5097. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5098. /**
  5099. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5100. * @param position the position of the point along this path, from 0.0 to 1.0
  5101. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5102. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5103. */
  5104. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5105. /**
  5106. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5107. * @param position the position of the point along this path, from 0.0 to 1.0
  5108. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5109. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5110. */
  5111. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5112. /**
  5113. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5114. * @param position the position of the point along this path, from 0.0 to 1.0
  5115. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5116. */
  5117. getDistanceAt(position: number): number;
  5118. /**
  5119. * Returns the array index of the previous point of an interpolated point along this path
  5120. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5121. * @returns the array index
  5122. */
  5123. getPreviousPointIndexAt(position: number): number;
  5124. /**
  5125. * 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)
  5126. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5127. * @returns the sub position
  5128. */
  5129. getSubPositionAt(position: number): number;
  5130. /**
  5131. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5132. * @param target the vector of which to get the closest position to
  5133. * @returns the position of the closest virtual point on this path to the target vector
  5134. */
  5135. getClosestPositionTo(target: Vector3): number;
  5136. /**
  5137. * Returns a sub path (slice) of this path
  5138. * @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
  5139. * @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
  5140. * @returns a sub path (slice) of this path
  5141. */
  5142. slice(start?: number, end?: number): Path3D;
  5143. /**
  5144. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5145. * @param path path which all values are copied into the curves points
  5146. * @param firstNormal which should be projected onto the curve
  5147. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5148. * @returns the same object updated.
  5149. */
  5150. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5151. private _compute;
  5152. private _getFirstNonNullVector;
  5153. private _getLastNonNullVector;
  5154. private _normalVector;
  5155. /**
  5156. * Updates the point at data for an interpolated point along this curve
  5157. * @param position the position of the point along this curve, from 0.0 to 1.0
  5158. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5159. * @returns the (updated) point at data
  5160. */
  5161. private _updatePointAtData;
  5162. /**
  5163. * Updates the point at data from the specified parameters
  5164. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5165. * @param point the interpolated point
  5166. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5167. */
  5168. private _setPointAtData;
  5169. /**
  5170. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5171. */
  5172. private _updateInterpolationMatrix;
  5173. }
  5174. /**
  5175. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5176. * A Curve3 is designed from a series of successive Vector3.
  5177. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5178. */
  5179. export class Curve3 {
  5180. private _points;
  5181. private _length;
  5182. /**
  5183. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5184. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5185. * @param v1 (Vector3) the control point
  5186. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5187. * @param nbPoints (integer) the wanted number of points in the curve
  5188. * @returns the created Curve3
  5189. */
  5190. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5191. /**
  5192. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5193. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5194. * @param v1 (Vector3) the first control point
  5195. * @param v2 (Vector3) the second control point
  5196. * @param v3 (Vector3) the end point of the Cubic Bezier
  5197. * @param nbPoints (integer) the wanted number of points in the curve
  5198. * @returns the created Curve3
  5199. */
  5200. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5201. /**
  5202. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5203. * @param p1 (Vector3) the origin point of the Hermite Spline
  5204. * @param t1 (Vector3) the tangent vector at the origin point
  5205. * @param p2 (Vector3) the end point of the Hermite Spline
  5206. * @param t2 (Vector3) the tangent vector at the end point
  5207. * @param nbPoints (integer) the wanted number of points in the curve
  5208. * @returns the created Curve3
  5209. */
  5210. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5211. /**
  5212. * Returns a Curve3 object along a CatmullRom Spline curve :
  5213. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5214. * @param nbPoints (integer) the wanted number of points between each curve control points
  5215. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5216. * @returns the created Curve3
  5217. */
  5218. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5219. /**
  5220. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5221. * A Curve3 is designed from a series of successive Vector3.
  5222. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5223. * @param points points which make up the curve
  5224. */
  5225. constructor(points: Vector3[]);
  5226. /**
  5227. * @returns the Curve3 stored array of successive Vector3
  5228. */
  5229. getPoints(): Vector3[];
  5230. /**
  5231. * @returns the computed length (float) of the curve.
  5232. */
  5233. length(): number;
  5234. /**
  5235. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5236. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5237. * curveA and curveB keep unchanged.
  5238. * @param curve the curve to continue from this curve
  5239. * @returns the newly constructed curve
  5240. */
  5241. continue(curve: DeepImmutable<Curve3>): Curve3;
  5242. private _computeLength;
  5243. }
  5244. }
  5245. declare module BABYLON {
  5246. /**
  5247. * This represents the main contract an easing function should follow.
  5248. * Easing functions are used throughout the animation system.
  5249. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5250. */
  5251. export interface IEasingFunction {
  5252. /**
  5253. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5254. * of the easing function.
  5255. * The link below provides some of the most common examples of easing functions.
  5256. * @see https://easings.net/
  5257. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5258. * @returns the corresponding value on the curve defined by the easing function
  5259. */
  5260. ease(gradient: number): number;
  5261. }
  5262. /**
  5263. * Base class used for every default easing function.
  5264. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5265. */
  5266. export class EasingFunction implements IEasingFunction {
  5267. /**
  5268. * Interpolation follows the mathematical formula associated with the easing function.
  5269. */
  5270. static readonly EASINGMODE_EASEIN: number;
  5271. /**
  5272. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5273. */
  5274. static readonly EASINGMODE_EASEOUT: number;
  5275. /**
  5276. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5277. */
  5278. static readonly EASINGMODE_EASEINOUT: number;
  5279. private _easingMode;
  5280. /**
  5281. * Sets the easing mode of the current function.
  5282. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5283. */
  5284. setEasingMode(easingMode: number): void;
  5285. /**
  5286. * Gets the current easing mode.
  5287. * @returns the easing mode
  5288. */
  5289. getEasingMode(): number;
  5290. /**
  5291. * @hidden
  5292. */
  5293. easeInCore(gradient: number): number;
  5294. /**
  5295. * Given an input gradient between 0 and 1, this returns the corresponding value
  5296. * of the easing function.
  5297. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5298. * @returns the corresponding value on the curve defined by the easing function
  5299. */
  5300. ease(gradient: number): number;
  5301. }
  5302. /**
  5303. * Easing function with a circle shape (see link below).
  5304. * @see https://easings.net/#easeInCirc
  5305. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5306. */
  5307. export class CircleEase extends EasingFunction implements IEasingFunction {
  5308. /** @hidden */
  5309. easeInCore(gradient: number): number;
  5310. }
  5311. /**
  5312. * Easing function with a ease back shape (see link below).
  5313. * @see https://easings.net/#easeInBack
  5314. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5315. */
  5316. export class BackEase extends EasingFunction implements IEasingFunction {
  5317. /** Defines the amplitude of the function */
  5318. amplitude: number;
  5319. /**
  5320. * Instantiates a back ease easing
  5321. * @see https://easings.net/#easeInBack
  5322. * @param amplitude Defines the amplitude of the function
  5323. */
  5324. constructor(
  5325. /** Defines the amplitude of the function */
  5326. amplitude?: number);
  5327. /** @hidden */
  5328. easeInCore(gradient: number): number;
  5329. }
  5330. /**
  5331. * Easing function with a bouncing shape (see link below).
  5332. * @see https://easings.net/#easeInBounce
  5333. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5334. */
  5335. export class BounceEase extends EasingFunction implements IEasingFunction {
  5336. /** Defines the number of bounces */
  5337. bounces: number;
  5338. /** Defines the amplitude of the bounce */
  5339. bounciness: number;
  5340. /**
  5341. * Instantiates a bounce easing
  5342. * @see https://easings.net/#easeInBounce
  5343. * @param bounces Defines the number of bounces
  5344. * @param bounciness Defines the amplitude of the bounce
  5345. */
  5346. constructor(
  5347. /** Defines the number of bounces */
  5348. bounces?: number,
  5349. /** Defines the amplitude of the bounce */
  5350. bounciness?: number);
  5351. /** @hidden */
  5352. easeInCore(gradient: number): number;
  5353. }
  5354. /**
  5355. * Easing function with a power of 3 shape (see link below).
  5356. * @see https://easings.net/#easeInCubic
  5357. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5358. */
  5359. export class CubicEase extends EasingFunction implements IEasingFunction {
  5360. /** @hidden */
  5361. easeInCore(gradient: number): number;
  5362. }
  5363. /**
  5364. * Easing function with an elastic shape (see link below).
  5365. * @see https://easings.net/#easeInElastic
  5366. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5367. */
  5368. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5369. /** Defines the number of oscillations*/
  5370. oscillations: number;
  5371. /** Defines the amplitude of the oscillations*/
  5372. springiness: number;
  5373. /**
  5374. * Instantiates an elastic easing function
  5375. * @see https://easings.net/#easeInElastic
  5376. * @param oscillations Defines the number of oscillations
  5377. * @param springiness Defines the amplitude of the oscillations
  5378. */
  5379. constructor(
  5380. /** Defines the number of oscillations*/
  5381. oscillations?: number,
  5382. /** Defines the amplitude of the oscillations*/
  5383. springiness?: number);
  5384. /** @hidden */
  5385. easeInCore(gradient: number): number;
  5386. }
  5387. /**
  5388. * Easing function with an exponential shape (see link below).
  5389. * @see https://easings.net/#easeInExpo
  5390. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5391. */
  5392. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5393. /** Defines the exponent of the function */
  5394. exponent: number;
  5395. /**
  5396. * Instantiates an exponential easing function
  5397. * @see https://easings.net/#easeInExpo
  5398. * @param exponent Defines the exponent of the function
  5399. */
  5400. constructor(
  5401. /** Defines the exponent of the function */
  5402. exponent?: number);
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with a power shape (see link below).
  5408. * @see https://easings.net/#easeInQuad
  5409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class PowerEase extends EasingFunction implements IEasingFunction {
  5412. /** Defines the power of the function */
  5413. power: number;
  5414. /**
  5415. * Instantiates an power base easing function
  5416. * @see https://easings.net/#easeInQuad
  5417. * @param power Defines the power of the function
  5418. */
  5419. constructor(
  5420. /** Defines the power of the function */
  5421. power?: number);
  5422. /** @hidden */
  5423. easeInCore(gradient: number): number;
  5424. }
  5425. /**
  5426. * Easing function with a power of 2 shape (see link below).
  5427. * @see https://easings.net/#easeInQuad
  5428. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5429. */
  5430. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5431. /** @hidden */
  5432. easeInCore(gradient: number): number;
  5433. }
  5434. /**
  5435. * Easing function with a power of 4 shape (see link below).
  5436. * @see https://easings.net/#easeInQuart
  5437. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5438. */
  5439. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5440. /** @hidden */
  5441. easeInCore(gradient: number): number;
  5442. }
  5443. /**
  5444. * Easing function with a power of 5 shape (see link below).
  5445. * @see https://easings.net/#easeInQuint
  5446. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5447. */
  5448. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5449. /** @hidden */
  5450. easeInCore(gradient: number): number;
  5451. }
  5452. /**
  5453. * Easing function with a sin shape (see link below).
  5454. * @see https://easings.net/#easeInSine
  5455. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5456. */
  5457. export class SineEase extends EasingFunction implements IEasingFunction {
  5458. /** @hidden */
  5459. easeInCore(gradient: number): number;
  5460. }
  5461. /**
  5462. * Easing function with a bezier shape (see link below).
  5463. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5464. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5465. */
  5466. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5467. /** Defines the x component of the start tangent in the bezier curve */
  5468. x1: number;
  5469. /** Defines the y component of the start tangent in the bezier curve */
  5470. y1: number;
  5471. /** Defines the x component of the end tangent in the bezier curve */
  5472. x2: number;
  5473. /** Defines the y component of the end tangent in the bezier curve */
  5474. y2: number;
  5475. /**
  5476. * Instantiates a bezier function
  5477. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5478. * @param x1 Defines the x component of the start tangent in the bezier curve
  5479. * @param y1 Defines the y component of the start tangent in the bezier curve
  5480. * @param x2 Defines the x component of the end tangent in the bezier curve
  5481. * @param y2 Defines the y component of the end tangent in the bezier curve
  5482. */
  5483. constructor(
  5484. /** Defines the x component of the start tangent in the bezier curve */
  5485. x1?: number,
  5486. /** Defines the y component of the start tangent in the bezier curve */
  5487. y1?: number,
  5488. /** Defines the x component of the end tangent in the bezier curve */
  5489. x2?: number,
  5490. /** Defines the y component of the end tangent in the bezier curve */
  5491. y2?: number);
  5492. /** @hidden */
  5493. easeInCore(gradient: number): number;
  5494. }
  5495. }
  5496. declare module BABYLON {
  5497. /**
  5498. * Class used to hold a RBG color
  5499. */
  5500. export class Color3 {
  5501. /**
  5502. * Defines the red component (between 0 and 1, default is 0)
  5503. */
  5504. r: number;
  5505. /**
  5506. * Defines the green component (between 0 and 1, default is 0)
  5507. */
  5508. g: number;
  5509. /**
  5510. * Defines the blue component (between 0 and 1, default is 0)
  5511. */
  5512. b: number;
  5513. /**
  5514. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5515. * @param r defines the red component (between 0 and 1, default is 0)
  5516. * @param g defines the green component (between 0 and 1, default is 0)
  5517. * @param b defines the blue component (between 0 and 1, default is 0)
  5518. */
  5519. constructor(
  5520. /**
  5521. * Defines the red component (between 0 and 1, default is 0)
  5522. */
  5523. r?: number,
  5524. /**
  5525. * Defines the green component (between 0 and 1, default is 0)
  5526. */
  5527. g?: number,
  5528. /**
  5529. * Defines the blue component (between 0 and 1, default is 0)
  5530. */
  5531. b?: number);
  5532. /**
  5533. * Creates a string with the Color3 current values
  5534. * @returns the string representation of the Color3 object
  5535. */
  5536. toString(): string;
  5537. /**
  5538. * Returns the string "Color3"
  5539. * @returns "Color3"
  5540. */
  5541. getClassName(): string;
  5542. /**
  5543. * Compute the Color3 hash code
  5544. * @returns an unique number that can be used to hash Color3 objects
  5545. */
  5546. getHashCode(): number;
  5547. /**
  5548. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5549. * @param array defines the array where to store the r,g,b components
  5550. * @param index defines an optional index in the target array to define where to start storing values
  5551. * @returns the current Color3 object
  5552. */
  5553. toArray(array: FloatArray, index?: number): Color3;
  5554. /**
  5555. * Update the current color with values stored in an array from the starting index of the given array
  5556. * @param array defines the source array
  5557. * @param offset defines an offset in the source array
  5558. * @returns the current Color3 object
  5559. */
  5560. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5561. /**
  5562. * Returns a new Color4 object from the current Color3 and the given alpha
  5563. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5564. * @returns a new Color4 object
  5565. */
  5566. toColor4(alpha?: number): Color4;
  5567. /**
  5568. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5569. * @returns the new array
  5570. */
  5571. asArray(): number[];
  5572. /**
  5573. * Returns the luminance value
  5574. * @returns a float value
  5575. */
  5576. toLuminance(): number;
  5577. /**
  5578. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5579. * @param otherColor defines the second operand
  5580. * @returns the new Color3 object
  5581. */
  5582. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5583. /**
  5584. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5585. * @param otherColor defines the second operand
  5586. * @param result defines the Color3 object where to store the result
  5587. * @returns the current Color3
  5588. */
  5589. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5590. /**
  5591. * Determines equality between Color3 objects
  5592. * @param otherColor defines the second operand
  5593. * @returns true if the rgb values are equal to the given ones
  5594. */
  5595. equals(otherColor: DeepImmutable<Color3>): boolean;
  5596. /**
  5597. * Determines equality between the current Color3 object and a set of r,b,g values
  5598. * @param r defines the red component to check
  5599. * @param g defines the green component to check
  5600. * @param b defines the blue component to check
  5601. * @returns true if the rgb values are equal to the given ones
  5602. */
  5603. equalsFloats(r: number, g: number, b: number): boolean;
  5604. /**
  5605. * Multiplies in place each rgb value by scale
  5606. * @param scale defines the scaling factor
  5607. * @returns the updated Color3
  5608. */
  5609. scale(scale: number): Color3;
  5610. /**
  5611. * Multiplies the rgb values by scale and stores the result into "result"
  5612. * @param scale defines the scaling factor
  5613. * @param result defines the Color3 object where to store the result
  5614. * @returns the unmodified current Color3
  5615. */
  5616. scaleToRef(scale: number, result: Color3): Color3;
  5617. /**
  5618. * Scale the current Color3 values by a factor and add the result to a given Color3
  5619. * @param scale defines the scale factor
  5620. * @param result defines color to store the result into
  5621. * @returns the unmodified current Color3
  5622. */
  5623. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5624. /**
  5625. * Clamps the rgb values by the min and max values and stores the result into "result"
  5626. * @param min defines minimum clamping value (default is 0)
  5627. * @param max defines maximum clamping value (default is 1)
  5628. * @param result defines color to store the result into
  5629. * @returns the original Color3
  5630. */
  5631. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5632. /**
  5633. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5634. * @param otherColor defines the second operand
  5635. * @returns the new Color3
  5636. */
  5637. add(otherColor: DeepImmutable<Color3>): Color3;
  5638. /**
  5639. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5640. * @param otherColor defines the second operand
  5641. * @param result defines Color3 object to store the result into
  5642. * @returns the unmodified current Color3
  5643. */
  5644. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5645. /**
  5646. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5647. * @param otherColor defines the second operand
  5648. * @returns the new Color3
  5649. */
  5650. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5651. /**
  5652. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5653. * @param otherColor defines the second operand
  5654. * @param result defines Color3 object to store the result into
  5655. * @returns the unmodified current Color3
  5656. */
  5657. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5658. /**
  5659. * Copy the current object
  5660. * @returns a new Color3 copied the current one
  5661. */
  5662. clone(): Color3;
  5663. /**
  5664. * Copies the rgb values from the source in the current Color3
  5665. * @param source defines the source Color3 object
  5666. * @returns the updated Color3 object
  5667. */
  5668. copyFrom(source: DeepImmutable<Color3>): Color3;
  5669. /**
  5670. * Updates the Color3 rgb values from the given floats
  5671. * @param r defines the red component to read from
  5672. * @param g defines the green component to read from
  5673. * @param b defines the blue component to read from
  5674. * @returns the current Color3 object
  5675. */
  5676. copyFromFloats(r: number, g: number, b: number): Color3;
  5677. /**
  5678. * Updates the Color3 rgb values from the given floats
  5679. * @param r defines the red component to read from
  5680. * @param g defines the green component to read from
  5681. * @param b defines the blue component to read from
  5682. * @returns the current Color3 object
  5683. */
  5684. set(r: number, g: number, b: number): Color3;
  5685. /**
  5686. * Compute the Color3 hexadecimal code as a string
  5687. * @returns a string containing the hexadecimal representation of the Color3 object
  5688. */
  5689. toHexString(): string;
  5690. /**
  5691. * Computes a new Color3 converted from the current one to linear space
  5692. * @returns a new Color3 object
  5693. */
  5694. toLinearSpace(): Color3;
  5695. /**
  5696. * Converts current color in rgb space to HSV values
  5697. * @returns a new color3 representing the HSV values
  5698. */
  5699. toHSV(): Color3;
  5700. /**
  5701. * Converts current color in rgb space to HSV values
  5702. * @param result defines the Color3 where to store the HSV values
  5703. */
  5704. toHSVToRef(result: Color3): void;
  5705. /**
  5706. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5707. * @param convertedColor defines the Color3 object where to store the linear space version
  5708. * @returns the unmodified Color3
  5709. */
  5710. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5711. /**
  5712. * Computes a new Color3 converted from the current one to gamma space
  5713. * @returns a new Color3 object
  5714. */
  5715. toGammaSpace(): Color3;
  5716. /**
  5717. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5718. * @param convertedColor defines the Color3 object where to store the gamma space version
  5719. * @returns the unmodified Color3
  5720. */
  5721. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5722. private static _BlackReadOnly;
  5723. /**
  5724. * Convert Hue, saturation and value to a Color3 (RGB)
  5725. * @param hue defines the hue
  5726. * @param saturation defines the saturation
  5727. * @param value defines the value
  5728. * @param result defines the Color3 where to store the RGB values
  5729. */
  5730. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5731. /**
  5732. * Creates a new Color3 from the string containing valid hexadecimal values
  5733. * @param hex defines a string containing valid hexadecimal values
  5734. * @returns a new Color3 object
  5735. */
  5736. static FromHexString(hex: string): Color3;
  5737. /**
  5738. * Creates a new Color3 from the starting index of the given array
  5739. * @param array defines the source array
  5740. * @param offset defines an offset in the source array
  5741. * @returns a new Color3 object
  5742. */
  5743. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5744. /**
  5745. * Creates a new Color3 from the starting index element of the given array
  5746. * @param array defines the source array to read from
  5747. * @param offset defines the offset in the source array
  5748. * @param result defines the target Color3 object
  5749. */
  5750. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5751. /**
  5752. * Creates a new Color3 from integer values (< 256)
  5753. * @param r defines the red component to read from (value between 0 and 255)
  5754. * @param g defines the green component to read from (value between 0 and 255)
  5755. * @param b defines the blue component to read from (value between 0 and 255)
  5756. * @returns a new Color3 object
  5757. */
  5758. static FromInts(r: number, g: number, b: number): Color3;
  5759. /**
  5760. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5761. * @param start defines the start Color3 value
  5762. * @param end defines the end Color3 value
  5763. * @param amount defines the gradient value between start and end
  5764. * @returns a new Color3 object
  5765. */
  5766. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5767. /**
  5768. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5769. * @param left defines the start value
  5770. * @param right defines the end value
  5771. * @param amount defines the gradient factor
  5772. * @param result defines the Color3 object where to store the result
  5773. */
  5774. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5775. /**
  5776. * Returns a Color3 value containing a red color
  5777. * @returns a new Color3 object
  5778. */
  5779. static Red(): Color3;
  5780. /**
  5781. * Returns a Color3 value containing a green color
  5782. * @returns a new Color3 object
  5783. */
  5784. static Green(): Color3;
  5785. /**
  5786. * Returns a Color3 value containing a blue color
  5787. * @returns a new Color3 object
  5788. */
  5789. static Blue(): Color3;
  5790. /**
  5791. * Returns a Color3 value containing a black color
  5792. * @returns a new Color3 object
  5793. */
  5794. static Black(): Color3;
  5795. /**
  5796. * Gets a Color3 value containing a black color that must not be updated
  5797. */
  5798. static get BlackReadOnly(): DeepImmutable<Color3>;
  5799. /**
  5800. * Returns a Color3 value containing a white color
  5801. * @returns a new Color3 object
  5802. */
  5803. static White(): Color3;
  5804. /**
  5805. * Returns a Color3 value containing a purple color
  5806. * @returns a new Color3 object
  5807. */
  5808. static Purple(): Color3;
  5809. /**
  5810. * Returns a Color3 value containing a magenta color
  5811. * @returns a new Color3 object
  5812. */
  5813. static Magenta(): Color3;
  5814. /**
  5815. * Returns a Color3 value containing a yellow color
  5816. * @returns a new Color3 object
  5817. */
  5818. static Yellow(): Color3;
  5819. /**
  5820. * Returns a Color3 value containing a gray color
  5821. * @returns a new Color3 object
  5822. */
  5823. static Gray(): Color3;
  5824. /**
  5825. * Returns a Color3 value containing a teal color
  5826. * @returns a new Color3 object
  5827. */
  5828. static Teal(): Color3;
  5829. /**
  5830. * Returns a Color3 value containing a random color
  5831. * @returns a new Color3 object
  5832. */
  5833. static Random(): Color3;
  5834. }
  5835. /**
  5836. * Class used to hold a RBGA color
  5837. */
  5838. export class Color4 {
  5839. /**
  5840. * Defines the red component (between 0 and 1, default is 0)
  5841. */
  5842. r: number;
  5843. /**
  5844. * Defines the green component (between 0 and 1, default is 0)
  5845. */
  5846. g: number;
  5847. /**
  5848. * Defines the blue component (between 0 and 1, default is 0)
  5849. */
  5850. b: number;
  5851. /**
  5852. * Defines the alpha component (between 0 and 1, default is 1)
  5853. */
  5854. a: number;
  5855. /**
  5856. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5857. * @param r defines the red component (between 0 and 1, default is 0)
  5858. * @param g defines the green component (between 0 and 1, default is 0)
  5859. * @param b defines the blue component (between 0 and 1, default is 0)
  5860. * @param a defines the alpha component (between 0 and 1, default is 1)
  5861. */
  5862. constructor(
  5863. /**
  5864. * Defines the red component (between 0 and 1, default is 0)
  5865. */
  5866. r?: number,
  5867. /**
  5868. * Defines the green component (between 0 and 1, default is 0)
  5869. */
  5870. g?: number,
  5871. /**
  5872. * Defines the blue component (between 0 and 1, default is 0)
  5873. */
  5874. b?: number,
  5875. /**
  5876. * Defines the alpha component (between 0 and 1, default is 1)
  5877. */
  5878. a?: number);
  5879. /**
  5880. * Adds in place the given Color4 values to the current Color4 object
  5881. * @param right defines the second operand
  5882. * @returns the current updated Color4 object
  5883. */
  5884. addInPlace(right: DeepImmutable<Color4>): Color4;
  5885. /**
  5886. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5887. * @returns the new array
  5888. */
  5889. asArray(): number[];
  5890. /**
  5891. * Stores from the starting index in the given array the Color4 successive values
  5892. * @param array defines the array where to store the r,g,b components
  5893. * @param index defines an optional index in the target array to define where to start storing values
  5894. * @returns the current Color4 object
  5895. */
  5896. toArray(array: number[], index?: number): Color4;
  5897. /**
  5898. * Update the current color with values stored in an array from the starting index of the given array
  5899. * @param array defines the source array
  5900. * @param offset defines an offset in the source array
  5901. * @returns the current Color4 object
  5902. */
  5903. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5904. /**
  5905. * Determines equality between Color4 objects
  5906. * @param otherColor defines the second operand
  5907. * @returns true if the rgba values are equal to the given ones
  5908. */
  5909. equals(otherColor: DeepImmutable<Color4>): boolean;
  5910. /**
  5911. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5912. * @param right defines the second operand
  5913. * @returns a new Color4 object
  5914. */
  5915. add(right: DeepImmutable<Color4>): Color4;
  5916. /**
  5917. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5918. * @param right defines the second operand
  5919. * @returns a new Color4 object
  5920. */
  5921. subtract(right: DeepImmutable<Color4>): Color4;
  5922. /**
  5923. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5924. * @param right defines the second operand
  5925. * @param result defines the Color4 object where to store the result
  5926. * @returns the current Color4 object
  5927. */
  5928. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5929. /**
  5930. * Creates a new Color4 with the current Color4 values multiplied by scale
  5931. * @param scale defines the scaling factor to apply
  5932. * @returns a new Color4 object
  5933. */
  5934. scale(scale: number): Color4;
  5935. /**
  5936. * Multiplies the current Color4 values by scale and stores the result in "result"
  5937. * @param scale defines the scaling factor to apply
  5938. * @param result defines the Color4 object where to store the result
  5939. * @returns the current unmodified Color4
  5940. */
  5941. scaleToRef(scale: number, result: Color4): Color4;
  5942. /**
  5943. * Scale the current Color4 values by a factor and add the result to a given Color4
  5944. * @param scale defines the scale factor
  5945. * @param result defines the Color4 object where to store the result
  5946. * @returns the unmodified current Color4
  5947. */
  5948. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5949. /**
  5950. * Clamps the rgb values by the min and max values and stores the result into "result"
  5951. * @param min defines minimum clamping value (default is 0)
  5952. * @param max defines maximum clamping value (default is 1)
  5953. * @param result defines color to store the result into.
  5954. * @returns the cuurent Color4
  5955. */
  5956. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5957. /**
  5958. * Multipy an Color4 value by another and return a new Color4 object
  5959. * @param color defines the Color4 value to multiply by
  5960. * @returns a new Color4 object
  5961. */
  5962. multiply(color: Color4): Color4;
  5963. /**
  5964. * Multipy a Color4 value by another and push the result in a reference value
  5965. * @param color defines the Color4 value to multiply by
  5966. * @param result defines the Color4 to fill the result in
  5967. * @returns the result Color4
  5968. */
  5969. multiplyToRef(color: Color4, result: Color4): Color4;
  5970. /**
  5971. * Creates a string with the Color4 current values
  5972. * @returns the string representation of the Color4 object
  5973. */
  5974. toString(): string;
  5975. /**
  5976. * Returns the string "Color4"
  5977. * @returns "Color4"
  5978. */
  5979. getClassName(): string;
  5980. /**
  5981. * Compute the Color4 hash code
  5982. * @returns an unique number that can be used to hash Color4 objects
  5983. */
  5984. getHashCode(): number;
  5985. /**
  5986. * Creates a new Color4 copied from the current one
  5987. * @returns a new Color4 object
  5988. */
  5989. clone(): Color4;
  5990. /**
  5991. * Copies the given Color4 values into the current one
  5992. * @param source defines the source Color4 object
  5993. * @returns the current updated Color4 object
  5994. */
  5995. copyFrom(source: Color4): Color4;
  5996. /**
  5997. * Copies the given float values into the current one
  5998. * @param r defines the red component to read from
  5999. * @param g defines the green component to read from
  6000. * @param b defines the blue component to read from
  6001. * @param a defines the alpha component to read from
  6002. * @returns the current updated Color4 object
  6003. */
  6004. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6005. /**
  6006. * Copies the given float values into the current one
  6007. * @param r defines the red component to read from
  6008. * @param g defines the green component to read from
  6009. * @param b defines the blue component to read from
  6010. * @param a defines the alpha component to read from
  6011. * @returns the current updated Color4 object
  6012. */
  6013. set(r: number, g: number, b: number, a: number): Color4;
  6014. /**
  6015. * Compute the Color4 hexadecimal code as a string
  6016. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6017. * @returns a string containing the hexadecimal representation of the Color4 object
  6018. */
  6019. toHexString(returnAsColor3?: boolean): string;
  6020. /**
  6021. * Computes a new Color4 converted from the current one to linear space
  6022. * @returns a new Color4 object
  6023. */
  6024. toLinearSpace(): Color4;
  6025. /**
  6026. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6027. * @param convertedColor defines the Color4 object where to store the linear space version
  6028. * @returns the unmodified Color4
  6029. */
  6030. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6031. /**
  6032. * Computes a new Color4 converted from the current one to gamma space
  6033. * @returns a new Color4 object
  6034. */
  6035. toGammaSpace(): Color4;
  6036. /**
  6037. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6038. * @param convertedColor defines the Color4 object where to store the gamma space version
  6039. * @returns the unmodified Color4
  6040. */
  6041. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6042. /**
  6043. * Creates a new Color4 from the string containing valid hexadecimal values
  6044. * @param hex defines a string containing valid hexadecimal values
  6045. * @returns a new Color4 object
  6046. */
  6047. static FromHexString(hex: string): Color4;
  6048. /**
  6049. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6050. * @param left defines the start value
  6051. * @param right defines the end value
  6052. * @param amount defines the gradient factor
  6053. * @returns a new Color4 object
  6054. */
  6055. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6056. /**
  6057. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6058. * @param left defines the start value
  6059. * @param right defines the end value
  6060. * @param amount defines the gradient factor
  6061. * @param result defines the Color4 object where to store data
  6062. */
  6063. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6064. /**
  6065. * Creates a new Color4 from a Color3 and an alpha value
  6066. * @param color3 defines the source Color3 to read from
  6067. * @param alpha defines the alpha component (1.0 by default)
  6068. * @returns a new Color4 object
  6069. */
  6070. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6071. /**
  6072. * Creates a new Color4 from the starting index element of the given array
  6073. * @param array defines the source array to read from
  6074. * @param offset defines the offset in the source array
  6075. * @returns a new Color4 object
  6076. */
  6077. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6078. /**
  6079. * Creates a new Color4 from the starting index element of the given array
  6080. * @param array defines the source array to read from
  6081. * @param offset defines the offset in the source array
  6082. * @param result defines the target Color4 object
  6083. */
  6084. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6085. /**
  6086. * Creates a new Color3 from integer values (< 256)
  6087. * @param r defines the red component to read from (value between 0 and 255)
  6088. * @param g defines the green component to read from (value between 0 and 255)
  6089. * @param b defines the blue component to read from (value between 0 and 255)
  6090. * @param a defines the alpha component to read from (value between 0 and 255)
  6091. * @returns a new Color3 object
  6092. */
  6093. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6094. /**
  6095. * Check the content of a given array and convert it to an array containing RGBA data
  6096. * If the original array was already containing count * 4 values then it is returned directly
  6097. * @param colors defines the array to check
  6098. * @param count defines the number of RGBA data to expect
  6099. * @returns an array containing count * 4 values (RGBA)
  6100. */
  6101. static CheckColors4(colors: number[], count: number): number[];
  6102. }
  6103. /**
  6104. * @hidden
  6105. */
  6106. export class TmpColors {
  6107. static Color3: Color3[];
  6108. static Color4: Color4[];
  6109. }
  6110. }
  6111. declare module BABYLON {
  6112. /**
  6113. * Defines an interface which represents an animation key frame
  6114. */
  6115. export interface IAnimationKey {
  6116. /**
  6117. * Frame of the key frame
  6118. */
  6119. frame: number;
  6120. /**
  6121. * Value at the specifies key frame
  6122. */
  6123. value: any;
  6124. /**
  6125. * The input tangent for the cubic hermite spline
  6126. */
  6127. inTangent?: any;
  6128. /**
  6129. * The output tangent for the cubic hermite spline
  6130. */
  6131. outTangent?: any;
  6132. /**
  6133. * The animation interpolation type
  6134. */
  6135. interpolation?: AnimationKeyInterpolation;
  6136. }
  6137. /**
  6138. * Enum for the animation key frame interpolation type
  6139. */
  6140. export enum AnimationKeyInterpolation {
  6141. /**
  6142. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6143. */
  6144. STEP = 1
  6145. }
  6146. }
  6147. declare module BABYLON {
  6148. /**
  6149. * Represents the range of an animation
  6150. */
  6151. export class AnimationRange {
  6152. /**The name of the animation range**/
  6153. name: string;
  6154. /**The starting frame of the animation */
  6155. from: number;
  6156. /**The ending frame of the animation*/
  6157. to: number;
  6158. /**
  6159. * Initializes the range of an animation
  6160. * @param name The name of the animation range
  6161. * @param from The starting frame of the animation
  6162. * @param to The ending frame of the animation
  6163. */
  6164. constructor(
  6165. /**The name of the animation range**/
  6166. name: string,
  6167. /**The starting frame of the animation */
  6168. from: number,
  6169. /**The ending frame of the animation*/
  6170. to: number);
  6171. /**
  6172. * Makes a copy of the animation range
  6173. * @returns A copy of the animation range
  6174. */
  6175. clone(): AnimationRange;
  6176. }
  6177. }
  6178. declare module BABYLON {
  6179. /**
  6180. * Composed of a frame, and an action function
  6181. */
  6182. export class AnimationEvent {
  6183. /** The frame for which the event is triggered **/
  6184. frame: number;
  6185. /** The event to perform when triggered **/
  6186. action: (currentFrame: number) => void;
  6187. /** Specifies if the event should be triggered only once**/
  6188. onlyOnce?: boolean | undefined;
  6189. /**
  6190. * Specifies if the animation event is done
  6191. */
  6192. isDone: boolean;
  6193. /**
  6194. * Initializes the animation event
  6195. * @param frame The frame for which the event is triggered
  6196. * @param action The event to perform when triggered
  6197. * @param onlyOnce Specifies if the event should be triggered only once
  6198. */
  6199. constructor(
  6200. /** The frame for which the event is triggered **/
  6201. frame: number,
  6202. /** The event to perform when triggered **/
  6203. action: (currentFrame: number) => void,
  6204. /** Specifies if the event should be triggered only once**/
  6205. onlyOnce?: boolean | undefined);
  6206. /** @hidden */
  6207. _clone(): AnimationEvent;
  6208. }
  6209. }
  6210. declare module BABYLON {
  6211. /**
  6212. * Interface used to define a behavior
  6213. */
  6214. export interface Behavior<T> {
  6215. /** gets or sets behavior's name */
  6216. name: string;
  6217. /**
  6218. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6219. */
  6220. init(): void;
  6221. /**
  6222. * Called when the behavior is attached to a target
  6223. * @param target defines the target where the behavior is attached to
  6224. */
  6225. attach(target: T): void;
  6226. /**
  6227. * Called when the behavior is detached from its target
  6228. */
  6229. detach(): void;
  6230. }
  6231. /**
  6232. * Interface implemented by classes supporting behaviors
  6233. */
  6234. export interface IBehaviorAware<T> {
  6235. /**
  6236. * Attach a behavior
  6237. * @param behavior defines the behavior to attach
  6238. * @returns the current host
  6239. */
  6240. addBehavior(behavior: Behavior<T>): T;
  6241. /**
  6242. * Remove a behavior from the current object
  6243. * @param behavior defines the behavior to detach
  6244. * @returns the current host
  6245. */
  6246. removeBehavior(behavior: Behavior<T>): T;
  6247. /**
  6248. * Gets a behavior using its name to search
  6249. * @param name defines the name to search
  6250. * @returns the behavior or null if not found
  6251. */
  6252. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6253. }
  6254. }
  6255. declare module BABYLON {
  6256. /**
  6257. * Defines an array and its length.
  6258. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6259. */
  6260. export interface ISmartArrayLike<T> {
  6261. /**
  6262. * The data of the array.
  6263. */
  6264. data: Array<T>;
  6265. /**
  6266. * The active length of the array.
  6267. */
  6268. length: number;
  6269. }
  6270. /**
  6271. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6272. */
  6273. export class SmartArray<T> implements ISmartArrayLike<T> {
  6274. /**
  6275. * The full set of data from the array.
  6276. */
  6277. data: Array<T>;
  6278. /**
  6279. * The active length of the array.
  6280. */
  6281. length: number;
  6282. protected _id: number;
  6283. /**
  6284. * Instantiates a Smart Array.
  6285. * @param capacity defines the default capacity of the array.
  6286. */
  6287. constructor(capacity: number);
  6288. /**
  6289. * Pushes a value at the end of the active data.
  6290. * @param value defines the object to push in the array.
  6291. */
  6292. push(value: T): void;
  6293. /**
  6294. * Iterates over the active data and apply the lambda to them.
  6295. * @param func defines the action to apply on each value.
  6296. */
  6297. forEach(func: (content: T) => void): void;
  6298. /**
  6299. * Sorts the full sets of data.
  6300. * @param compareFn defines the comparison function to apply.
  6301. */
  6302. sort(compareFn: (a: T, b: T) => number): void;
  6303. /**
  6304. * Resets the active data to an empty array.
  6305. */
  6306. reset(): void;
  6307. /**
  6308. * Releases all the data from the array as well as the array.
  6309. */
  6310. dispose(): void;
  6311. /**
  6312. * Concats the active data with a given array.
  6313. * @param array defines the data to concatenate with.
  6314. */
  6315. concat(array: any): void;
  6316. /**
  6317. * Returns the position of a value in the active data.
  6318. * @param value defines the value to find the index for
  6319. * @returns the index if found in the active data otherwise -1
  6320. */
  6321. indexOf(value: T): number;
  6322. /**
  6323. * Returns whether an element is part of the active data.
  6324. * @param value defines the value to look for
  6325. * @returns true if found in the active data otherwise false
  6326. */
  6327. contains(value: T): boolean;
  6328. private static _GlobalId;
  6329. }
  6330. /**
  6331. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6332. * The data in this array can only be present once
  6333. */
  6334. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6335. private _duplicateId;
  6336. /**
  6337. * Pushes a value at the end of the active data.
  6338. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6339. * @param value defines the object to push in the array.
  6340. */
  6341. push(value: T): void;
  6342. /**
  6343. * Pushes a value at the end of the active data.
  6344. * If the data is already present, it won t be added again
  6345. * @param value defines the object to push in the array.
  6346. * @returns true if added false if it was already present
  6347. */
  6348. pushNoDuplicate(value: T): boolean;
  6349. /**
  6350. * Resets the active data to an empty array.
  6351. */
  6352. reset(): void;
  6353. /**
  6354. * Concats the active data with a given array.
  6355. * This ensures no dupplicate will be present in the result.
  6356. * @param array defines the data to concatenate with.
  6357. */
  6358. concatWithNoDuplicate(array: any): void;
  6359. }
  6360. }
  6361. declare module BABYLON {
  6362. /**
  6363. * @ignore
  6364. * This is a list of all the different input types that are available in the application.
  6365. * Fo instance: ArcRotateCameraGamepadInput...
  6366. */
  6367. export var CameraInputTypes: {};
  6368. /**
  6369. * This is the contract to implement in order to create a new input class.
  6370. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6371. */
  6372. export interface ICameraInput<TCamera extends Camera> {
  6373. /**
  6374. * Defines the camera the input is attached to.
  6375. */
  6376. camera: Nullable<TCamera>;
  6377. /**
  6378. * Gets the class name of the current intput.
  6379. * @returns the class name
  6380. */
  6381. getClassName(): string;
  6382. /**
  6383. * Get the friendly name associated with the input class.
  6384. * @returns the input friendly name
  6385. */
  6386. getSimpleName(): string;
  6387. /**
  6388. * Attach the input controls to a specific dom element to get the input from.
  6389. * @param element Defines the element the controls should be listened from
  6390. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6391. */
  6392. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6393. /**
  6394. * Detach the current controls from the specified dom element.
  6395. * @param element Defines the element to stop listening the inputs from
  6396. */
  6397. detachControl(element: Nullable<HTMLElement>): void;
  6398. /**
  6399. * Update the current camera state depending on the inputs that have been used this frame.
  6400. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6401. */
  6402. checkInputs?: () => void;
  6403. }
  6404. /**
  6405. * Represents a map of input types to input instance or input index to input instance.
  6406. */
  6407. export interface CameraInputsMap<TCamera extends Camera> {
  6408. /**
  6409. * Accessor to the input by input type.
  6410. */
  6411. [name: string]: ICameraInput<TCamera>;
  6412. /**
  6413. * Accessor to the input by input index.
  6414. */
  6415. [idx: number]: ICameraInput<TCamera>;
  6416. }
  6417. /**
  6418. * This represents the input manager used within a camera.
  6419. * It helps dealing with all the different kind of input attached to a camera.
  6420. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6421. */
  6422. export class CameraInputsManager<TCamera extends Camera> {
  6423. /**
  6424. * Defines the list of inputs attahed to the camera.
  6425. */
  6426. attached: CameraInputsMap<TCamera>;
  6427. /**
  6428. * Defines the dom element the camera is collecting inputs from.
  6429. * This is null if the controls have not been attached.
  6430. */
  6431. attachedElement: Nullable<HTMLElement>;
  6432. /**
  6433. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6434. */
  6435. noPreventDefault: boolean;
  6436. /**
  6437. * Defined the camera the input manager belongs to.
  6438. */
  6439. camera: TCamera;
  6440. /**
  6441. * Update the current camera state depending on the inputs that have been used this frame.
  6442. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6443. */
  6444. checkInputs: () => void;
  6445. /**
  6446. * Instantiate a new Camera Input Manager.
  6447. * @param camera Defines the camera the input manager blongs to
  6448. */
  6449. constructor(camera: TCamera);
  6450. /**
  6451. * Add an input method to a camera
  6452. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6453. * @param input camera input method
  6454. */
  6455. add(input: ICameraInput<TCamera>): void;
  6456. /**
  6457. * Remove a specific input method from a camera
  6458. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6459. * @param inputToRemove camera input method
  6460. */
  6461. remove(inputToRemove: ICameraInput<TCamera>): void;
  6462. /**
  6463. * Remove a specific input type from a camera
  6464. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6465. * @param inputType the type of the input to remove
  6466. */
  6467. removeByType(inputType: string): void;
  6468. private _addCheckInputs;
  6469. /**
  6470. * Attach the input controls to the currently attached dom element to listen the events from.
  6471. * @param input Defines the input to attach
  6472. */
  6473. attachInput(input: ICameraInput<TCamera>): void;
  6474. /**
  6475. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6476. * @param element Defines the dom element to collect the events from
  6477. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6478. */
  6479. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6480. /**
  6481. * Detach the current manager inputs controls from a specific dom element.
  6482. * @param element Defines the dom element to collect the events from
  6483. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6484. */
  6485. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6486. /**
  6487. * Rebuild the dynamic inputCheck function from the current list of
  6488. * defined inputs in the manager.
  6489. */
  6490. rebuildInputCheck(): void;
  6491. /**
  6492. * Remove all attached input methods from a camera
  6493. */
  6494. clear(): void;
  6495. /**
  6496. * Serialize the current input manager attached to a camera.
  6497. * This ensures than once parsed,
  6498. * the input associated to the camera will be identical to the current ones
  6499. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6500. */
  6501. serialize(serializedCamera: any): void;
  6502. /**
  6503. * Parses an input manager serialized JSON to restore the previous list of inputs
  6504. * and states associated to a camera.
  6505. * @param parsedCamera Defines the JSON to parse
  6506. */
  6507. parse(parsedCamera: any): void;
  6508. }
  6509. }
  6510. declare module BABYLON {
  6511. /**
  6512. * Class used to store data that will be store in GPU memory
  6513. */
  6514. export class Buffer {
  6515. private _engine;
  6516. private _buffer;
  6517. /** @hidden */
  6518. _data: Nullable<DataArray>;
  6519. private _updatable;
  6520. private _instanced;
  6521. private _divisor;
  6522. /**
  6523. * Gets the byte stride.
  6524. */
  6525. readonly byteStride: number;
  6526. /**
  6527. * Constructor
  6528. * @param engine the engine
  6529. * @param data the data to use for this buffer
  6530. * @param updatable whether the data is updatable
  6531. * @param stride the stride (optional)
  6532. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6533. * @param instanced whether the buffer is instanced (optional)
  6534. * @param useBytes set to true if the stride in in bytes (optional)
  6535. * @param divisor sets an optional divisor for instances (1 by default)
  6536. */
  6537. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6538. /**
  6539. * Create a new VertexBuffer based on the current buffer
  6540. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6541. * @param offset defines offset in the buffer (0 by default)
  6542. * @param size defines the size in floats of attributes (position is 3 for instance)
  6543. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6544. * @param instanced defines if the vertex buffer contains indexed data
  6545. * @param useBytes defines if the offset and stride are in bytes *
  6546. * @param divisor sets an optional divisor for instances (1 by default)
  6547. * @returns the new vertex buffer
  6548. */
  6549. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6550. /**
  6551. * Gets a boolean indicating if the Buffer is updatable?
  6552. * @returns true if the buffer is updatable
  6553. */
  6554. isUpdatable(): boolean;
  6555. /**
  6556. * Gets current buffer's data
  6557. * @returns a DataArray or null
  6558. */
  6559. getData(): Nullable<DataArray>;
  6560. /**
  6561. * Gets underlying native buffer
  6562. * @returns underlying native buffer
  6563. */
  6564. getBuffer(): Nullable<DataBuffer>;
  6565. /**
  6566. * Gets the stride in float32 units (i.e. byte stride / 4).
  6567. * May not be an integer if the byte stride is not divisible by 4.
  6568. * @returns the stride in float32 units
  6569. * @deprecated Please use byteStride instead.
  6570. */
  6571. getStrideSize(): number;
  6572. /**
  6573. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6574. * @param data defines the data to store
  6575. */
  6576. create(data?: Nullable<DataArray>): void;
  6577. /** @hidden */
  6578. _rebuild(): void;
  6579. /**
  6580. * Update current buffer data
  6581. * @param data defines the data to store
  6582. */
  6583. update(data: DataArray): void;
  6584. /**
  6585. * Updates the data directly.
  6586. * @param data the new data
  6587. * @param offset the new offset
  6588. * @param vertexCount the vertex count (optional)
  6589. * @param useBytes set to true if the offset is in bytes
  6590. */
  6591. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6592. /**
  6593. * Release all resources
  6594. */
  6595. dispose(): void;
  6596. }
  6597. /**
  6598. * Specialized buffer used to store vertex data
  6599. */
  6600. export class VertexBuffer {
  6601. /** @hidden */
  6602. _buffer: Buffer;
  6603. private _kind;
  6604. private _size;
  6605. private _ownsBuffer;
  6606. private _instanced;
  6607. private _instanceDivisor;
  6608. /**
  6609. * The byte type.
  6610. */
  6611. static readonly BYTE: number;
  6612. /**
  6613. * The unsigned byte type.
  6614. */
  6615. static readonly UNSIGNED_BYTE: number;
  6616. /**
  6617. * The short type.
  6618. */
  6619. static readonly SHORT: number;
  6620. /**
  6621. * The unsigned short type.
  6622. */
  6623. static readonly UNSIGNED_SHORT: number;
  6624. /**
  6625. * The integer type.
  6626. */
  6627. static readonly INT: number;
  6628. /**
  6629. * The unsigned integer type.
  6630. */
  6631. static readonly UNSIGNED_INT: number;
  6632. /**
  6633. * The float type.
  6634. */
  6635. static readonly FLOAT: number;
  6636. /**
  6637. * Gets or sets the instance divisor when in instanced mode
  6638. */
  6639. get instanceDivisor(): number;
  6640. set instanceDivisor(value: number);
  6641. /**
  6642. * Gets the byte stride.
  6643. */
  6644. readonly byteStride: number;
  6645. /**
  6646. * Gets the byte offset.
  6647. */
  6648. readonly byteOffset: number;
  6649. /**
  6650. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6651. */
  6652. readonly normalized: boolean;
  6653. /**
  6654. * Gets the data type of each component in the array.
  6655. */
  6656. readonly type: number;
  6657. /**
  6658. * Constructor
  6659. * @param engine the engine
  6660. * @param data the data to use for this vertex buffer
  6661. * @param kind the vertex buffer kind
  6662. * @param updatable whether the data is updatable
  6663. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6664. * @param stride the stride (optional)
  6665. * @param instanced whether the buffer is instanced (optional)
  6666. * @param offset the offset of the data (optional)
  6667. * @param size the number of components (optional)
  6668. * @param type the type of the component (optional)
  6669. * @param normalized whether the data contains normalized data (optional)
  6670. * @param useBytes set to true if stride and offset are in bytes (optional)
  6671. * @param divisor defines the instance divisor to use (1 by default)
  6672. */
  6673. 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);
  6674. /** @hidden */
  6675. _rebuild(): void;
  6676. /**
  6677. * Returns the kind of the VertexBuffer (string)
  6678. * @returns a string
  6679. */
  6680. getKind(): string;
  6681. /**
  6682. * Gets a boolean indicating if the VertexBuffer is updatable?
  6683. * @returns true if the buffer is updatable
  6684. */
  6685. isUpdatable(): boolean;
  6686. /**
  6687. * Gets current buffer's data
  6688. * @returns a DataArray or null
  6689. */
  6690. getData(): Nullable<DataArray>;
  6691. /**
  6692. * Gets underlying native buffer
  6693. * @returns underlying native buffer
  6694. */
  6695. getBuffer(): Nullable<DataBuffer>;
  6696. /**
  6697. * Gets the stride in float32 units (i.e. byte stride / 4).
  6698. * May not be an integer if the byte stride is not divisible by 4.
  6699. * @returns the stride in float32 units
  6700. * @deprecated Please use byteStride instead.
  6701. */
  6702. getStrideSize(): number;
  6703. /**
  6704. * Returns the offset as a multiple of the type byte length.
  6705. * @returns the offset in bytes
  6706. * @deprecated Please use byteOffset instead.
  6707. */
  6708. getOffset(): number;
  6709. /**
  6710. * Returns the number of components per vertex attribute (integer)
  6711. * @returns the size in float
  6712. */
  6713. getSize(): number;
  6714. /**
  6715. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6716. * @returns true if this buffer is instanced
  6717. */
  6718. getIsInstanced(): boolean;
  6719. /**
  6720. * Returns the instancing divisor, zero for non-instanced (integer).
  6721. * @returns a number
  6722. */
  6723. getInstanceDivisor(): number;
  6724. /**
  6725. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6726. * @param data defines the data to store
  6727. */
  6728. create(data?: DataArray): void;
  6729. /**
  6730. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6731. * This function will create a new buffer if the current one is not updatable
  6732. * @param data defines the data to store
  6733. */
  6734. update(data: DataArray): void;
  6735. /**
  6736. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6737. * Returns the directly updated WebGLBuffer.
  6738. * @param data the new data
  6739. * @param offset the new offset
  6740. * @param useBytes set to true if the offset is in bytes
  6741. */
  6742. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6743. /**
  6744. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6745. */
  6746. dispose(): void;
  6747. /**
  6748. * Enumerates each value of this vertex buffer as numbers.
  6749. * @param count the number of values to enumerate
  6750. * @param callback the callback function called for each value
  6751. */
  6752. forEach(count: number, callback: (value: number, index: number) => void): void;
  6753. /**
  6754. * Positions
  6755. */
  6756. static readonly PositionKind: string;
  6757. /**
  6758. * Normals
  6759. */
  6760. static readonly NormalKind: string;
  6761. /**
  6762. * Tangents
  6763. */
  6764. static readonly TangentKind: string;
  6765. /**
  6766. * Texture coordinates
  6767. */
  6768. static readonly UVKind: string;
  6769. /**
  6770. * Texture coordinates 2
  6771. */
  6772. static readonly UV2Kind: string;
  6773. /**
  6774. * Texture coordinates 3
  6775. */
  6776. static readonly UV3Kind: string;
  6777. /**
  6778. * Texture coordinates 4
  6779. */
  6780. static readonly UV4Kind: string;
  6781. /**
  6782. * Texture coordinates 5
  6783. */
  6784. static readonly UV5Kind: string;
  6785. /**
  6786. * Texture coordinates 6
  6787. */
  6788. static readonly UV6Kind: string;
  6789. /**
  6790. * Colors
  6791. */
  6792. static readonly ColorKind: string;
  6793. /**
  6794. * Matrix indices (for bones)
  6795. */
  6796. static readonly MatricesIndicesKind: string;
  6797. /**
  6798. * Matrix weights (for bones)
  6799. */
  6800. static readonly MatricesWeightsKind: string;
  6801. /**
  6802. * Additional matrix indices (for bones)
  6803. */
  6804. static readonly MatricesIndicesExtraKind: string;
  6805. /**
  6806. * Additional matrix weights (for bones)
  6807. */
  6808. static readonly MatricesWeightsExtraKind: string;
  6809. /**
  6810. * Deduces the stride given a kind.
  6811. * @param kind The kind string to deduce
  6812. * @returns The deduced stride
  6813. */
  6814. static DeduceStride(kind: string): number;
  6815. /**
  6816. * Gets the byte length of the given type.
  6817. * @param type the type
  6818. * @returns the number of bytes
  6819. */
  6820. static GetTypeByteLength(type: number): number;
  6821. /**
  6822. * Enumerates each value of the given parameters as numbers.
  6823. * @param data the data to enumerate
  6824. * @param byteOffset the byte offset of the data
  6825. * @param byteStride the byte stride of the data
  6826. * @param componentCount the number of components per element
  6827. * @param componentType the type of the component
  6828. * @param count the number of values to enumerate
  6829. * @param normalized whether the data is normalized
  6830. * @param callback the callback function called for each value
  6831. */
  6832. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6833. private static _GetFloatValue;
  6834. }
  6835. }
  6836. declare module BABYLON {
  6837. /**
  6838. * The options Interface for creating a Capsule Mesh
  6839. */
  6840. export interface ICreateCapsuleOptions {
  6841. /** The Orientation of the capsule. Default : Vector3.Up() */
  6842. orientation?: Vector3;
  6843. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6844. subdivisions: number;
  6845. /** Number of cylindrical segments on the capsule. */
  6846. tessellation: number;
  6847. /** Height or Length of the capsule. */
  6848. height: number;
  6849. /** Radius of the capsule. */
  6850. radius: number;
  6851. /** Height or Length of the capsule. */
  6852. capSubdivisions: number;
  6853. /** Overwrite for the top radius. */
  6854. radiusTop?: number;
  6855. /** Overwrite for the bottom radius. */
  6856. radiusBottom?: number;
  6857. /** Overwrite for the top capSubdivisions. */
  6858. topCapSubdivisions?: number;
  6859. /** Overwrite for the bottom capSubdivisions. */
  6860. bottomCapSubdivisions?: number;
  6861. }
  6862. /**
  6863. * Class containing static functions to help procedurally build meshes
  6864. */
  6865. export class CapsuleBuilder {
  6866. /**
  6867. * Creates a capsule or a pill mesh
  6868. * @param name defines the name of the mesh
  6869. * @param options The constructors options.
  6870. * @param scene The scene the mesh is scoped to.
  6871. * @returns Capsule Mesh
  6872. */
  6873. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6874. }
  6875. }
  6876. declare module BABYLON {
  6877. /**
  6878. * @hidden
  6879. */
  6880. export class IntersectionInfo {
  6881. bu: Nullable<number>;
  6882. bv: Nullable<number>;
  6883. distance: number;
  6884. faceId: number;
  6885. subMeshId: number;
  6886. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6887. }
  6888. }
  6889. declare module BABYLON {
  6890. /**
  6891. * Class used to store bounding sphere information
  6892. */
  6893. export class BoundingSphere {
  6894. /**
  6895. * Gets the center of the bounding sphere in local space
  6896. */
  6897. readonly center: Vector3;
  6898. /**
  6899. * Radius of the bounding sphere in local space
  6900. */
  6901. radius: number;
  6902. /**
  6903. * Gets the center of the bounding sphere in world space
  6904. */
  6905. readonly centerWorld: Vector3;
  6906. /**
  6907. * Radius of the bounding sphere in world space
  6908. */
  6909. radiusWorld: number;
  6910. /**
  6911. * Gets the minimum vector in local space
  6912. */
  6913. readonly minimum: Vector3;
  6914. /**
  6915. * Gets the maximum vector in local space
  6916. */
  6917. readonly maximum: Vector3;
  6918. private _worldMatrix;
  6919. private static readonly TmpVector3;
  6920. /**
  6921. * Creates a new bounding sphere
  6922. * @param min defines the minimum vector (in local space)
  6923. * @param max defines the maximum vector (in local space)
  6924. * @param worldMatrix defines the new world matrix
  6925. */
  6926. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6927. /**
  6928. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6929. * @param min defines the new minimum vector (in local space)
  6930. * @param max defines the new maximum vector (in local space)
  6931. * @param worldMatrix defines the new world matrix
  6932. */
  6933. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6934. /**
  6935. * Scale the current bounding sphere by applying a scale factor
  6936. * @param factor defines the scale factor to apply
  6937. * @returns the current bounding box
  6938. */
  6939. scale(factor: number): BoundingSphere;
  6940. /**
  6941. * Gets the world matrix of the bounding box
  6942. * @returns a matrix
  6943. */
  6944. getWorldMatrix(): DeepImmutable<Matrix>;
  6945. /** @hidden */
  6946. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6947. /**
  6948. * Tests if the bounding sphere is intersecting the frustum planes
  6949. * @param frustumPlanes defines the frustum planes to test
  6950. * @returns true if there is an intersection
  6951. */
  6952. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6953. /**
  6954. * Tests if the bounding sphere center is in between the frustum planes.
  6955. * Used for optimistic fast inclusion.
  6956. * @param frustumPlanes defines the frustum planes to test
  6957. * @returns true if the sphere center is in between the frustum planes
  6958. */
  6959. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6960. /**
  6961. * Tests if a point is inside the bounding sphere
  6962. * @param point defines the point to test
  6963. * @returns true if the point is inside the bounding sphere
  6964. */
  6965. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6966. /**
  6967. * Checks if two sphere intersct
  6968. * @param sphere0 sphere 0
  6969. * @param sphere1 sphere 1
  6970. * @returns true if the speres intersect
  6971. */
  6972. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6973. }
  6974. }
  6975. declare module BABYLON {
  6976. /**
  6977. * Class used to store bounding box information
  6978. */
  6979. export class BoundingBox implements ICullable {
  6980. /**
  6981. * Gets the 8 vectors representing the bounding box in local space
  6982. */
  6983. readonly vectors: Vector3[];
  6984. /**
  6985. * Gets the center of the bounding box in local space
  6986. */
  6987. readonly center: Vector3;
  6988. /**
  6989. * Gets the center of the bounding box in world space
  6990. */
  6991. readonly centerWorld: Vector3;
  6992. /**
  6993. * Gets the extend size in local space
  6994. */
  6995. readonly extendSize: Vector3;
  6996. /**
  6997. * Gets the extend size in world space
  6998. */
  6999. readonly extendSizeWorld: Vector3;
  7000. /**
  7001. * Gets the OBB (object bounding box) directions
  7002. */
  7003. readonly directions: Vector3[];
  7004. /**
  7005. * Gets the 8 vectors representing the bounding box in world space
  7006. */
  7007. readonly vectorsWorld: Vector3[];
  7008. /**
  7009. * Gets the minimum vector in world space
  7010. */
  7011. readonly minimumWorld: Vector3;
  7012. /**
  7013. * Gets the maximum vector in world space
  7014. */
  7015. readonly maximumWorld: Vector3;
  7016. /**
  7017. * Gets the minimum vector in local space
  7018. */
  7019. readonly minimum: Vector3;
  7020. /**
  7021. * Gets the maximum vector in local space
  7022. */
  7023. readonly maximum: Vector3;
  7024. private _worldMatrix;
  7025. private static readonly TmpVector3;
  7026. /**
  7027. * @hidden
  7028. */
  7029. _tag: number;
  7030. /**
  7031. * Creates a new bounding box
  7032. * @param min defines the minimum vector (in local space)
  7033. * @param max defines the maximum vector (in local space)
  7034. * @param worldMatrix defines the new world matrix
  7035. */
  7036. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7037. /**
  7038. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7039. * @param min defines the new minimum vector (in local space)
  7040. * @param max defines the new maximum vector (in local space)
  7041. * @param worldMatrix defines the new world matrix
  7042. */
  7043. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7044. /**
  7045. * Scale the current bounding box by applying a scale factor
  7046. * @param factor defines the scale factor to apply
  7047. * @returns the current bounding box
  7048. */
  7049. scale(factor: number): BoundingBox;
  7050. /**
  7051. * Gets the world matrix of the bounding box
  7052. * @returns a matrix
  7053. */
  7054. getWorldMatrix(): DeepImmutable<Matrix>;
  7055. /** @hidden */
  7056. _update(world: DeepImmutable<Matrix>): void;
  7057. /**
  7058. * Tests if the bounding box is intersecting the frustum planes
  7059. * @param frustumPlanes defines the frustum planes to test
  7060. * @returns true if there is an intersection
  7061. */
  7062. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7063. /**
  7064. * Tests if the bounding box is entirely inside the frustum planes
  7065. * @param frustumPlanes defines the frustum planes to test
  7066. * @returns true if there is an inclusion
  7067. */
  7068. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7069. /**
  7070. * Tests if a point is inside the bounding box
  7071. * @param point defines the point to test
  7072. * @returns true if the point is inside the bounding box
  7073. */
  7074. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7075. /**
  7076. * Tests if the bounding box intersects with a bounding sphere
  7077. * @param sphere defines the sphere to test
  7078. * @returns true if there is an intersection
  7079. */
  7080. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7081. /**
  7082. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7083. * @param min defines the min vector to use
  7084. * @param max defines the max vector to use
  7085. * @returns true if there is an intersection
  7086. */
  7087. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7088. /**
  7089. * Tests if two bounding boxes are intersections
  7090. * @param box0 defines the first box to test
  7091. * @param box1 defines the second box to test
  7092. * @returns true if there is an intersection
  7093. */
  7094. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7095. /**
  7096. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7097. * @param minPoint defines the minimum vector of the bounding box
  7098. * @param maxPoint defines the maximum vector of the bounding box
  7099. * @param sphereCenter defines the sphere center
  7100. * @param sphereRadius defines the sphere radius
  7101. * @returns true if there is an intersection
  7102. */
  7103. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7104. /**
  7105. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7106. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7107. * @param frustumPlanes defines the frustum planes to test
  7108. * @return true if there is an inclusion
  7109. */
  7110. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7111. /**
  7112. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7113. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7114. * @param frustumPlanes defines the frustum planes to test
  7115. * @return true if there is an intersection
  7116. */
  7117. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7118. }
  7119. }
  7120. declare module BABYLON {
  7121. /** @hidden */
  7122. export class Collider {
  7123. /** Define if a collision was found */
  7124. collisionFound: boolean;
  7125. /**
  7126. * Define last intersection point in local space
  7127. */
  7128. intersectionPoint: Vector3;
  7129. /**
  7130. * Define last collided mesh
  7131. */
  7132. collidedMesh: Nullable<AbstractMesh>;
  7133. private _collisionPoint;
  7134. private _planeIntersectionPoint;
  7135. private _tempVector;
  7136. private _tempVector2;
  7137. private _tempVector3;
  7138. private _tempVector4;
  7139. private _edge;
  7140. private _baseToVertex;
  7141. private _destinationPoint;
  7142. private _slidePlaneNormal;
  7143. private _displacementVector;
  7144. /** @hidden */
  7145. _radius: Vector3;
  7146. /** @hidden */
  7147. _retry: number;
  7148. private _velocity;
  7149. private _basePoint;
  7150. private _epsilon;
  7151. /** @hidden */
  7152. _velocityWorldLength: number;
  7153. /** @hidden */
  7154. _basePointWorld: Vector3;
  7155. private _velocityWorld;
  7156. private _normalizedVelocity;
  7157. /** @hidden */
  7158. _initialVelocity: Vector3;
  7159. /** @hidden */
  7160. _initialPosition: Vector3;
  7161. private _nearestDistance;
  7162. private _collisionMask;
  7163. get collisionMask(): number;
  7164. set collisionMask(mask: number);
  7165. /**
  7166. * Gets the plane normal used to compute the sliding response (in local space)
  7167. */
  7168. get slidePlaneNormal(): Vector3;
  7169. /** @hidden */
  7170. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7171. /** @hidden */
  7172. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7173. /** @hidden */
  7174. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7175. /** @hidden */
  7176. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7177. /** @hidden */
  7178. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7179. /** @hidden */
  7180. _getResponse(pos: Vector3, vel: Vector3): void;
  7181. }
  7182. }
  7183. declare module BABYLON {
  7184. /**
  7185. * Interface for cullable objects
  7186. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7187. */
  7188. export interface ICullable {
  7189. /**
  7190. * Checks if the object or part of the object is in the frustum
  7191. * @param frustumPlanes Camera near/planes
  7192. * @returns true if the object is in frustum otherwise false
  7193. */
  7194. isInFrustum(frustumPlanes: Plane[]): boolean;
  7195. /**
  7196. * Checks if a cullable object (mesh...) is in the camera frustum
  7197. * Unlike isInFrustum this cheks the full bounding box
  7198. * @param frustumPlanes Camera near/planes
  7199. * @returns true if the object is in frustum otherwise false
  7200. */
  7201. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7202. }
  7203. /**
  7204. * Info for a bounding data of a mesh
  7205. */
  7206. export class BoundingInfo implements ICullable {
  7207. /**
  7208. * Bounding box for the mesh
  7209. */
  7210. readonly boundingBox: BoundingBox;
  7211. /**
  7212. * Bounding sphere for the mesh
  7213. */
  7214. readonly boundingSphere: BoundingSphere;
  7215. private _isLocked;
  7216. private static readonly TmpVector3;
  7217. /**
  7218. * Constructs bounding info
  7219. * @param minimum min vector of the bounding box/sphere
  7220. * @param maximum max vector of the bounding box/sphere
  7221. * @param worldMatrix defines the new world matrix
  7222. */
  7223. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7224. /**
  7225. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7226. * @param min defines the new minimum vector (in local space)
  7227. * @param max defines the new maximum vector (in local space)
  7228. * @param worldMatrix defines the new world matrix
  7229. */
  7230. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7231. /**
  7232. * min vector of the bounding box/sphere
  7233. */
  7234. get minimum(): Vector3;
  7235. /**
  7236. * max vector of the bounding box/sphere
  7237. */
  7238. get maximum(): Vector3;
  7239. /**
  7240. * If the info is locked and won't be updated to avoid perf overhead
  7241. */
  7242. get isLocked(): boolean;
  7243. set isLocked(value: boolean);
  7244. /**
  7245. * Updates the bounding sphere and box
  7246. * @param world world matrix to be used to update
  7247. */
  7248. update(world: DeepImmutable<Matrix>): void;
  7249. /**
  7250. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7251. * @param center New center of the bounding info
  7252. * @param extend New extend of the bounding info
  7253. * @returns the current bounding info
  7254. */
  7255. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7256. /**
  7257. * Scale the current bounding info by applying a scale factor
  7258. * @param factor defines the scale factor to apply
  7259. * @returns the current bounding info
  7260. */
  7261. scale(factor: number): BoundingInfo;
  7262. /**
  7263. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7264. * @param frustumPlanes defines the frustum to test
  7265. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7266. * @returns true if the bounding info is in the frustum planes
  7267. */
  7268. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7269. /**
  7270. * Gets the world distance between the min and max points of the bounding box
  7271. */
  7272. get diagonalLength(): number;
  7273. /**
  7274. * Checks if a cullable object (mesh...) is in the camera frustum
  7275. * Unlike isInFrustum this cheks the full bounding box
  7276. * @param frustumPlanes Camera near/planes
  7277. * @returns true if the object is in frustum otherwise false
  7278. */
  7279. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7280. /** @hidden */
  7281. _checkCollision(collider: Collider): boolean;
  7282. /**
  7283. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7284. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7285. * @param point the point to check intersection with
  7286. * @returns if the point intersects
  7287. */
  7288. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7289. /**
  7290. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7291. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7292. * @param boundingInfo the bounding info to check intersection with
  7293. * @param precise if the intersection should be done using OBB
  7294. * @returns if the bounding info intersects
  7295. */
  7296. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7297. }
  7298. }
  7299. declare module BABYLON {
  7300. /**
  7301. * Extracts minimum and maximum values from a list of indexed positions
  7302. * @param positions defines the positions to use
  7303. * @param indices defines the indices to the positions
  7304. * @param indexStart defines the start index
  7305. * @param indexCount defines the end index
  7306. * @param bias defines bias value to add to the result
  7307. * @return minimum and maximum values
  7308. */
  7309. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7310. minimum: Vector3;
  7311. maximum: Vector3;
  7312. };
  7313. /**
  7314. * Extracts minimum and maximum values from a list of positions
  7315. * @param positions defines the positions to use
  7316. * @param start defines the start index in the positions array
  7317. * @param count defines the number of positions to handle
  7318. * @param bias defines bias value to add to the result
  7319. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7320. * @return minimum and maximum values
  7321. */
  7322. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7323. minimum: Vector3;
  7324. maximum: Vector3;
  7325. };
  7326. }
  7327. declare module BABYLON {
  7328. /** @hidden */
  7329. export class WebGLDataBuffer extends DataBuffer {
  7330. private _buffer;
  7331. constructor(resource: WebGLBuffer);
  7332. get underlyingResource(): any;
  7333. }
  7334. }
  7335. declare module BABYLON {
  7336. /** @hidden */
  7337. export class WebGLPipelineContext implements IPipelineContext {
  7338. engine: ThinEngine;
  7339. program: Nullable<WebGLProgram>;
  7340. context?: WebGLRenderingContext;
  7341. vertexShader?: WebGLShader;
  7342. fragmentShader?: WebGLShader;
  7343. isParallelCompiled: boolean;
  7344. onCompiled?: () => void;
  7345. transformFeedback?: WebGLTransformFeedback | null;
  7346. vertexCompilationError: Nullable<string>;
  7347. fragmentCompilationError: Nullable<string>;
  7348. programLinkError: Nullable<string>;
  7349. programValidationError: Nullable<string>;
  7350. get isAsync(): boolean;
  7351. get isReady(): boolean;
  7352. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7353. _getVertexShaderCode(): string | null;
  7354. _getFragmentShaderCode(): string | null;
  7355. }
  7356. }
  7357. declare module BABYLON {
  7358. interface ThinEngine {
  7359. /**
  7360. * Create an uniform buffer
  7361. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7362. * @param elements defines the content of the uniform buffer
  7363. * @returns the webGL uniform buffer
  7364. */
  7365. createUniformBuffer(elements: FloatArray): DataBuffer;
  7366. /**
  7367. * Create a dynamic uniform buffer
  7368. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7369. * @param elements defines the content of the uniform buffer
  7370. * @returns the webGL uniform buffer
  7371. */
  7372. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7373. /**
  7374. * Update an existing uniform buffer
  7375. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7376. * @param uniformBuffer defines the target uniform buffer
  7377. * @param elements defines the content to update
  7378. * @param offset defines the offset in the uniform buffer where update should start
  7379. * @param count defines the size of the data to update
  7380. */
  7381. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7382. /**
  7383. * Bind an uniform buffer to the current webGL context
  7384. * @param buffer defines the buffer to bind
  7385. */
  7386. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7387. /**
  7388. * Bind a buffer to the current webGL context at a given location
  7389. * @param buffer defines the buffer to bind
  7390. * @param location defines the index where to bind the buffer
  7391. */
  7392. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7393. /**
  7394. * Bind a specific block at a given index in a specific shader program
  7395. * @param pipelineContext defines the pipeline context to use
  7396. * @param blockName defines the block name
  7397. * @param index defines the index where to bind the block
  7398. */
  7399. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7400. }
  7401. }
  7402. declare module BABYLON {
  7403. /**
  7404. * Uniform buffer objects.
  7405. *
  7406. * Handles blocks of uniform on the GPU.
  7407. *
  7408. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7409. *
  7410. * For more information, please refer to :
  7411. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7412. */
  7413. export class UniformBuffer {
  7414. private _engine;
  7415. private _buffer;
  7416. private _data;
  7417. private _bufferData;
  7418. private _dynamic?;
  7419. private _uniformLocations;
  7420. private _uniformSizes;
  7421. private _uniformLocationPointer;
  7422. private _needSync;
  7423. private _noUBO;
  7424. private _currentEffect;
  7425. /** @hidden */
  7426. _alreadyBound: boolean;
  7427. private static _MAX_UNIFORM_SIZE;
  7428. private static _tempBuffer;
  7429. /**
  7430. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7431. * This is dynamic to allow compat with webgl 1 and 2.
  7432. * You will need to pass the name of the uniform as well as the value.
  7433. */
  7434. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7435. /**
  7436. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7437. * This is dynamic to allow compat with webgl 1 and 2.
  7438. * You will need to pass the name of the uniform as well as the value.
  7439. */
  7440. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7441. /**
  7442. * Lambda to Update a single float in a uniform buffer.
  7443. * This is dynamic to allow compat with webgl 1 and 2.
  7444. * You will need to pass the name of the uniform as well as the value.
  7445. */
  7446. updateFloat: (name: string, x: number) => void;
  7447. /**
  7448. * Lambda to Update a vec2 of float in a uniform buffer.
  7449. * This is dynamic to allow compat with webgl 1 and 2.
  7450. * You will need to pass the name of the uniform as well as the value.
  7451. */
  7452. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7453. /**
  7454. * Lambda to Update a vec3 of float in a uniform buffer.
  7455. * This is dynamic to allow compat with webgl 1 and 2.
  7456. * You will need to pass the name of the uniform as well as the value.
  7457. */
  7458. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7459. /**
  7460. * Lambda to Update a vec4 of float in a uniform buffer.
  7461. * This is dynamic to allow compat with webgl 1 and 2.
  7462. * You will need to pass the name of the uniform as well as the value.
  7463. */
  7464. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7465. /**
  7466. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7467. * This is dynamic to allow compat with webgl 1 and 2.
  7468. * You will need to pass the name of the uniform as well as the value.
  7469. */
  7470. updateMatrix: (name: string, mat: Matrix) => void;
  7471. /**
  7472. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7473. * This is dynamic to allow compat with webgl 1 and 2.
  7474. * You will need to pass the name of the uniform as well as the value.
  7475. */
  7476. updateVector3: (name: string, vector: Vector3) => void;
  7477. /**
  7478. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7479. * This is dynamic to allow compat with webgl 1 and 2.
  7480. * You will need to pass the name of the uniform as well as the value.
  7481. */
  7482. updateVector4: (name: string, vector: Vector4) => void;
  7483. /**
  7484. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7485. * This is dynamic to allow compat with webgl 1 and 2.
  7486. * You will need to pass the name of the uniform as well as the value.
  7487. */
  7488. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7489. /**
  7490. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7491. * This is dynamic to allow compat with webgl 1 and 2.
  7492. * You will need to pass the name of the uniform as well as the value.
  7493. */
  7494. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7495. /**
  7496. * Instantiates a new Uniform buffer objects.
  7497. *
  7498. * Handles blocks of uniform on the GPU.
  7499. *
  7500. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7501. *
  7502. * For more information, please refer to :
  7503. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7504. * @param engine Define the engine the buffer is associated with
  7505. * @param data Define the data contained in the buffer
  7506. * @param dynamic Define if the buffer is updatable
  7507. */
  7508. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7509. /**
  7510. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7511. * or just falling back on setUniformXXX calls.
  7512. */
  7513. get useUbo(): boolean;
  7514. /**
  7515. * Indicates if the WebGL underlying uniform buffer is in sync
  7516. * with the javascript cache data.
  7517. */
  7518. get isSync(): boolean;
  7519. /**
  7520. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7521. * Also, a dynamic UniformBuffer will disable cache verification and always
  7522. * update the underlying WebGL uniform buffer to the GPU.
  7523. * @returns if Dynamic, otherwise false
  7524. */
  7525. isDynamic(): boolean;
  7526. /**
  7527. * The data cache on JS side.
  7528. * @returns the underlying data as a float array
  7529. */
  7530. getData(): Float32Array;
  7531. /**
  7532. * The underlying WebGL Uniform buffer.
  7533. * @returns the webgl buffer
  7534. */
  7535. getBuffer(): Nullable<DataBuffer>;
  7536. /**
  7537. * std140 layout specifies how to align data within an UBO structure.
  7538. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7539. * for specs.
  7540. */
  7541. private _fillAlignment;
  7542. /**
  7543. * Adds an uniform in the buffer.
  7544. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7545. * for the layout to be correct !
  7546. * @param name Name of the uniform, as used in the uniform block in the shader.
  7547. * @param size Data size, or data directly.
  7548. */
  7549. addUniform(name: string, size: number | number[]): void;
  7550. /**
  7551. * Adds a Matrix 4x4 to the uniform buffer.
  7552. * @param name Name of the uniform, as used in the uniform block in the shader.
  7553. * @param mat A 4x4 matrix.
  7554. */
  7555. addMatrix(name: string, mat: Matrix): void;
  7556. /**
  7557. * Adds a vec2 to the uniform buffer.
  7558. * @param name Name of the uniform, as used in the uniform block in the shader.
  7559. * @param x Define the x component value of the vec2
  7560. * @param y Define the y component value of the vec2
  7561. */
  7562. addFloat2(name: string, x: number, y: number): void;
  7563. /**
  7564. * Adds a vec3 to the uniform buffer.
  7565. * @param name Name of the uniform, as used in the uniform block in the shader.
  7566. * @param x Define the x component value of the vec3
  7567. * @param y Define the y component value of the vec3
  7568. * @param z Define the z component value of the vec3
  7569. */
  7570. addFloat3(name: string, x: number, y: number, z: number): void;
  7571. /**
  7572. * Adds a vec3 to the uniform buffer.
  7573. * @param name Name of the uniform, as used in the uniform block in the shader.
  7574. * @param color Define the vec3 from a Color
  7575. */
  7576. addColor3(name: string, color: Color3): void;
  7577. /**
  7578. * Adds a vec4 to the uniform buffer.
  7579. * @param name Name of the uniform, as used in the uniform block in the shader.
  7580. * @param color Define the rgb components from a Color
  7581. * @param alpha Define the a component of the vec4
  7582. */
  7583. addColor4(name: string, color: Color3, alpha: number): void;
  7584. /**
  7585. * Adds a vec3 to the uniform buffer.
  7586. * @param name Name of the uniform, as used in the uniform block in the shader.
  7587. * @param vector Define the vec3 components from a Vector
  7588. */
  7589. addVector3(name: string, vector: Vector3): void;
  7590. /**
  7591. * Adds a Matrix 3x3 to the uniform buffer.
  7592. * @param name Name of the uniform, as used in the uniform block in the shader.
  7593. */
  7594. addMatrix3x3(name: string): void;
  7595. /**
  7596. * Adds a Matrix 2x2 to the uniform buffer.
  7597. * @param name Name of the uniform, as used in the uniform block in the shader.
  7598. */
  7599. addMatrix2x2(name: string): void;
  7600. /**
  7601. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7602. */
  7603. create(): void;
  7604. /** @hidden */
  7605. _rebuild(): void;
  7606. /**
  7607. * Updates the WebGL Uniform Buffer on the GPU.
  7608. * If the `dynamic` flag is set to true, no cache comparison is done.
  7609. * Otherwise, the buffer will be updated only if the cache differs.
  7610. */
  7611. update(): void;
  7612. /**
  7613. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7614. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7615. * @param data Define the flattened data
  7616. * @param size Define the size of the data.
  7617. */
  7618. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7619. private _valueCache;
  7620. private _cacheMatrix;
  7621. private _updateMatrix3x3ForUniform;
  7622. private _updateMatrix3x3ForEffect;
  7623. private _updateMatrix2x2ForEffect;
  7624. private _updateMatrix2x2ForUniform;
  7625. private _updateFloatForEffect;
  7626. private _updateFloatForUniform;
  7627. private _updateFloat2ForEffect;
  7628. private _updateFloat2ForUniform;
  7629. private _updateFloat3ForEffect;
  7630. private _updateFloat3ForUniform;
  7631. private _updateFloat4ForEffect;
  7632. private _updateFloat4ForUniform;
  7633. private _updateMatrixForEffect;
  7634. private _updateMatrixForUniform;
  7635. private _updateVector3ForEffect;
  7636. private _updateVector3ForUniform;
  7637. private _updateVector4ForEffect;
  7638. private _updateVector4ForUniform;
  7639. private _updateColor3ForEffect;
  7640. private _updateColor3ForUniform;
  7641. private _updateColor4ForEffect;
  7642. private _updateColor4ForUniform;
  7643. /**
  7644. * Sets a sampler uniform on the effect.
  7645. * @param name Define the name of the sampler.
  7646. * @param texture Define the texture to set in the sampler
  7647. */
  7648. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7649. /**
  7650. * Directly updates the value of the uniform in the cache AND on the GPU.
  7651. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7652. * @param data Define the flattened data
  7653. */
  7654. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7655. /**
  7656. * Binds this uniform buffer to an effect.
  7657. * @param effect Define the effect to bind the buffer to
  7658. * @param name Name of the uniform block in the shader.
  7659. */
  7660. bindToEffect(effect: Effect, name: string): void;
  7661. /**
  7662. * Disposes the uniform buffer.
  7663. */
  7664. dispose(): void;
  7665. }
  7666. }
  7667. declare module BABYLON {
  7668. /**
  7669. * Enum that determines the text-wrapping mode to use.
  7670. */
  7671. export enum InspectableType {
  7672. /**
  7673. * Checkbox for booleans
  7674. */
  7675. Checkbox = 0,
  7676. /**
  7677. * Sliders for numbers
  7678. */
  7679. Slider = 1,
  7680. /**
  7681. * Vector3
  7682. */
  7683. Vector3 = 2,
  7684. /**
  7685. * Quaternions
  7686. */
  7687. Quaternion = 3,
  7688. /**
  7689. * Color3
  7690. */
  7691. Color3 = 4,
  7692. /**
  7693. * String
  7694. */
  7695. String = 5
  7696. }
  7697. /**
  7698. * Interface used to define custom inspectable properties.
  7699. * This interface is used by the inspector to display custom property grids
  7700. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7701. */
  7702. export interface IInspectable {
  7703. /**
  7704. * Gets the label to display
  7705. */
  7706. label: string;
  7707. /**
  7708. * Gets the name of the property to edit
  7709. */
  7710. propertyName: string;
  7711. /**
  7712. * Gets the type of the editor to use
  7713. */
  7714. type: InspectableType;
  7715. /**
  7716. * Gets the minimum value of the property when using in "slider" mode
  7717. */
  7718. min?: number;
  7719. /**
  7720. * Gets the maximum value of the property when using in "slider" mode
  7721. */
  7722. max?: number;
  7723. /**
  7724. * Gets the setp to use when using in "slider" mode
  7725. */
  7726. step?: number;
  7727. }
  7728. }
  7729. declare module BABYLON {
  7730. /**
  7731. * Class used to provide helper for timing
  7732. */
  7733. export class TimingTools {
  7734. /**
  7735. * Polyfill for setImmediate
  7736. * @param action defines the action to execute after the current execution block
  7737. */
  7738. static SetImmediate(action: () => void): void;
  7739. }
  7740. }
  7741. declare module BABYLON {
  7742. /**
  7743. * Class used to enable instatition of objects by class name
  7744. */
  7745. export class InstantiationTools {
  7746. /**
  7747. * Use this object to register external classes like custom textures or material
  7748. * to allow the laoders to instantiate them
  7749. */
  7750. static RegisteredExternalClasses: {
  7751. [key: string]: Object;
  7752. };
  7753. /**
  7754. * Tries to instantiate a new object from a given class name
  7755. * @param className defines the class name to instantiate
  7756. * @returns the new object or null if the system was not able to do the instantiation
  7757. */
  7758. static Instantiate(className: string): any;
  7759. }
  7760. }
  7761. declare module BABYLON {
  7762. /**
  7763. * Define options used to create a depth texture
  7764. */
  7765. export class DepthTextureCreationOptions {
  7766. /** Specifies whether or not a stencil should be allocated in the texture */
  7767. generateStencil?: boolean;
  7768. /** Specifies whether or not bilinear filtering is enable on the texture */
  7769. bilinearFiltering?: boolean;
  7770. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7771. comparisonFunction?: number;
  7772. /** Specifies if the created texture is a cube texture */
  7773. isCube?: boolean;
  7774. }
  7775. }
  7776. declare module BABYLON {
  7777. interface ThinEngine {
  7778. /**
  7779. * Creates a depth stencil cube texture.
  7780. * This is only available in WebGL 2.
  7781. * @param size The size of face edge in the cube texture.
  7782. * @param options The options defining the cube texture.
  7783. * @returns The cube texture
  7784. */
  7785. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7786. /**
  7787. * Creates a cube texture
  7788. * @param rootUrl defines the url where the files to load is located
  7789. * @param scene defines the current scene
  7790. * @param files defines the list of files to load (1 per face)
  7791. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7792. * @param onLoad defines an optional callback raised when the texture is loaded
  7793. * @param onError defines an optional callback raised if there is an issue to load the texture
  7794. * @param format defines the format of the data
  7795. * @param forcedExtension defines the extension to use to pick the right loader
  7796. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7797. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7798. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7799. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7800. * @returns the cube texture as an InternalTexture
  7801. */
  7802. 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;
  7803. /**
  7804. * Creates a cube texture
  7805. * @param rootUrl defines the url where the files to load is located
  7806. * @param scene defines the current scene
  7807. * @param files defines the list of files to load (1 per face)
  7808. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7809. * @param onLoad defines an optional callback raised when the texture is loaded
  7810. * @param onError defines an optional callback raised if there is an issue to load the texture
  7811. * @param format defines the format of the data
  7812. * @param forcedExtension defines the extension to use to pick the right loader
  7813. * @returns the cube texture as an InternalTexture
  7814. */
  7815. 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;
  7816. /**
  7817. * Creates a cube texture
  7818. * @param rootUrl defines the url where the files to load is located
  7819. * @param scene defines the current scene
  7820. * @param files defines the list of files to load (1 per face)
  7821. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7822. * @param onLoad defines an optional callback raised when the texture is loaded
  7823. * @param onError defines an optional callback raised if there is an issue to load the texture
  7824. * @param format defines the format of the data
  7825. * @param forcedExtension defines the extension to use to pick the right loader
  7826. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7827. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7828. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7829. * @returns the cube texture as an InternalTexture
  7830. */
  7831. 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;
  7832. /** @hidden */
  7833. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7834. /** @hidden */
  7835. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7836. /** @hidden */
  7837. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7838. /** @hidden */
  7839. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7840. /**
  7841. * @hidden
  7842. */
  7843. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7844. }
  7845. }
  7846. declare module BABYLON {
  7847. /**
  7848. * Class for creating a cube texture
  7849. */
  7850. export class CubeTexture extends BaseTexture {
  7851. private _delayedOnLoad;
  7852. /**
  7853. * Observable triggered once the texture has been loaded.
  7854. */
  7855. onLoadObservable: Observable<CubeTexture>;
  7856. /**
  7857. * The url of the texture
  7858. */
  7859. url: string;
  7860. /**
  7861. * Gets or sets the center of the bounding box associated with the cube texture.
  7862. * It must define where the camera used to render the texture was set
  7863. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7864. */
  7865. boundingBoxPosition: Vector3;
  7866. private _boundingBoxSize;
  7867. /**
  7868. * Gets or sets the size of the bounding box associated with the cube texture
  7869. * When defined, the cubemap will switch to local mode
  7870. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7871. * @example https://www.babylonjs-playground.com/#RNASML
  7872. */
  7873. set boundingBoxSize(value: Vector3);
  7874. /**
  7875. * Returns the bounding box size
  7876. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7877. */
  7878. get boundingBoxSize(): Vector3;
  7879. protected _rotationY: number;
  7880. /**
  7881. * Sets texture matrix rotation angle around Y axis in radians.
  7882. */
  7883. set rotationY(value: number);
  7884. /**
  7885. * Gets texture matrix rotation angle around Y axis radians.
  7886. */
  7887. get rotationY(): number;
  7888. /**
  7889. * Are mip maps generated for this texture or not.
  7890. */
  7891. get noMipmap(): boolean;
  7892. private _noMipmap;
  7893. private _files;
  7894. protected _forcedExtension: Nullable<string>;
  7895. private _extensions;
  7896. private _textureMatrix;
  7897. private _format;
  7898. private _createPolynomials;
  7899. /**
  7900. * Creates a cube texture from an array of image urls
  7901. * @param files defines an array of image urls
  7902. * @param scene defines the hosting scene
  7903. * @param noMipmap specifies if mip maps are not used
  7904. * @returns a cube texture
  7905. */
  7906. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7907. /**
  7908. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7909. * @param url defines the url of the prefiltered texture
  7910. * @param scene defines the scene the texture is attached to
  7911. * @param forcedExtension defines the extension of the file if different from the url
  7912. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7913. * @return the prefiltered texture
  7914. */
  7915. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7916. /**
  7917. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7918. * as prefiltered data.
  7919. * @param rootUrl defines the url of the texture or the root name of the six images
  7920. * @param null defines the scene or engine the texture is attached to
  7921. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7922. * @param noMipmap defines if mipmaps should be created or not
  7923. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7924. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7925. * @param onError defines a callback triggered in case of error during load
  7926. * @param format defines the internal format to use for the texture once loaded
  7927. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7928. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7929. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7930. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7931. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7932. * @return the cube texture
  7933. */
  7934. 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);
  7935. /**
  7936. * Get the current class name of the texture useful for serialization or dynamic coding.
  7937. * @returns "CubeTexture"
  7938. */
  7939. getClassName(): string;
  7940. /**
  7941. * Update the url (and optional buffer) of this texture if url was null during construction.
  7942. * @param url the url of the texture
  7943. * @param forcedExtension defines the extension to use
  7944. * @param onLoad callback called when the texture is loaded (defaults to null)
  7945. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7946. */
  7947. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7948. /**
  7949. * Delays loading of the cube texture
  7950. * @param forcedExtension defines the extension to use
  7951. */
  7952. delayLoad(forcedExtension?: string): void;
  7953. /**
  7954. * Returns the reflection texture matrix
  7955. * @returns the reflection texture matrix
  7956. */
  7957. getReflectionTextureMatrix(): Matrix;
  7958. /**
  7959. * Sets the reflection texture matrix
  7960. * @param value Reflection texture matrix
  7961. */
  7962. setReflectionTextureMatrix(value: Matrix): void;
  7963. /**
  7964. * Parses text to create a cube texture
  7965. * @param parsedTexture define the serialized text to read from
  7966. * @param scene defines the hosting scene
  7967. * @param rootUrl defines the root url of the cube texture
  7968. * @returns a cube texture
  7969. */
  7970. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7971. /**
  7972. * Makes a clone, or deep copy, of the cube texture
  7973. * @returns a new cube texture
  7974. */
  7975. clone(): CubeTexture;
  7976. }
  7977. }
  7978. declare module BABYLON {
  7979. /**
  7980. * Manages the defines for the Material
  7981. */
  7982. export class MaterialDefines {
  7983. /** @hidden */
  7984. protected _keys: string[];
  7985. private _isDirty;
  7986. /** @hidden */
  7987. _renderId: number;
  7988. /** @hidden */
  7989. _areLightsDirty: boolean;
  7990. /** @hidden */
  7991. _areLightsDisposed: boolean;
  7992. /** @hidden */
  7993. _areAttributesDirty: boolean;
  7994. /** @hidden */
  7995. _areTexturesDirty: boolean;
  7996. /** @hidden */
  7997. _areFresnelDirty: boolean;
  7998. /** @hidden */
  7999. _areMiscDirty: boolean;
  8000. /** @hidden */
  8001. _areImageProcessingDirty: boolean;
  8002. /** @hidden */
  8003. _normals: boolean;
  8004. /** @hidden */
  8005. _uvs: boolean;
  8006. /** @hidden */
  8007. _needNormals: boolean;
  8008. /** @hidden */
  8009. _needUVs: boolean;
  8010. [id: string]: any;
  8011. /**
  8012. * Specifies if the material needs to be re-calculated
  8013. */
  8014. get isDirty(): boolean;
  8015. /**
  8016. * Marks the material to indicate that it has been re-calculated
  8017. */
  8018. markAsProcessed(): void;
  8019. /**
  8020. * Marks the material to indicate that it needs to be re-calculated
  8021. */
  8022. markAsUnprocessed(): void;
  8023. /**
  8024. * Marks the material to indicate all of its defines need to be re-calculated
  8025. */
  8026. markAllAsDirty(): void;
  8027. /**
  8028. * Marks the material to indicate that image processing needs to be re-calculated
  8029. */
  8030. markAsImageProcessingDirty(): void;
  8031. /**
  8032. * Marks the material to indicate the lights need to be re-calculated
  8033. * @param disposed Defines whether the light is dirty due to dispose or not
  8034. */
  8035. markAsLightDirty(disposed?: boolean): void;
  8036. /**
  8037. * Marks the attribute state as changed
  8038. */
  8039. markAsAttributesDirty(): void;
  8040. /**
  8041. * Marks the texture state as changed
  8042. */
  8043. markAsTexturesDirty(): void;
  8044. /**
  8045. * Marks the fresnel state as changed
  8046. */
  8047. markAsFresnelDirty(): void;
  8048. /**
  8049. * Marks the misc state as changed
  8050. */
  8051. markAsMiscDirty(): void;
  8052. /**
  8053. * Rebuilds the material defines
  8054. */
  8055. rebuild(): void;
  8056. /**
  8057. * Specifies if two material defines are equal
  8058. * @param other - A material define instance to compare to
  8059. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8060. */
  8061. isEqual(other: MaterialDefines): boolean;
  8062. /**
  8063. * Clones this instance's defines to another instance
  8064. * @param other - material defines to clone values to
  8065. */
  8066. cloneTo(other: MaterialDefines): void;
  8067. /**
  8068. * Resets the material define values
  8069. */
  8070. reset(): void;
  8071. /**
  8072. * Converts the material define values to a string
  8073. * @returns - String of material define information
  8074. */
  8075. toString(): string;
  8076. }
  8077. }
  8078. declare module BABYLON {
  8079. /**
  8080. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8081. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8082. * 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;
  8083. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8084. */
  8085. export class ColorCurves {
  8086. private _dirty;
  8087. private _tempColor;
  8088. private _globalCurve;
  8089. private _highlightsCurve;
  8090. private _midtonesCurve;
  8091. private _shadowsCurve;
  8092. private _positiveCurve;
  8093. private _negativeCurve;
  8094. private _globalHue;
  8095. private _globalDensity;
  8096. private _globalSaturation;
  8097. private _globalExposure;
  8098. /**
  8099. * Gets the global Hue value.
  8100. * 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).
  8101. */
  8102. get globalHue(): number;
  8103. /**
  8104. * Sets the global Hue value.
  8105. * 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).
  8106. */
  8107. set globalHue(value: number);
  8108. /**
  8109. * Gets the global Density value.
  8110. * 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.
  8111. * Values less than zero provide a filter of opposite hue.
  8112. */
  8113. get globalDensity(): number;
  8114. /**
  8115. * Sets the global Density value.
  8116. * 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.
  8117. * Values less than zero provide a filter of opposite hue.
  8118. */
  8119. set globalDensity(value: number);
  8120. /**
  8121. * Gets the global Saturation value.
  8122. * 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.
  8123. */
  8124. get globalSaturation(): number;
  8125. /**
  8126. * Sets the global Saturation value.
  8127. * 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.
  8128. */
  8129. set globalSaturation(value: number);
  8130. /**
  8131. * Gets the global Exposure value.
  8132. * 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.
  8133. */
  8134. get globalExposure(): number;
  8135. /**
  8136. * Sets the global Exposure value.
  8137. * 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.
  8138. */
  8139. set globalExposure(value: number);
  8140. private _highlightsHue;
  8141. private _highlightsDensity;
  8142. private _highlightsSaturation;
  8143. private _highlightsExposure;
  8144. /**
  8145. * Gets the highlights Hue value.
  8146. * 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).
  8147. */
  8148. get highlightsHue(): number;
  8149. /**
  8150. * Sets the highlights Hue value.
  8151. * 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).
  8152. */
  8153. set highlightsHue(value: number);
  8154. /**
  8155. * Gets the highlights Density value.
  8156. * 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.
  8157. * Values less than zero provide a filter of opposite hue.
  8158. */
  8159. get highlightsDensity(): number;
  8160. /**
  8161. * Sets the highlights Density value.
  8162. * 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.
  8163. * Values less than zero provide a filter of opposite hue.
  8164. */
  8165. set highlightsDensity(value: number);
  8166. /**
  8167. * Gets the highlights Saturation value.
  8168. * 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.
  8169. */
  8170. get highlightsSaturation(): number;
  8171. /**
  8172. * Sets the highlights Saturation value.
  8173. * 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.
  8174. */
  8175. set highlightsSaturation(value: number);
  8176. /**
  8177. * Gets the highlights Exposure value.
  8178. * 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.
  8179. */
  8180. get highlightsExposure(): number;
  8181. /**
  8182. * Sets the highlights Exposure value.
  8183. * 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.
  8184. */
  8185. set highlightsExposure(value: number);
  8186. private _midtonesHue;
  8187. private _midtonesDensity;
  8188. private _midtonesSaturation;
  8189. private _midtonesExposure;
  8190. /**
  8191. * Gets the midtones Hue value.
  8192. * 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).
  8193. */
  8194. get midtonesHue(): number;
  8195. /**
  8196. * Sets the midtones Hue value.
  8197. * 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).
  8198. */
  8199. set midtonesHue(value: number);
  8200. /**
  8201. * Gets the midtones Density value.
  8202. * 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.
  8203. * Values less than zero provide a filter of opposite hue.
  8204. */
  8205. get midtonesDensity(): number;
  8206. /**
  8207. * Sets the midtones Density value.
  8208. * 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.
  8209. * Values less than zero provide a filter of opposite hue.
  8210. */
  8211. set midtonesDensity(value: number);
  8212. /**
  8213. * Gets the midtones Saturation value.
  8214. * 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.
  8215. */
  8216. get midtonesSaturation(): number;
  8217. /**
  8218. * Sets the midtones Saturation value.
  8219. * 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.
  8220. */
  8221. set midtonesSaturation(value: number);
  8222. /**
  8223. * Gets the midtones Exposure value.
  8224. * 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.
  8225. */
  8226. get midtonesExposure(): number;
  8227. /**
  8228. * Sets the midtones Exposure value.
  8229. * 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.
  8230. */
  8231. set midtonesExposure(value: number);
  8232. private _shadowsHue;
  8233. private _shadowsDensity;
  8234. private _shadowsSaturation;
  8235. private _shadowsExposure;
  8236. /**
  8237. * Gets the shadows Hue value.
  8238. * 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).
  8239. */
  8240. get shadowsHue(): number;
  8241. /**
  8242. * Sets the shadows Hue value.
  8243. * 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).
  8244. */
  8245. set shadowsHue(value: number);
  8246. /**
  8247. * Gets the shadows Density value.
  8248. * 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.
  8249. * Values less than zero provide a filter of opposite hue.
  8250. */
  8251. get shadowsDensity(): number;
  8252. /**
  8253. * Sets the shadows Density value.
  8254. * 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.
  8255. * Values less than zero provide a filter of opposite hue.
  8256. */
  8257. set shadowsDensity(value: number);
  8258. /**
  8259. * Gets the shadows Saturation value.
  8260. * 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.
  8261. */
  8262. get shadowsSaturation(): number;
  8263. /**
  8264. * Sets the shadows Saturation value.
  8265. * 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.
  8266. */
  8267. set shadowsSaturation(value: number);
  8268. /**
  8269. * Gets the shadows Exposure value.
  8270. * 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.
  8271. */
  8272. get shadowsExposure(): number;
  8273. /**
  8274. * Sets the shadows Exposure value.
  8275. * 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.
  8276. */
  8277. set shadowsExposure(value: number);
  8278. /**
  8279. * Returns the class name
  8280. * @returns The class name
  8281. */
  8282. getClassName(): string;
  8283. /**
  8284. * Binds the color curves to the shader.
  8285. * @param colorCurves The color curve to bind
  8286. * @param effect The effect to bind to
  8287. * @param positiveUniform The positive uniform shader parameter
  8288. * @param neutralUniform The neutral uniform shader parameter
  8289. * @param negativeUniform The negative uniform shader parameter
  8290. */
  8291. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8292. /**
  8293. * Prepare the list of uniforms associated with the ColorCurves effects.
  8294. * @param uniformsList The list of uniforms used in the effect
  8295. */
  8296. static PrepareUniforms(uniformsList: string[]): void;
  8297. /**
  8298. * Returns color grading data based on a hue, density, saturation and exposure value.
  8299. * @param filterHue The hue of the color filter.
  8300. * @param filterDensity The density of the color filter.
  8301. * @param saturation The saturation.
  8302. * @param exposure The exposure.
  8303. * @param result The result data container.
  8304. */
  8305. private getColorGradingDataToRef;
  8306. /**
  8307. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8308. * @param value The input slider value in range [-100,100].
  8309. * @returns Adjusted value.
  8310. */
  8311. private static applyColorGradingSliderNonlinear;
  8312. /**
  8313. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8314. * @param hue The hue (H) input.
  8315. * @param saturation The saturation (S) input.
  8316. * @param brightness The brightness (B) input.
  8317. * @result An RGBA color represented as Vector4.
  8318. */
  8319. private static fromHSBToRef;
  8320. /**
  8321. * Returns a value clamped between min and max
  8322. * @param value The value to clamp
  8323. * @param min The minimum of value
  8324. * @param max The maximum of value
  8325. * @returns The clamped value.
  8326. */
  8327. private static clamp;
  8328. /**
  8329. * Clones the current color curve instance.
  8330. * @return The cloned curves
  8331. */
  8332. clone(): ColorCurves;
  8333. /**
  8334. * Serializes the current color curve instance to a json representation.
  8335. * @return a JSON representation
  8336. */
  8337. serialize(): any;
  8338. /**
  8339. * Parses the color curve from a json representation.
  8340. * @param source the JSON source to parse
  8341. * @return The parsed curves
  8342. */
  8343. static Parse(source: any): ColorCurves;
  8344. }
  8345. }
  8346. declare module BABYLON {
  8347. /**
  8348. * Interface to follow in your material defines to integrate easily the
  8349. * Image proccessing functions.
  8350. * @hidden
  8351. */
  8352. export interface IImageProcessingConfigurationDefines {
  8353. IMAGEPROCESSING: boolean;
  8354. VIGNETTE: boolean;
  8355. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8356. VIGNETTEBLENDMODEOPAQUE: boolean;
  8357. TONEMAPPING: boolean;
  8358. TONEMAPPING_ACES: boolean;
  8359. CONTRAST: boolean;
  8360. EXPOSURE: boolean;
  8361. COLORCURVES: boolean;
  8362. COLORGRADING: boolean;
  8363. COLORGRADING3D: boolean;
  8364. SAMPLER3DGREENDEPTH: boolean;
  8365. SAMPLER3DBGRMAP: boolean;
  8366. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8367. }
  8368. /**
  8369. * @hidden
  8370. */
  8371. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8372. IMAGEPROCESSING: boolean;
  8373. VIGNETTE: boolean;
  8374. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8375. VIGNETTEBLENDMODEOPAQUE: boolean;
  8376. TONEMAPPING: boolean;
  8377. TONEMAPPING_ACES: boolean;
  8378. CONTRAST: boolean;
  8379. COLORCURVES: boolean;
  8380. COLORGRADING: boolean;
  8381. COLORGRADING3D: boolean;
  8382. SAMPLER3DGREENDEPTH: boolean;
  8383. SAMPLER3DBGRMAP: boolean;
  8384. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8385. EXPOSURE: boolean;
  8386. constructor();
  8387. }
  8388. /**
  8389. * This groups together the common properties used for image processing either in direct forward pass
  8390. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8391. * or not.
  8392. */
  8393. export class ImageProcessingConfiguration {
  8394. /**
  8395. * Default tone mapping applied in BabylonJS.
  8396. */
  8397. static readonly TONEMAPPING_STANDARD: number;
  8398. /**
  8399. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8400. * to other engines rendering to increase portability.
  8401. */
  8402. static readonly TONEMAPPING_ACES: number;
  8403. /**
  8404. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8405. */
  8406. colorCurves: Nullable<ColorCurves>;
  8407. private _colorCurvesEnabled;
  8408. /**
  8409. * Gets wether the color curves effect is enabled.
  8410. */
  8411. get colorCurvesEnabled(): boolean;
  8412. /**
  8413. * Sets wether the color curves effect is enabled.
  8414. */
  8415. set colorCurvesEnabled(value: boolean);
  8416. private _colorGradingTexture;
  8417. /**
  8418. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8419. */
  8420. get colorGradingTexture(): Nullable<BaseTexture>;
  8421. /**
  8422. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8423. */
  8424. set colorGradingTexture(value: Nullable<BaseTexture>);
  8425. private _colorGradingEnabled;
  8426. /**
  8427. * Gets wether the color grading effect is enabled.
  8428. */
  8429. get colorGradingEnabled(): boolean;
  8430. /**
  8431. * Sets wether the color grading effect is enabled.
  8432. */
  8433. set colorGradingEnabled(value: boolean);
  8434. private _colorGradingWithGreenDepth;
  8435. /**
  8436. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8437. */
  8438. get colorGradingWithGreenDepth(): boolean;
  8439. /**
  8440. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8441. */
  8442. set colorGradingWithGreenDepth(value: boolean);
  8443. private _colorGradingBGR;
  8444. /**
  8445. * Gets wether the color grading texture contains BGR values.
  8446. */
  8447. get colorGradingBGR(): boolean;
  8448. /**
  8449. * Sets wether the color grading texture contains BGR values.
  8450. */
  8451. set colorGradingBGR(value: boolean);
  8452. /** @hidden */
  8453. _exposure: number;
  8454. /**
  8455. * Gets the Exposure used in the effect.
  8456. */
  8457. get exposure(): number;
  8458. /**
  8459. * Sets the Exposure used in the effect.
  8460. */
  8461. set exposure(value: number);
  8462. private _toneMappingEnabled;
  8463. /**
  8464. * Gets wether the tone mapping effect is enabled.
  8465. */
  8466. get toneMappingEnabled(): boolean;
  8467. /**
  8468. * Sets wether the tone mapping effect is enabled.
  8469. */
  8470. set toneMappingEnabled(value: boolean);
  8471. private _toneMappingType;
  8472. /**
  8473. * Gets the type of tone mapping effect.
  8474. */
  8475. get toneMappingType(): number;
  8476. /**
  8477. * Sets the type of tone mapping effect used in BabylonJS.
  8478. */
  8479. set toneMappingType(value: number);
  8480. protected _contrast: number;
  8481. /**
  8482. * Gets the contrast used in the effect.
  8483. */
  8484. get contrast(): number;
  8485. /**
  8486. * Sets the contrast used in the effect.
  8487. */
  8488. set contrast(value: number);
  8489. /**
  8490. * Vignette stretch size.
  8491. */
  8492. vignetteStretch: number;
  8493. /**
  8494. * Vignette centre X Offset.
  8495. */
  8496. vignetteCentreX: number;
  8497. /**
  8498. * Vignette centre Y Offset.
  8499. */
  8500. vignetteCentreY: number;
  8501. /**
  8502. * Vignette weight or intensity of the vignette effect.
  8503. */
  8504. vignetteWeight: number;
  8505. /**
  8506. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8507. * if vignetteEnabled is set to true.
  8508. */
  8509. vignetteColor: Color4;
  8510. /**
  8511. * Camera field of view used by the Vignette effect.
  8512. */
  8513. vignetteCameraFov: number;
  8514. private _vignetteBlendMode;
  8515. /**
  8516. * Gets the vignette blend mode allowing different kind of effect.
  8517. */
  8518. get vignetteBlendMode(): number;
  8519. /**
  8520. * Sets the vignette blend mode allowing different kind of effect.
  8521. */
  8522. set vignetteBlendMode(value: number);
  8523. private _vignetteEnabled;
  8524. /**
  8525. * Gets wether the vignette effect is enabled.
  8526. */
  8527. get vignetteEnabled(): boolean;
  8528. /**
  8529. * Sets wether the vignette effect is enabled.
  8530. */
  8531. set vignetteEnabled(value: boolean);
  8532. private _applyByPostProcess;
  8533. /**
  8534. * Gets wether the image processing is applied through a post process or not.
  8535. */
  8536. get applyByPostProcess(): boolean;
  8537. /**
  8538. * Sets wether the image processing is applied through a post process or not.
  8539. */
  8540. set applyByPostProcess(value: boolean);
  8541. private _isEnabled;
  8542. /**
  8543. * Gets wether the image processing is enabled or not.
  8544. */
  8545. get isEnabled(): boolean;
  8546. /**
  8547. * Sets wether the image processing is enabled or not.
  8548. */
  8549. set isEnabled(value: boolean);
  8550. /**
  8551. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8552. */
  8553. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8554. /**
  8555. * Method called each time the image processing information changes requires to recompile the effect.
  8556. */
  8557. protected _updateParameters(): void;
  8558. /**
  8559. * Gets the current class name.
  8560. * @return "ImageProcessingConfiguration"
  8561. */
  8562. getClassName(): string;
  8563. /**
  8564. * Prepare the list of uniforms associated with the Image Processing effects.
  8565. * @param uniforms The list of uniforms used in the effect
  8566. * @param defines the list of defines currently in use
  8567. */
  8568. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8569. /**
  8570. * Prepare the list of samplers associated with the Image Processing effects.
  8571. * @param samplersList The list of uniforms used in the effect
  8572. * @param defines the list of defines currently in use
  8573. */
  8574. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8575. /**
  8576. * Prepare the list of defines associated to the shader.
  8577. * @param defines the list of defines to complete
  8578. * @param forPostProcess Define if we are currently in post process mode or not
  8579. */
  8580. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8581. /**
  8582. * Returns true if all the image processing information are ready.
  8583. * @returns True if ready, otherwise, false
  8584. */
  8585. isReady(): boolean;
  8586. /**
  8587. * Binds the image processing to the shader.
  8588. * @param effect The effect to bind to
  8589. * @param overrideAspectRatio Override the aspect ratio of the effect
  8590. */
  8591. bind(effect: Effect, overrideAspectRatio?: number): void;
  8592. /**
  8593. * Clones the current image processing instance.
  8594. * @return The cloned image processing
  8595. */
  8596. clone(): ImageProcessingConfiguration;
  8597. /**
  8598. * Serializes the current image processing instance to a json representation.
  8599. * @return a JSON representation
  8600. */
  8601. serialize(): any;
  8602. /**
  8603. * Parses the image processing from a json representation.
  8604. * @param source the JSON source to parse
  8605. * @return The parsed image processing
  8606. */
  8607. static Parse(source: any): ImageProcessingConfiguration;
  8608. private static _VIGNETTEMODE_MULTIPLY;
  8609. private static _VIGNETTEMODE_OPAQUE;
  8610. /**
  8611. * Used to apply the vignette as a mix with the pixel color.
  8612. */
  8613. static get VIGNETTEMODE_MULTIPLY(): number;
  8614. /**
  8615. * Used to apply the vignette as a replacement of the pixel color.
  8616. */
  8617. static get VIGNETTEMODE_OPAQUE(): number;
  8618. }
  8619. }
  8620. declare module BABYLON {
  8621. /** @hidden */
  8622. export var postprocessVertexShader: {
  8623. name: string;
  8624. shader: string;
  8625. };
  8626. }
  8627. declare module BABYLON {
  8628. /**
  8629. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8630. */
  8631. export type RenderTargetTextureSize = number | {
  8632. width: number;
  8633. height: number;
  8634. layers?: number;
  8635. };
  8636. interface ThinEngine {
  8637. /**
  8638. * Creates a new render target texture
  8639. * @param size defines the size of the texture
  8640. * @param options defines the options used to create the texture
  8641. * @returns a new render target texture stored in an InternalTexture
  8642. */
  8643. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8644. /**
  8645. * Creates a depth stencil texture.
  8646. * This is only available in WebGL 2 or with the depth texture extension available.
  8647. * @param size The size of face edge in the texture.
  8648. * @param options The options defining the texture.
  8649. * @returns The texture
  8650. */
  8651. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8652. /** @hidden */
  8653. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8654. }
  8655. }
  8656. declare module BABYLON {
  8657. /**
  8658. * Defines the kind of connection point for node based material
  8659. */
  8660. export enum NodeMaterialBlockConnectionPointTypes {
  8661. /** Float */
  8662. Float = 1,
  8663. /** Int */
  8664. Int = 2,
  8665. /** Vector2 */
  8666. Vector2 = 4,
  8667. /** Vector3 */
  8668. Vector3 = 8,
  8669. /** Vector4 */
  8670. Vector4 = 16,
  8671. /** Color3 */
  8672. Color3 = 32,
  8673. /** Color4 */
  8674. Color4 = 64,
  8675. /** Matrix */
  8676. Matrix = 128,
  8677. /** Custom object */
  8678. Object = 256,
  8679. /** Detect type based on connection */
  8680. AutoDetect = 1024,
  8681. /** Output type that will be defined by input type */
  8682. BasedOnInput = 2048
  8683. }
  8684. }
  8685. declare module BABYLON {
  8686. /**
  8687. * Enum used to define the target of a block
  8688. */
  8689. export enum NodeMaterialBlockTargets {
  8690. /** Vertex shader */
  8691. Vertex = 1,
  8692. /** Fragment shader */
  8693. Fragment = 2,
  8694. /** Neutral */
  8695. Neutral = 4,
  8696. /** Vertex and Fragment */
  8697. VertexAndFragment = 3
  8698. }
  8699. }
  8700. declare module BABYLON {
  8701. /**
  8702. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8703. */
  8704. export enum NodeMaterialBlockConnectionPointMode {
  8705. /** Value is an uniform */
  8706. Uniform = 0,
  8707. /** Value is a mesh attribute */
  8708. Attribute = 1,
  8709. /** Value is a varying between vertex and fragment shaders */
  8710. Varying = 2,
  8711. /** Mode is undefined */
  8712. Undefined = 3
  8713. }
  8714. }
  8715. declare module BABYLON {
  8716. /**
  8717. * Enum used to define system values e.g. values automatically provided by the system
  8718. */
  8719. export enum NodeMaterialSystemValues {
  8720. /** World */
  8721. World = 1,
  8722. /** View */
  8723. View = 2,
  8724. /** Projection */
  8725. Projection = 3,
  8726. /** ViewProjection */
  8727. ViewProjection = 4,
  8728. /** WorldView */
  8729. WorldView = 5,
  8730. /** WorldViewProjection */
  8731. WorldViewProjection = 6,
  8732. /** CameraPosition */
  8733. CameraPosition = 7,
  8734. /** Fog Color */
  8735. FogColor = 8,
  8736. /** Delta time */
  8737. DeltaTime = 9
  8738. }
  8739. }
  8740. declare module BABYLON {
  8741. /** Defines supported spaces */
  8742. export enum Space {
  8743. /** Local (object) space */
  8744. LOCAL = 0,
  8745. /** World space */
  8746. WORLD = 1,
  8747. /** Bone space */
  8748. BONE = 2
  8749. }
  8750. /** Defines the 3 main axes */
  8751. export class Axis {
  8752. /** X axis */
  8753. static X: Vector3;
  8754. /** Y axis */
  8755. static Y: Vector3;
  8756. /** Z axis */
  8757. static Z: Vector3;
  8758. }
  8759. }
  8760. declare module BABYLON {
  8761. /**
  8762. * Represents a camera frustum
  8763. */
  8764. export class Frustum {
  8765. /**
  8766. * Gets the planes representing the frustum
  8767. * @param transform matrix to be applied to the returned planes
  8768. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8769. */
  8770. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8771. /**
  8772. * Gets the near frustum plane transformed by the transform matrix
  8773. * @param transform transformation matrix to be applied to the resulting frustum plane
  8774. * @param frustumPlane the resuling frustum plane
  8775. */
  8776. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8777. /**
  8778. * Gets the far frustum plane transformed by the transform matrix
  8779. * @param transform transformation matrix to be applied to the resulting frustum plane
  8780. * @param frustumPlane the resuling frustum plane
  8781. */
  8782. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8783. /**
  8784. * Gets the left frustum plane transformed by the transform matrix
  8785. * @param transform transformation matrix to be applied to the resulting frustum plane
  8786. * @param frustumPlane the resuling frustum plane
  8787. */
  8788. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8789. /**
  8790. * Gets the right frustum plane transformed by the transform matrix
  8791. * @param transform transformation matrix to be applied to the resulting frustum plane
  8792. * @param frustumPlane the resuling frustum plane
  8793. */
  8794. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8795. /**
  8796. * Gets the top frustum plane transformed by the transform matrix
  8797. * @param transform transformation matrix to be applied to the resulting frustum plane
  8798. * @param frustumPlane the resuling frustum plane
  8799. */
  8800. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8801. /**
  8802. * Gets the bottom frustum plane transformed by the transform matrix
  8803. * @param transform transformation matrix to be applied to the resulting frustum plane
  8804. * @param frustumPlane the resuling frustum plane
  8805. */
  8806. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8807. /**
  8808. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8809. * @param transform transformation matrix to be applied to the resulting frustum planes
  8810. * @param frustumPlanes the resuling frustum planes
  8811. */
  8812. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8813. }
  8814. }
  8815. declare module BABYLON {
  8816. /**
  8817. * Interface for the size containing width and height
  8818. */
  8819. export interface ISize {
  8820. /**
  8821. * Width
  8822. */
  8823. width: number;
  8824. /**
  8825. * Heighht
  8826. */
  8827. height: number;
  8828. }
  8829. /**
  8830. * Size containing widht and height
  8831. */
  8832. export class Size implements ISize {
  8833. /**
  8834. * Width
  8835. */
  8836. width: number;
  8837. /**
  8838. * Height
  8839. */
  8840. height: number;
  8841. /**
  8842. * Creates a Size object from the given width and height (floats).
  8843. * @param width width of the new size
  8844. * @param height height of the new size
  8845. */
  8846. constructor(width: number, height: number);
  8847. /**
  8848. * Returns a string with the Size width and height
  8849. * @returns a string with the Size width and height
  8850. */
  8851. toString(): string;
  8852. /**
  8853. * "Size"
  8854. * @returns the string "Size"
  8855. */
  8856. getClassName(): string;
  8857. /**
  8858. * Returns the Size hash code.
  8859. * @returns a hash code for a unique width and height
  8860. */
  8861. getHashCode(): number;
  8862. /**
  8863. * Updates the current size from the given one.
  8864. * @param src the given size
  8865. */
  8866. copyFrom(src: Size): void;
  8867. /**
  8868. * Updates in place the current Size from the given floats.
  8869. * @param width width of the new size
  8870. * @param height height of the new size
  8871. * @returns the updated Size.
  8872. */
  8873. copyFromFloats(width: number, height: number): Size;
  8874. /**
  8875. * Updates in place the current Size from the given floats.
  8876. * @param width width to set
  8877. * @param height height to set
  8878. * @returns the updated Size.
  8879. */
  8880. set(width: number, height: number): Size;
  8881. /**
  8882. * Multiplies the width and height by numbers
  8883. * @param w factor to multiple the width by
  8884. * @param h factor to multiple the height by
  8885. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8886. */
  8887. multiplyByFloats(w: number, h: number): Size;
  8888. /**
  8889. * Clones the size
  8890. * @returns a new Size copied from the given one.
  8891. */
  8892. clone(): Size;
  8893. /**
  8894. * True if the current Size and the given one width and height are strictly equal.
  8895. * @param other the other size to compare against
  8896. * @returns True if the current Size and the given one width and height are strictly equal.
  8897. */
  8898. equals(other: Size): boolean;
  8899. /**
  8900. * The surface of the Size : width * height (float).
  8901. */
  8902. get surface(): number;
  8903. /**
  8904. * Create a new size of zero
  8905. * @returns a new Size set to (0.0, 0.0)
  8906. */
  8907. static Zero(): Size;
  8908. /**
  8909. * Sums the width and height of two sizes
  8910. * @param otherSize size to add to this size
  8911. * @returns a new Size set as the addition result of the current Size and the given one.
  8912. */
  8913. add(otherSize: Size): Size;
  8914. /**
  8915. * Subtracts the width and height of two
  8916. * @param otherSize size to subtract to this size
  8917. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8918. */
  8919. subtract(otherSize: Size): Size;
  8920. /**
  8921. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8922. * @param start starting size to lerp between
  8923. * @param end end size to lerp between
  8924. * @param amount amount to lerp between the start and end values
  8925. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8926. */
  8927. static Lerp(start: Size, end: Size, amount: number): Size;
  8928. }
  8929. }
  8930. declare module BABYLON {
  8931. /**
  8932. * Contains position and normal vectors for a vertex
  8933. */
  8934. export class PositionNormalVertex {
  8935. /** the position of the vertex (defaut: 0,0,0) */
  8936. position: Vector3;
  8937. /** the normal of the vertex (defaut: 0,1,0) */
  8938. normal: Vector3;
  8939. /**
  8940. * Creates a PositionNormalVertex
  8941. * @param position the position of the vertex (defaut: 0,0,0)
  8942. * @param normal the normal of the vertex (defaut: 0,1,0)
  8943. */
  8944. constructor(
  8945. /** the position of the vertex (defaut: 0,0,0) */
  8946. position?: Vector3,
  8947. /** the normal of the vertex (defaut: 0,1,0) */
  8948. normal?: Vector3);
  8949. /**
  8950. * Clones the PositionNormalVertex
  8951. * @returns the cloned PositionNormalVertex
  8952. */
  8953. clone(): PositionNormalVertex;
  8954. }
  8955. /**
  8956. * Contains position, normal and uv vectors for a vertex
  8957. */
  8958. export class PositionNormalTextureVertex {
  8959. /** the position of the vertex (defaut: 0,0,0) */
  8960. position: Vector3;
  8961. /** the normal of the vertex (defaut: 0,1,0) */
  8962. normal: Vector3;
  8963. /** the uv of the vertex (default: 0,0) */
  8964. uv: Vector2;
  8965. /**
  8966. * Creates a PositionNormalTextureVertex
  8967. * @param position the position of the vertex (defaut: 0,0,0)
  8968. * @param normal the normal of the vertex (defaut: 0,1,0)
  8969. * @param uv the uv of the vertex (default: 0,0)
  8970. */
  8971. constructor(
  8972. /** the position of the vertex (defaut: 0,0,0) */
  8973. position?: Vector3,
  8974. /** the normal of the vertex (defaut: 0,1,0) */
  8975. normal?: Vector3,
  8976. /** the uv of the vertex (default: 0,0) */
  8977. uv?: Vector2);
  8978. /**
  8979. * Clones the PositionNormalTextureVertex
  8980. * @returns the cloned PositionNormalTextureVertex
  8981. */
  8982. clone(): PositionNormalTextureVertex;
  8983. }
  8984. }
  8985. declare module BABYLON {
  8986. /**
  8987. * Enum defining the type of animations supported by InputBlock
  8988. */
  8989. export enum AnimatedInputBlockTypes {
  8990. /** No animation */
  8991. None = 0,
  8992. /** Time based animation. Will only work for floats */
  8993. Time = 1
  8994. }
  8995. }
  8996. declare module BABYLON {
  8997. /**
  8998. * Interface describing all the common properties and methods a shadow light needs to implement.
  8999. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9000. * as well as binding the different shadow properties to the effects.
  9001. */
  9002. export interface IShadowLight extends Light {
  9003. /**
  9004. * The light id in the scene (used in scene.findLighById for instance)
  9005. */
  9006. id: string;
  9007. /**
  9008. * The position the shdow will be casted from.
  9009. */
  9010. position: Vector3;
  9011. /**
  9012. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9013. */
  9014. direction: Vector3;
  9015. /**
  9016. * The transformed position. Position of the light in world space taking parenting in account.
  9017. */
  9018. transformedPosition: Vector3;
  9019. /**
  9020. * The transformed direction. Direction of the light in world space taking parenting in account.
  9021. */
  9022. transformedDirection: Vector3;
  9023. /**
  9024. * The friendly name of the light in the scene.
  9025. */
  9026. name: string;
  9027. /**
  9028. * Defines the shadow projection clipping minimum z value.
  9029. */
  9030. shadowMinZ: number;
  9031. /**
  9032. * Defines the shadow projection clipping maximum z value.
  9033. */
  9034. shadowMaxZ: number;
  9035. /**
  9036. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9037. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9038. */
  9039. computeTransformedInformation(): boolean;
  9040. /**
  9041. * Gets the scene the light belongs to.
  9042. * @returns The scene
  9043. */
  9044. getScene(): Scene;
  9045. /**
  9046. * Callback defining a custom Projection Matrix Builder.
  9047. * This can be used to override the default projection matrix computation.
  9048. */
  9049. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9050. /**
  9051. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9052. * @param matrix The materix to updated with the projection information
  9053. * @param viewMatrix The transform matrix of the light
  9054. * @param renderList The list of mesh to render in the map
  9055. * @returns The current light
  9056. */
  9057. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9058. /**
  9059. * Gets the current depth scale used in ESM.
  9060. * @returns The scale
  9061. */
  9062. getDepthScale(): number;
  9063. /**
  9064. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9065. * @returns true if a cube texture needs to be use
  9066. */
  9067. needCube(): boolean;
  9068. /**
  9069. * Detects if the projection matrix requires to be recomputed this frame.
  9070. * @returns true if it requires to be recomputed otherwise, false.
  9071. */
  9072. needProjectionMatrixCompute(): boolean;
  9073. /**
  9074. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9075. */
  9076. forceProjectionMatrixCompute(): void;
  9077. /**
  9078. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9079. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9080. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9081. */
  9082. getShadowDirection(faceIndex?: number): Vector3;
  9083. /**
  9084. * Gets the minZ used for shadow according to both the scene and the light.
  9085. * @param activeCamera The camera we are returning the min for
  9086. * @returns the depth min z
  9087. */
  9088. getDepthMinZ(activeCamera: Camera): number;
  9089. /**
  9090. * Gets the maxZ used for shadow according to both the scene and the light.
  9091. * @param activeCamera The camera we are returning the max for
  9092. * @returns the depth max z
  9093. */
  9094. getDepthMaxZ(activeCamera: Camera): number;
  9095. }
  9096. /**
  9097. * Base implementation IShadowLight
  9098. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9099. */
  9100. export abstract class ShadowLight extends Light implements IShadowLight {
  9101. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9102. protected _position: Vector3;
  9103. protected _setPosition(value: Vector3): void;
  9104. /**
  9105. * Sets the position the shadow will be casted from. Also use as the light position for both
  9106. * point and spot lights.
  9107. */
  9108. get position(): Vector3;
  9109. /**
  9110. * Sets the position the shadow will be casted from. Also use as the light position for both
  9111. * point and spot lights.
  9112. */
  9113. set position(value: Vector3);
  9114. protected _direction: Vector3;
  9115. protected _setDirection(value: Vector3): void;
  9116. /**
  9117. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9118. * Also use as the light direction on spot and directional lights.
  9119. */
  9120. get direction(): Vector3;
  9121. /**
  9122. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9123. * Also use as the light direction on spot and directional lights.
  9124. */
  9125. set direction(value: Vector3);
  9126. protected _shadowMinZ: number;
  9127. /**
  9128. * Gets the shadow projection clipping minimum z value.
  9129. */
  9130. get shadowMinZ(): number;
  9131. /**
  9132. * Sets the shadow projection clipping minimum z value.
  9133. */
  9134. set shadowMinZ(value: number);
  9135. protected _shadowMaxZ: number;
  9136. /**
  9137. * Sets the shadow projection clipping maximum z value.
  9138. */
  9139. get shadowMaxZ(): number;
  9140. /**
  9141. * Gets the shadow projection clipping maximum z value.
  9142. */
  9143. set shadowMaxZ(value: number);
  9144. /**
  9145. * Callback defining a custom Projection Matrix Builder.
  9146. * This can be used to override the default projection matrix computation.
  9147. */
  9148. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9149. /**
  9150. * The transformed position. Position of the light in world space taking parenting in account.
  9151. */
  9152. transformedPosition: Vector3;
  9153. /**
  9154. * The transformed direction. Direction of the light in world space taking parenting in account.
  9155. */
  9156. transformedDirection: Vector3;
  9157. private _needProjectionMatrixCompute;
  9158. /**
  9159. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9160. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9161. */
  9162. computeTransformedInformation(): boolean;
  9163. /**
  9164. * Return the depth scale used for the shadow map.
  9165. * @returns the depth scale.
  9166. */
  9167. getDepthScale(): number;
  9168. /**
  9169. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9170. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9171. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9172. */
  9173. getShadowDirection(faceIndex?: number): Vector3;
  9174. /**
  9175. * Returns the ShadowLight absolute position in the World.
  9176. * @returns the position vector in world space
  9177. */
  9178. getAbsolutePosition(): Vector3;
  9179. /**
  9180. * Sets the ShadowLight direction toward the passed target.
  9181. * @param target The point to target in local space
  9182. * @returns the updated ShadowLight direction
  9183. */
  9184. setDirectionToTarget(target: Vector3): Vector3;
  9185. /**
  9186. * Returns the light rotation in euler definition.
  9187. * @returns the x y z rotation in local space.
  9188. */
  9189. getRotation(): Vector3;
  9190. /**
  9191. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9192. * @returns true if a cube texture needs to be use
  9193. */
  9194. needCube(): boolean;
  9195. /**
  9196. * Detects if the projection matrix requires to be recomputed this frame.
  9197. * @returns true if it requires to be recomputed otherwise, false.
  9198. */
  9199. needProjectionMatrixCompute(): boolean;
  9200. /**
  9201. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9202. */
  9203. forceProjectionMatrixCompute(): void;
  9204. /** @hidden */
  9205. _initCache(): void;
  9206. /** @hidden */
  9207. _isSynchronized(): boolean;
  9208. /**
  9209. * Computes the world matrix of the node
  9210. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9211. * @returns the world matrix
  9212. */
  9213. computeWorldMatrix(force?: boolean): Matrix;
  9214. /**
  9215. * Gets the minZ used for shadow according to both the scene and the light.
  9216. * @param activeCamera The camera we are returning the min for
  9217. * @returns the depth min z
  9218. */
  9219. getDepthMinZ(activeCamera: Camera): number;
  9220. /**
  9221. * Gets the maxZ used for shadow according to both the scene and the light.
  9222. * @param activeCamera The camera we are returning the max for
  9223. * @returns the depth max z
  9224. */
  9225. getDepthMaxZ(activeCamera: Camera): number;
  9226. /**
  9227. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9228. * @param matrix The materix to updated with the projection information
  9229. * @param viewMatrix The transform matrix of the light
  9230. * @param renderList The list of mesh to render in the map
  9231. * @returns The current light
  9232. */
  9233. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9234. }
  9235. }
  9236. declare module BABYLON {
  9237. /** @hidden */
  9238. export var packingFunctions: {
  9239. name: string;
  9240. shader: string;
  9241. };
  9242. }
  9243. declare module BABYLON {
  9244. /** @hidden */
  9245. export var bayerDitherFunctions: {
  9246. name: string;
  9247. shader: string;
  9248. };
  9249. }
  9250. declare module BABYLON {
  9251. /** @hidden */
  9252. export var shadowMapFragmentDeclaration: {
  9253. name: string;
  9254. shader: string;
  9255. };
  9256. }
  9257. declare module BABYLON {
  9258. /** @hidden */
  9259. export var clipPlaneFragmentDeclaration: {
  9260. name: string;
  9261. shader: string;
  9262. };
  9263. }
  9264. declare module BABYLON {
  9265. /** @hidden */
  9266. export var clipPlaneFragment: {
  9267. name: string;
  9268. shader: string;
  9269. };
  9270. }
  9271. declare module BABYLON {
  9272. /** @hidden */
  9273. export var shadowMapFragment: {
  9274. name: string;
  9275. shader: string;
  9276. };
  9277. }
  9278. declare module BABYLON {
  9279. /** @hidden */
  9280. export var shadowMapPixelShader: {
  9281. name: string;
  9282. shader: string;
  9283. };
  9284. }
  9285. declare module BABYLON {
  9286. /** @hidden */
  9287. export var bonesDeclaration: {
  9288. name: string;
  9289. shader: string;
  9290. };
  9291. }
  9292. declare module BABYLON {
  9293. /** @hidden */
  9294. export var morphTargetsVertexGlobalDeclaration: {
  9295. name: string;
  9296. shader: string;
  9297. };
  9298. }
  9299. declare module BABYLON {
  9300. /** @hidden */
  9301. export var morphTargetsVertexDeclaration: {
  9302. name: string;
  9303. shader: string;
  9304. };
  9305. }
  9306. declare module BABYLON {
  9307. /** @hidden */
  9308. export var instancesDeclaration: {
  9309. name: string;
  9310. shader: string;
  9311. };
  9312. }
  9313. declare module BABYLON {
  9314. /** @hidden */
  9315. export var helperFunctions: {
  9316. name: string;
  9317. shader: string;
  9318. };
  9319. }
  9320. declare module BABYLON {
  9321. /** @hidden */
  9322. export var shadowMapVertexDeclaration: {
  9323. name: string;
  9324. shader: string;
  9325. };
  9326. }
  9327. declare module BABYLON {
  9328. /** @hidden */
  9329. export var clipPlaneVertexDeclaration: {
  9330. name: string;
  9331. shader: string;
  9332. };
  9333. }
  9334. declare module BABYLON {
  9335. /** @hidden */
  9336. export var morphTargetsVertex: {
  9337. name: string;
  9338. shader: string;
  9339. };
  9340. }
  9341. declare module BABYLON {
  9342. /** @hidden */
  9343. export var instancesVertex: {
  9344. name: string;
  9345. shader: string;
  9346. };
  9347. }
  9348. declare module BABYLON {
  9349. /** @hidden */
  9350. export var bonesVertex: {
  9351. name: string;
  9352. shader: string;
  9353. };
  9354. }
  9355. declare module BABYLON {
  9356. /** @hidden */
  9357. export var shadowMapVertexNormalBias: {
  9358. name: string;
  9359. shader: string;
  9360. };
  9361. }
  9362. declare module BABYLON {
  9363. /** @hidden */
  9364. export var shadowMapVertexMetric: {
  9365. name: string;
  9366. shader: string;
  9367. };
  9368. }
  9369. declare module BABYLON {
  9370. /** @hidden */
  9371. export var clipPlaneVertex: {
  9372. name: string;
  9373. shader: string;
  9374. };
  9375. }
  9376. declare module BABYLON {
  9377. /** @hidden */
  9378. export var shadowMapVertexShader: {
  9379. name: string;
  9380. shader: string;
  9381. };
  9382. }
  9383. declare module BABYLON {
  9384. /** @hidden */
  9385. export var depthBoxBlurPixelShader: {
  9386. name: string;
  9387. shader: string;
  9388. };
  9389. }
  9390. declare module BABYLON {
  9391. /** @hidden */
  9392. export var shadowMapFragmentSoftTransparentShadow: {
  9393. name: string;
  9394. shader: string;
  9395. };
  9396. }
  9397. declare module BABYLON {
  9398. /**
  9399. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9400. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9401. */
  9402. export class EffectFallbacks implements IEffectFallbacks {
  9403. private _defines;
  9404. private _currentRank;
  9405. private _maxRank;
  9406. private _mesh;
  9407. /**
  9408. * Removes the fallback from the bound mesh.
  9409. */
  9410. unBindMesh(): void;
  9411. /**
  9412. * Adds a fallback on the specified property.
  9413. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9414. * @param define The name of the define in the shader
  9415. */
  9416. addFallback(rank: number, define: string): void;
  9417. /**
  9418. * Sets the mesh to use CPU skinning when needing to fallback.
  9419. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9420. * @param mesh The mesh to use the fallbacks.
  9421. */
  9422. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9423. /**
  9424. * Checks to see if more fallbacks are still availible.
  9425. */
  9426. get hasMoreFallbacks(): boolean;
  9427. /**
  9428. * Removes the defines that should be removed when falling back.
  9429. * @param currentDefines defines the current define statements for the shader.
  9430. * @param effect defines the current effect we try to compile
  9431. * @returns The resulting defines with defines of the current rank removed.
  9432. */
  9433. reduce(currentDefines: string, effect: Effect): string;
  9434. }
  9435. }
  9436. declare module BABYLON {
  9437. /**
  9438. * Interface used to define Action
  9439. */
  9440. export interface IAction {
  9441. /**
  9442. * Trigger for the action
  9443. */
  9444. trigger: number;
  9445. /** Options of the trigger */
  9446. triggerOptions: any;
  9447. /**
  9448. * Gets the trigger parameters
  9449. * @returns the trigger parameters
  9450. */
  9451. getTriggerParameter(): any;
  9452. /**
  9453. * Internal only - executes current action event
  9454. * @hidden
  9455. */
  9456. _executeCurrent(evt?: ActionEvent): void;
  9457. /**
  9458. * Serialize placeholder for child classes
  9459. * @param parent of child
  9460. * @returns the serialized object
  9461. */
  9462. serialize(parent: any): any;
  9463. /**
  9464. * Internal only
  9465. * @hidden
  9466. */
  9467. _prepare(): void;
  9468. /**
  9469. * Internal only - manager for action
  9470. * @hidden
  9471. */
  9472. _actionManager: Nullable<AbstractActionManager>;
  9473. /**
  9474. * Adds action to chain of actions, may be a DoNothingAction
  9475. * @param action defines the next action to execute
  9476. * @returns The action passed in
  9477. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9478. */
  9479. then(action: IAction): IAction;
  9480. }
  9481. /**
  9482. * The action to be carried out following a trigger
  9483. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9484. */
  9485. export class Action implements IAction {
  9486. /** the trigger, with or without parameters, for the action */
  9487. triggerOptions: any;
  9488. /**
  9489. * Trigger for the action
  9490. */
  9491. trigger: number;
  9492. /**
  9493. * Internal only - manager for action
  9494. * @hidden
  9495. */
  9496. _actionManager: ActionManager;
  9497. private _nextActiveAction;
  9498. private _child;
  9499. private _condition?;
  9500. private _triggerParameter;
  9501. /**
  9502. * An event triggered prior to action being executed.
  9503. */
  9504. onBeforeExecuteObservable: Observable<Action>;
  9505. /**
  9506. * Creates a new Action
  9507. * @param triggerOptions the trigger, with or without parameters, for the action
  9508. * @param condition an optional determinant of action
  9509. */
  9510. constructor(
  9511. /** the trigger, with or without parameters, for the action */
  9512. triggerOptions: any, condition?: Condition);
  9513. /**
  9514. * Internal only
  9515. * @hidden
  9516. */
  9517. _prepare(): void;
  9518. /**
  9519. * Gets the trigger parameters
  9520. * @returns the trigger parameters
  9521. */
  9522. getTriggerParameter(): any;
  9523. /**
  9524. * Internal only - executes current action event
  9525. * @hidden
  9526. */
  9527. _executeCurrent(evt?: ActionEvent): void;
  9528. /**
  9529. * Execute placeholder for child classes
  9530. * @param evt optional action event
  9531. */
  9532. execute(evt?: ActionEvent): void;
  9533. /**
  9534. * Skips to next active action
  9535. */
  9536. skipToNextActiveAction(): void;
  9537. /**
  9538. * Adds action to chain of actions, may be a DoNothingAction
  9539. * @param action defines the next action to execute
  9540. * @returns The action passed in
  9541. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9542. */
  9543. then(action: Action): Action;
  9544. /**
  9545. * Internal only
  9546. * @hidden
  9547. */
  9548. _getProperty(propertyPath: string): string;
  9549. /**
  9550. * Internal only
  9551. * @hidden
  9552. */
  9553. _getEffectiveTarget(target: any, propertyPath: string): any;
  9554. /**
  9555. * Serialize placeholder for child classes
  9556. * @param parent of child
  9557. * @returns the serialized object
  9558. */
  9559. serialize(parent: any): any;
  9560. /**
  9561. * Internal only called by serialize
  9562. * @hidden
  9563. */
  9564. protected _serialize(serializedAction: any, parent?: any): any;
  9565. /**
  9566. * Internal only
  9567. * @hidden
  9568. */
  9569. static _SerializeValueAsString: (value: any) => string;
  9570. /**
  9571. * Internal only
  9572. * @hidden
  9573. */
  9574. static _GetTargetProperty: (target: Scene | Node) => {
  9575. name: string;
  9576. targetType: string;
  9577. value: string;
  9578. };
  9579. }
  9580. }
  9581. declare module BABYLON {
  9582. /**
  9583. * A Condition applied to an Action
  9584. */
  9585. export class Condition {
  9586. /**
  9587. * Internal only - manager for action
  9588. * @hidden
  9589. */
  9590. _actionManager: ActionManager;
  9591. /**
  9592. * Internal only
  9593. * @hidden
  9594. */
  9595. _evaluationId: number;
  9596. /**
  9597. * Internal only
  9598. * @hidden
  9599. */
  9600. _currentResult: boolean;
  9601. /**
  9602. * Creates a new Condition
  9603. * @param actionManager the manager of the action the condition is applied to
  9604. */
  9605. constructor(actionManager: ActionManager);
  9606. /**
  9607. * Check if the current condition is valid
  9608. * @returns a boolean
  9609. */
  9610. isValid(): boolean;
  9611. /**
  9612. * Internal only
  9613. * @hidden
  9614. */
  9615. _getProperty(propertyPath: string): string;
  9616. /**
  9617. * Internal only
  9618. * @hidden
  9619. */
  9620. _getEffectiveTarget(target: any, propertyPath: string): any;
  9621. /**
  9622. * Serialize placeholder for child classes
  9623. * @returns the serialized object
  9624. */
  9625. serialize(): any;
  9626. /**
  9627. * Internal only
  9628. * @hidden
  9629. */
  9630. protected _serialize(serializedCondition: any): any;
  9631. }
  9632. /**
  9633. * Defines specific conditional operators as extensions of Condition
  9634. */
  9635. export class ValueCondition extends Condition {
  9636. /** path to specify the property of the target the conditional operator uses */
  9637. propertyPath: string;
  9638. /** the value compared by the conditional operator against the current value of the property */
  9639. value: any;
  9640. /** the conditional operator, default ValueCondition.IsEqual */
  9641. operator: number;
  9642. /**
  9643. * Internal only
  9644. * @hidden
  9645. */
  9646. private static _IsEqual;
  9647. /**
  9648. * Internal only
  9649. * @hidden
  9650. */
  9651. private static _IsDifferent;
  9652. /**
  9653. * Internal only
  9654. * @hidden
  9655. */
  9656. private static _IsGreater;
  9657. /**
  9658. * Internal only
  9659. * @hidden
  9660. */
  9661. private static _IsLesser;
  9662. /**
  9663. * returns the number for IsEqual
  9664. */
  9665. static get IsEqual(): number;
  9666. /**
  9667. * Returns the number for IsDifferent
  9668. */
  9669. static get IsDifferent(): number;
  9670. /**
  9671. * Returns the number for IsGreater
  9672. */
  9673. static get IsGreater(): number;
  9674. /**
  9675. * Returns the number for IsLesser
  9676. */
  9677. static get IsLesser(): number;
  9678. /**
  9679. * Internal only The action manager for the condition
  9680. * @hidden
  9681. */
  9682. _actionManager: ActionManager;
  9683. /**
  9684. * Internal only
  9685. * @hidden
  9686. */
  9687. private _target;
  9688. /**
  9689. * Internal only
  9690. * @hidden
  9691. */
  9692. private _effectiveTarget;
  9693. /**
  9694. * Internal only
  9695. * @hidden
  9696. */
  9697. private _property;
  9698. /**
  9699. * Creates a new ValueCondition
  9700. * @param actionManager manager for the action the condition applies to
  9701. * @param target for the action
  9702. * @param propertyPath path to specify the property of the target the conditional operator uses
  9703. * @param value the value compared by the conditional operator against the current value of the property
  9704. * @param operator the conditional operator, default ValueCondition.IsEqual
  9705. */
  9706. constructor(actionManager: ActionManager, target: any,
  9707. /** path to specify the property of the target the conditional operator uses */
  9708. propertyPath: string,
  9709. /** the value compared by the conditional operator against the current value of the property */
  9710. value: any,
  9711. /** the conditional operator, default ValueCondition.IsEqual */
  9712. operator?: number);
  9713. /**
  9714. * Compares the given value with the property value for the specified conditional operator
  9715. * @returns the result of the comparison
  9716. */
  9717. isValid(): boolean;
  9718. /**
  9719. * Serialize the ValueCondition into a JSON compatible object
  9720. * @returns serialization object
  9721. */
  9722. serialize(): any;
  9723. /**
  9724. * Gets the name of the conditional operator for the ValueCondition
  9725. * @param operator the conditional operator
  9726. * @returns the name
  9727. */
  9728. static GetOperatorName(operator: number): string;
  9729. }
  9730. /**
  9731. * Defines a predicate condition as an extension of Condition
  9732. */
  9733. export class PredicateCondition extends Condition {
  9734. /** defines the predicate function used to validate the condition */
  9735. predicate: () => boolean;
  9736. /**
  9737. * Internal only - manager for action
  9738. * @hidden
  9739. */
  9740. _actionManager: ActionManager;
  9741. /**
  9742. * Creates a new PredicateCondition
  9743. * @param actionManager manager for the action the condition applies to
  9744. * @param predicate defines the predicate function used to validate the condition
  9745. */
  9746. constructor(actionManager: ActionManager,
  9747. /** defines the predicate function used to validate the condition */
  9748. predicate: () => boolean);
  9749. /**
  9750. * @returns the validity of the predicate condition
  9751. */
  9752. isValid(): boolean;
  9753. }
  9754. /**
  9755. * Defines a state condition as an extension of Condition
  9756. */
  9757. export class StateCondition extends Condition {
  9758. /** Value to compare with target state */
  9759. value: string;
  9760. /**
  9761. * Internal only - manager for action
  9762. * @hidden
  9763. */
  9764. _actionManager: ActionManager;
  9765. /**
  9766. * Internal only
  9767. * @hidden
  9768. */
  9769. private _target;
  9770. /**
  9771. * Creates a new StateCondition
  9772. * @param actionManager manager for the action the condition applies to
  9773. * @param target of the condition
  9774. * @param value to compare with target state
  9775. */
  9776. constructor(actionManager: ActionManager, target: any,
  9777. /** Value to compare with target state */
  9778. value: string);
  9779. /**
  9780. * Gets a boolean indicating if the current condition is met
  9781. * @returns the validity of the state
  9782. */
  9783. isValid(): boolean;
  9784. /**
  9785. * Serialize the StateCondition into a JSON compatible object
  9786. * @returns serialization object
  9787. */
  9788. serialize(): any;
  9789. }
  9790. }
  9791. declare module BABYLON {
  9792. /**
  9793. * This defines an action responsible to toggle a boolean once triggered.
  9794. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9795. */
  9796. export class SwitchBooleanAction extends Action {
  9797. /**
  9798. * The path to the boolean property in the target object
  9799. */
  9800. propertyPath: string;
  9801. private _target;
  9802. private _effectiveTarget;
  9803. private _property;
  9804. /**
  9805. * Instantiate the action
  9806. * @param triggerOptions defines the trigger options
  9807. * @param target defines the object containing the boolean
  9808. * @param propertyPath defines the path to the boolean property in the target object
  9809. * @param condition defines the trigger related conditions
  9810. */
  9811. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9812. /** @hidden */
  9813. _prepare(): void;
  9814. /**
  9815. * Execute the action toggle the boolean value.
  9816. */
  9817. execute(): void;
  9818. /**
  9819. * Serializes the actions and its related information.
  9820. * @param parent defines the object to serialize in
  9821. * @returns the serialized object
  9822. */
  9823. serialize(parent: any): any;
  9824. }
  9825. /**
  9826. * This defines an action responsible to set a the state field of the target
  9827. * to a desired value once triggered.
  9828. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9829. */
  9830. export class SetStateAction extends Action {
  9831. /**
  9832. * The value to store in the state field.
  9833. */
  9834. value: string;
  9835. private _target;
  9836. /**
  9837. * Instantiate the action
  9838. * @param triggerOptions defines the trigger options
  9839. * @param target defines the object containing the state property
  9840. * @param value defines the value to store in the state field
  9841. * @param condition defines the trigger related conditions
  9842. */
  9843. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9844. /**
  9845. * Execute the action and store the value on the target state property.
  9846. */
  9847. execute(): void;
  9848. /**
  9849. * Serializes the actions and its related information.
  9850. * @param parent defines the object to serialize in
  9851. * @returns the serialized object
  9852. */
  9853. serialize(parent: any): any;
  9854. }
  9855. /**
  9856. * This defines an action responsible to set a property of the target
  9857. * to a desired value once triggered.
  9858. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9859. */
  9860. export class SetValueAction extends Action {
  9861. /**
  9862. * The path of the property to set in the target.
  9863. */
  9864. propertyPath: string;
  9865. /**
  9866. * The value to set in the property
  9867. */
  9868. value: any;
  9869. private _target;
  9870. private _effectiveTarget;
  9871. private _property;
  9872. /**
  9873. * Instantiate the action
  9874. * @param triggerOptions defines the trigger options
  9875. * @param target defines the object containing the property
  9876. * @param propertyPath defines the path of the property to set in the target
  9877. * @param value defines the value to set in the property
  9878. * @param condition defines the trigger related conditions
  9879. */
  9880. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9881. /** @hidden */
  9882. _prepare(): void;
  9883. /**
  9884. * Execute the action and set the targetted property to the desired value.
  9885. */
  9886. execute(): void;
  9887. /**
  9888. * Serializes the actions and its related information.
  9889. * @param parent defines the object to serialize in
  9890. * @returns the serialized object
  9891. */
  9892. serialize(parent: any): any;
  9893. }
  9894. /**
  9895. * This defines an action responsible to increment the target value
  9896. * to a desired value once triggered.
  9897. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9898. */
  9899. export class IncrementValueAction extends Action {
  9900. /**
  9901. * The path of the property to increment in the target.
  9902. */
  9903. propertyPath: string;
  9904. /**
  9905. * The value we should increment the property by.
  9906. */
  9907. value: any;
  9908. private _target;
  9909. private _effectiveTarget;
  9910. private _property;
  9911. /**
  9912. * Instantiate the action
  9913. * @param triggerOptions defines the trigger options
  9914. * @param target defines the object containing the property
  9915. * @param propertyPath defines the path of the property to increment in the target
  9916. * @param value defines the value value we should increment the property by
  9917. * @param condition defines the trigger related conditions
  9918. */
  9919. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9920. /** @hidden */
  9921. _prepare(): void;
  9922. /**
  9923. * Execute the action and increment the target of the value amount.
  9924. */
  9925. execute(): void;
  9926. /**
  9927. * Serializes the actions and its related information.
  9928. * @param parent defines the object to serialize in
  9929. * @returns the serialized object
  9930. */
  9931. serialize(parent: any): any;
  9932. }
  9933. /**
  9934. * This defines an action responsible to start an animation once triggered.
  9935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9936. */
  9937. export class PlayAnimationAction extends Action {
  9938. /**
  9939. * Where the animation should start (animation frame)
  9940. */
  9941. from: number;
  9942. /**
  9943. * Where the animation should stop (animation frame)
  9944. */
  9945. to: number;
  9946. /**
  9947. * Define if the animation should loop or stop after the first play.
  9948. */
  9949. loop?: boolean;
  9950. private _target;
  9951. /**
  9952. * Instantiate the action
  9953. * @param triggerOptions defines the trigger options
  9954. * @param target defines the target animation or animation name
  9955. * @param from defines from where the animation should start (animation frame)
  9956. * @param end defines where the animation should stop (animation frame)
  9957. * @param loop defines if the animation should loop or stop after the first play
  9958. * @param condition defines the trigger related conditions
  9959. */
  9960. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9961. /** @hidden */
  9962. _prepare(): void;
  9963. /**
  9964. * Execute the action and play the animation.
  9965. */
  9966. execute(): void;
  9967. /**
  9968. * Serializes the actions and its related information.
  9969. * @param parent defines the object to serialize in
  9970. * @returns the serialized object
  9971. */
  9972. serialize(parent: any): any;
  9973. }
  9974. /**
  9975. * This defines an action responsible to stop an animation once triggered.
  9976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9977. */
  9978. export class StopAnimationAction extends Action {
  9979. private _target;
  9980. /**
  9981. * Instantiate the action
  9982. * @param triggerOptions defines the trigger options
  9983. * @param target defines the target animation or animation name
  9984. * @param condition defines the trigger related conditions
  9985. */
  9986. constructor(triggerOptions: any, target: any, condition?: Condition);
  9987. /** @hidden */
  9988. _prepare(): void;
  9989. /**
  9990. * Execute the action and stop the animation.
  9991. */
  9992. execute(): void;
  9993. /**
  9994. * Serializes the actions and its related information.
  9995. * @param parent defines the object to serialize in
  9996. * @returns the serialized object
  9997. */
  9998. serialize(parent: any): any;
  9999. }
  10000. /**
  10001. * This defines an action responsible that does nothing once triggered.
  10002. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10003. */
  10004. export class DoNothingAction extends Action {
  10005. /**
  10006. * Instantiate the action
  10007. * @param triggerOptions defines the trigger options
  10008. * @param condition defines the trigger related conditions
  10009. */
  10010. constructor(triggerOptions?: any, condition?: Condition);
  10011. /**
  10012. * Execute the action and do nothing.
  10013. */
  10014. execute(): void;
  10015. /**
  10016. * Serializes the actions and its related information.
  10017. * @param parent defines the object to serialize in
  10018. * @returns the serialized object
  10019. */
  10020. serialize(parent: any): any;
  10021. }
  10022. /**
  10023. * This defines an action responsible to trigger several actions once triggered.
  10024. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10025. */
  10026. export class CombineAction extends Action {
  10027. /**
  10028. * The list of aggregated animations to run.
  10029. */
  10030. children: Action[];
  10031. /**
  10032. * Instantiate the action
  10033. * @param triggerOptions defines the trigger options
  10034. * @param children defines the list of aggregated animations to run
  10035. * @param condition defines the trigger related conditions
  10036. */
  10037. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10038. /** @hidden */
  10039. _prepare(): void;
  10040. /**
  10041. * Execute the action and executes all the aggregated actions.
  10042. */
  10043. execute(evt: ActionEvent): void;
  10044. /**
  10045. * Serializes the actions and its related information.
  10046. * @param parent defines the object to serialize in
  10047. * @returns the serialized object
  10048. */
  10049. serialize(parent: any): any;
  10050. }
  10051. /**
  10052. * This defines an action responsible to run code (external event) once triggered.
  10053. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10054. */
  10055. export class ExecuteCodeAction extends Action {
  10056. /**
  10057. * The callback function to run.
  10058. */
  10059. func: (evt: ActionEvent) => void;
  10060. /**
  10061. * Instantiate the action
  10062. * @param triggerOptions defines the trigger options
  10063. * @param func defines the callback function to run
  10064. * @param condition defines the trigger related conditions
  10065. */
  10066. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10067. /**
  10068. * Execute the action and run the attached code.
  10069. */
  10070. execute(evt: ActionEvent): void;
  10071. }
  10072. /**
  10073. * This defines an action responsible to set the parent property of the target once triggered.
  10074. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10075. */
  10076. export class SetParentAction extends Action {
  10077. private _parent;
  10078. private _target;
  10079. /**
  10080. * Instantiate the action
  10081. * @param triggerOptions defines the trigger options
  10082. * @param target defines the target containing the parent property
  10083. * @param parent defines from where the animation should start (animation frame)
  10084. * @param condition defines the trigger related conditions
  10085. */
  10086. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10087. /** @hidden */
  10088. _prepare(): void;
  10089. /**
  10090. * Execute the action and set the parent property.
  10091. */
  10092. execute(): void;
  10093. /**
  10094. * Serializes the actions and its related information.
  10095. * @param parent defines the object to serialize in
  10096. * @returns the serialized object
  10097. */
  10098. serialize(parent: any): any;
  10099. }
  10100. }
  10101. declare module BABYLON {
  10102. /**
  10103. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10104. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10105. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10106. */
  10107. export class ActionManager extends AbstractActionManager {
  10108. /**
  10109. * Nothing
  10110. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10111. */
  10112. static readonly NothingTrigger: number;
  10113. /**
  10114. * On pick
  10115. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10116. */
  10117. static readonly OnPickTrigger: number;
  10118. /**
  10119. * On left pick
  10120. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10121. */
  10122. static readonly OnLeftPickTrigger: number;
  10123. /**
  10124. * On right pick
  10125. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10126. */
  10127. static readonly OnRightPickTrigger: number;
  10128. /**
  10129. * On center pick
  10130. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10131. */
  10132. static readonly OnCenterPickTrigger: number;
  10133. /**
  10134. * On pick down
  10135. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10136. */
  10137. static readonly OnPickDownTrigger: number;
  10138. /**
  10139. * On double pick
  10140. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10141. */
  10142. static readonly OnDoublePickTrigger: number;
  10143. /**
  10144. * On pick up
  10145. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10146. */
  10147. static readonly OnPickUpTrigger: number;
  10148. /**
  10149. * On pick out.
  10150. * This trigger will only be raised if you also declared a OnPickDown
  10151. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10152. */
  10153. static readonly OnPickOutTrigger: number;
  10154. /**
  10155. * On long press
  10156. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10157. */
  10158. static readonly OnLongPressTrigger: number;
  10159. /**
  10160. * On pointer over
  10161. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10162. */
  10163. static readonly OnPointerOverTrigger: number;
  10164. /**
  10165. * On pointer out
  10166. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10167. */
  10168. static readonly OnPointerOutTrigger: number;
  10169. /**
  10170. * On every frame
  10171. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10172. */
  10173. static readonly OnEveryFrameTrigger: number;
  10174. /**
  10175. * On intersection enter
  10176. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10177. */
  10178. static readonly OnIntersectionEnterTrigger: number;
  10179. /**
  10180. * On intersection exit
  10181. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10182. */
  10183. static readonly OnIntersectionExitTrigger: number;
  10184. /**
  10185. * On key down
  10186. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10187. */
  10188. static readonly OnKeyDownTrigger: number;
  10189. /**
  10190. * On key up
  10191. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10192. */
  10193. static readonly OnKeyUpTrigger: number;
  10194. private _scene;
  10195. /**
  10196. * Creates a new action manager
  10197. * @param scene defines the hosting scene
  10198. */
  10199. constructor(scene: Scene);
  10200. /**
  10201. * Releases all associated resources
  10202. */
  10203. dispose(): void;
  10204. /**
  10205. * Gets hosting scene
  10206. * @returns the hosting scene
  10207. */
  10208. getScene(): Scene;
  10209. /**
  10210. * Does this action manager handles actions of any of the given triggers
  10211. * @param triggers defines the triggers to be tested
  10212. * @return a boolean indicating whether one (or more) of the triggers is handled
  10213. */
  10214. hasSpecificTriggers(triggers: number[]): boolean;
  10215. /**
  10216. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10217. * speed.
  10218. * @param triggerA defines the trigger to be tested
  10219. * @param triggerB defines the trigger to be tested
  10220. * @return a boolean indicating whether one (or more) of the triggers is handled
  10221. */
  10222. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10223. /**
  10224. * Does this action manager handles actions of a given trigger
  10225. * @param trigger defines the trigger to be tested
  10226. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10227. * @return whether the trigger is handled
  10228. */
  10229. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10230. /**
  10231. * Does this action manager has pointer triggers
  10232. */
  10233. get hasPointerTriggers(): boolean;
  10234. /**
  10235. * Does this action manager has pick triggers
  10236. */
  10237. get hasPickTriggers(): boolean;
  10238. /**
  10239. * Registers an action to this action manager
  10240. * @param action defines the action to be registered
  10241. * @return the action amended (prepared) after registration
  10242. */
  10243. registerAction(action: IAction): Nullable<IAction>;
  10244. /**
  10245. * Unregisters an action to this action manager
  10246. * @param action defines the action to be unregistered
  10247. * @return a boolean indicating whether the action has been unregistered
  10248. */
  10249. unregisterAction(action: IAction): Boolean;
  10250. /**
  10251. * Process a specific trigger
  10252. * @param trigger defines the trigger to process
  10253. * @param evt defines the event details to be processed
  10254. */
  10255. processTrigger(trigger: number, evt?: IActionEvent): void;
  10256. /** @hidden */
  10257. _getEffectiveTarget(target: any, propertyPath: string): any;
  10258. /** @hidden */
  10259. _getProperty(propertyPath: string): string;
  10260. /**
  10261. * Serialize this manager to a JSON object
  10262. * @param name defines the property name to store this manager
  10263. * @returns a JSON representation of this manager
  10264. */
  10265. serialize(name: string): any;
  10266. /**
  10267. * Creates a new ActionManager from a JSON data
  10268. * @param parsedActions defines the JSON data to read from
  10269. * @param object defines the hosting mesh
  10270. * @param scene defines the hosting scene
  10271. */
  10272. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10273. /**
  10274. * Get a trigger name by index
  10275. * @param trigger defines the trigger index
  10276. * @returns a trigger name
  10277. */
  10278. static GetTriggerName(trigger: number): string;
  10279. }
  10280. }
  10281. declare module BABYLON {
  10282. /**
  10283. * Class used to represent a sprite
  10284. * @see https://doc.babylonjs.com/babylon101/sprites
  10285. */
  10286. export class Sprite implements IAnimatable {
  10287. /** defines the name */
  10288. name: string;
  10289. /** Gets or sets the current world position */
  10290. position: Vector3;
  10291. /** Gets or sets the main color */
  10292. color: Color4;
  10293. /** Gets or sets the width */
  10294. width: number;
  10295. /** Gets or sets the height */
  10296. height: number;
  10297. /** Gets or sets rotation angle */
  10298. angle: number;
  10299. /** Gets or sets the cell index in the sprite sheet */
  10300. cellIndex: number;
  10301. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10302. cellRef: string;
  10303. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10304. invertU: boolean;
  10305. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10306. invertV: boolean;
  10307. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10308. disposeWhenFinishedAnimating: boolean;
  10309. /** Gets the list of attached animations */
  10310. animations: Nullable<Array<Animation>>;
  10311. /** Gets or sets a boolean indicating if the sprite can be picked */
  10312. isPickable: boolean;
  10313. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10314. useAlphaForPicking: boolean;
  10315. /** @hidden */
  10316. _xOffset: number;
  10317. /** @hidden */
  10318. _yOffset: number;
  10319. /** @hidden */
  10320. _xSize: number;
  10321. /** @hidden */
  10322. _ySize: number;
  10323. /**
  10324. * Gets or sets the associated action manager
  10325. */
  10326. actionManager: Nullable<ActionManager>;
  10327. /**
  10328. * An event triggered when the control has been disposed
  10329. */
  10330. onDisposeObservable: Observable<Sprite>;
  10331. private _animationStarted;
  10332. private _loopAnimation;
  10333. private _fromIndex;
  10334. private _toIndex;
  10335. private _delay;
  10336. private _direction;
  10337. private _manager;
  10338. private _time;
  10339. private _onAnimationEnd;
  10340. /**
  10341. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10342. */
  10343. isVisible: boolean;
  10344. /**
  10345. * Gets or sets the sprite size
  10346. */
  10347. get size(): number;
  10348. set size(value: number);
  10349. /**
  10350. * Returns a boolean indicating if the animation is started
  10351. */
  10352. get animationStarted(): boolean;
  10353. /**
  10354. * Gets or sets the unique id of the sprite
  10355. */
  10356. uniqueId: number;
  10357. /**
  10358. * Gets the manager of this sprite
  10359. */
  10360. get manager(): ISpriteManager;
  10361. /**
  10362. * Creates a new Sprite
  10363. * @param name defines the name
  10364. * @param manager defines the manager
  10365. */
  10366. constructor(
  10367. /** defines the name */
  10368. name: string, manager: ISpriteManager);
  10369. /**
  10370. * Returns the string "Sprite"
  10371. * @returns "Sprite"
  10372. */
  10373. getClassName(): string;
  10374. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10375. get fromIndex(): number;
  10376. set fromIndex(value: number);
  10377. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10378. get toIndex(): number;
  10379. set toIndex(value: number);
  10380. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10381. get loopAnimation(): boolean;
  10382. set loopAnimation(value: boolean);
  10383. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10384. get delay(): number;
  10385. set delay(value: number);
  10386. /**
  10387. * Starts an animation
  10388. * @param from defines the initial key
  10389. * @param to defines the end key
  10390. * @param loop defines if the animation must loop
  10391. * @param delay defines the start delay (in ms)
  10392. * @param onAnimationEnd defines a callback to call when animation ends
  10393. */
  10394. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10395. /** Stops current animation (if any) */
  10396. stopAnimation(): void;
  10397. /** @hidden */
  10398. _animate(deltaTime: number): void;
  10399. /** Release associated resources */
  10400. dispose(): void;
  10401. /**
  10402. * Serializes the sprite to a JSON object
  10403. * @returns the JSON object
  10404. */
  10405. serialize(): any;
  10406. /**
  10407. * Parses a JSON object to create a new sprite
  10408. * @param parsedSprite The JSON object to parse
  10409. * @param manager defines the hosting manager
  10410. * @returns the new sprite
  10411. */
  10412. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10413. }
  10414. }
  10415. declare module BABYLON {
  10416. /**
  10417. * Information about the result of picking within a scene
  10418. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10419. */
  10420. export class PickingInfo {
  10421. /** @hidden */
  10422. _pickingUnavailable: boolean;
  10423. /**
  10424. * If the pick collided with an object
  10425. */
  10426. hit: boolean;
  10427. /**
  10428. * Distance away where the pick collided
  10429. */
  10430. distance: number;
  10431. /**
  10432. * The location of pick collision
  10433. */
  10434. pickedPoint: Nullable<Vector3>;
  10435. /**
  10436. * The mesh corresponding the the pick collision
  10437. */
  10438. pickedMesh: Nullable<AbstractMesh>;
  10439. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10440. bu: number;
  10441. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10442. bv: number;
  10443. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10444. faceId: number;
  10445. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10446. subMeshFaceId: number;
  10447. /** Id of the the submesh that was picked */
  10448. subMeshId: number;
  10449. /** If a sprite was picked, this will be the sprite the pick collided with */
  10450. pickedSprite: Nullable<Sprite>;
  10451. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10452. thinInstanceIndex: number;
  10453. /**
  10454. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10455. */
  10456. originMesh: Nullable<AbstractMesh>;
  10457. /**
  10458. * The ray that was used to perform the picking.
  10459. */
  10460. ray: Nullable<Ray>;
  10461. /**
  10462. * Gets the normal correspodning to the face the pick collided with
  10463. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10464. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10465. * @returns The normal correspodning to the face the pick collided with
  10466. */
  10467. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10468. /**
  10469. * Gets the texture coordinates of where the pick occured
  10470. * @returns the vector containing the coordnates of the texture
  10471. */
  10472. getTextureCoordinates(): Nullable<Vector2>;
  10473. }
  10474. }
  10475. declare module BABYLON {
  10476. /**
  10477. * Class representing a ray with position and direction
  10478. */
  10479. export class Ray {
  10480. /** origin point */
  10481. origin: Vector3;
  10482. /** direction */
  10483. direction: Vector3;
  10484. /** length of the ray */
  10485. length: number;
  10486. private static readonly _TmpVector3;
  10487. private _tmpRay;
  10488. /**
  10489. * Creates a new ray
  10490. * @param origin origin point
  10491. * @param direction direction
  10492. * @param length length of the ray
  10493. */
  10494. constructor(
  10495. /** origin point */
  10496. origin: Vector3,
  10497. /** direction */
  10498. direction: Vector3,
  10499. /** length of the ray */
  10500. length?: number);
  10501. /**
  10502. * Checks if the ray intersects a box
  10503. * This does not account for the ray lenght by design to improve perfs.
  10504. * @param minimum bound of the box
  10505. * @param maximum bound of the box
  10506. * @param intersectionTreshold extra extend to be added to the box in all direction
  10507. * @returns if the box was hit
  10508. */
  10509. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10510. /**
  10511. * Checks if the ray intersects a box
  10512. * This does not account for the ray lenght by design to improve perfs.
  10513. * @param box the bounding box to check
  10514. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10515. * @returns if the box was hit
  10516. */
  10517. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10518. /**
  10519. * If the ray hits a sphere
  10520. * @param sphere the bounding sphere to check
  10521. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10522. * @returns true if it hits the sphere
  10523. */
  10524. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10525. /**
  10526. * If the ray hits a triange
  10527. * @param vertex0 triangle vertex
  10528. * @param vertex1 triangle vertex
  10529. * @param vertex2 triangle vertex
  10530. * @returns intersection information if hit
  10531. */
  10532. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10533. /**
  10534. * Checks if ray intersects a plane
  10535. * @param plane the plane to check
  10536. * @returns the distance away it was hit
  10537. */
  10538. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10539. /**
  10540. * Calculate the intercept of a ray on a given axis
  10541. * @param axis to check 'x' | 'y' | 'z'
  10542. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10543. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10544. */
  10545. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10546. /**
  10547. * Checks if ray intersects a mesh
  10548. * @param mesh the mesh to check
  10549. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10550. * @returns picking info of the intersecton
  10551. */
  10552. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10553. /**
  10554. * Checks if ray intersects a mesh
  10555. * @param meshes the meshes to check
  10556. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10557. * @param results array to store result in
  10558. * @returns Array of picking infos
  10559. */
  10560. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10561. private _comparePickingInfo;
  10562. private static smallnum;
  10563. private static rayl;
  10564. /**
  10565. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10566. * @param sega the first point of the segment to test the intersection against
  10567. * @param segb the second point of the segment to test the intersection against
  10568. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10569. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10570. */
  10571. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10572. /**
  10573. * Update the ray from viewport position
  10574. * @param x position
  10575. * @param y y position
  10576. * @param viewportWidth viewport width
  10577. * @param viewportHeight viewport height
  10578. * @param world world matrix
  10579. * @param view view matrix
  10580. * @param projection projection matrix
  10581. * @returns this ray updated
  10582. */
  10583. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10584. /**
  10585. * Creates a ray with origin and direction of 0,0,0
  10586. * @returns the new ray
  10587. */
  10588. static Zero(): Ray;
  10589. /**
  10590. * Creates a new ray from screen space and viewport
  10591. * @param x position
  10592. * @param y y position
  10593. * @param viewportWidth viewport width
  10594. * @param viewportHeight viewport height
  10595. * @param world world matrix
  10596. * @param view view matrix
  10597. * @param projection projection matrix
  10598. * @returns new ray
  10599. */
  10600. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10601. /**
  10602. * 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
  10603. * transformed to the given world matrix.
  10604. * @param origin The origin point
  10605. * @param end The end point
  10606. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10607. * @returns the new ray
  10608. */
  10609. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10610. /**
  10611. * Transforms a ray by a matrix
  10612. * @param ray ray to transform
  10613. * @param matrix matrix to apply
  10614. * @returns the resulting new ray
  10615. */
  10616. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10617. /**
  10618. * Transforms a ray by a matrix
  10619. * @param ray ray to transform
  10620. * @param matrix matrix to apply
  10621. * @param result ray to store result in
  10622. */
  10623. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10624. /**
  10625. * Unproject a ray from screen space to object space
  10626. * @param sourceX defines the screen space x coordinate to use
  10627. * @param sourceY defines the screen space y coordinate to use
  10628. * @param viewportWidth defines the current width of the viewport
  10629. * @param viewportHeight defines the current height of the viewport
  10630. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10631. * @param view defines the view matrix to use
  10632. * @param projection defines the projection matrix to use
  10633. */
  10634. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10635. }
  10636. /**
  10637. * Type used to define predicate used to select faces when a mesh intersection is detected
  10638. */
  10639. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10640. interface Scene {
  10641. /** @hidden */
  10642. _tempPickingRay: Nullable<Ray>;
  10643. /** @hidden */
  10644. _cachedRayForTransform: Ray;
  10645. /** @hidden */
  10646. _pickWithRayInverseMatrix: Matrix;
  10647. /** @hidden */
  10648. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10649. /** @hidden */
  10650. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10651. /** @hidden */
  10652. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10653. }
  10654. }
  10655. declare module BABYLON {
  10656. /**
  10657. * Groups all the scene component constants in one place to ease maintenance.
  10658. * @hidden
  10659. */
  10660. export class SceneComponentConstants {
  10661. static readonly NAME_EFFECTLAYER: string;
  10662. static readonly NAME_LAYER: string;
  10663. static readonly NAME_LENSFLARESYSTEM: string;
  10664. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10665. static readonly NAME_PARTICLESYSTEM: string;
  10666. static readonly NAME_GAMEPAD: string;
  10667. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10668. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10669. static readonly NAME_PREPASSRENDERER: string;
  10670. static readonly NAME_DEPTHRENDERER: string;
  10671. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10672. static readonly NAME_SPRITE: string;
  10673. static readonly NAME_SUBSURFACE: string;
  10674. static readonly NAME_OUTLINERENDERER: string;
  10675. static readonly NAME_PROCEDURALTEXTURE: string;
  10676. static readonly NAME_SHADOWGENERATOR: string;
  10677. static readonly NAME_OCTREE: string;
  10678. static readonly NAME_PHYSICSENGINE: string;
  10679. static readonly NAME_AUDIO: string;
  10680. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10681. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10682. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10683. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10684. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10685. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10686. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10687. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10688. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10689. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10690. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10691. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10692. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10693. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10694. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10695. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10696. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10697. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10698. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10699. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10700. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10701. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10702. static readonly STEP_AFTERRENDER_AUDIO: number;
  10703. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10704. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10705. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10706. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10707. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10708. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10709. static readonly STEP_POINTERMOVE_SPRITE: number;
  10710. static readonly STEP_POINTERDOWN_SPRITE: number;
  10711. static readonly STEP_POINTERUP_SPRITE: number;
  10712. }
  10713. /**
  10714. * This represents a scene component.
  10715. *
  10716. * This is used to decouple the dependency the scene is having on the different workloads like
  10717. * layers, post processes...
  10718. */
  10719. export interface ISceneComponent {
  10720. /**
  10721. * The name of the component. Each component must have a unique name.
  10722. */
  10723. name: string;
  10724. /**
  10725. * The scene the component belongs to.
  10726. */
  10727. scene: Scene;
  10728. /**
  10729. * Register the component to one instance of a scene.
  10730. */
  10731. register(): void;
  10732. /**
  10733. * Rebuilds the elements related to this component in case of
  10734. * context lost for instance.
  10735. */
  10736. rebuild(): void;
  10737. /**
  10738. * Disposes the component and the associated ressources.
  10739. */
  10740. dispose(): void;
  10741. }
  10742. /**
  10743. * This represents a SERIALIZABLE scene component.
  10744. *
  10745. * This extends Scene Component to add Serialization methods on top.
  10746. */
  10747. export interface ISceneSerializableComponent extends ISceneComponent {
  10748. /**
  10749. * Adds all the elements from the container to the scene
  10750. * @param container the container holding the elements
  10751. */
  10752. addFromContainer(container: AbstractScene): void;
  10753. /**
  10754. * Removes all the elements in the container from the scene
  10755. * @param container contains the elements to remove
  10756. * @param dispose if the removed element should be disposed (default: false)
  10757. */
  10758. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10759. /**
  10760. * Serializes the component data to the specified json object
  10761. * @param serializationObject The object to serialize to
  10762. */
  10763. serialize(serializationObject: any): void;
  10764. }
  10765. /**
  10766. * Strong typing of a Mesh related stage step action
  10767. */
  10768. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10769. /**
  10770. * Strong typing of a Evaluate Sub Mesh related stage step action
  10771. */
  10772. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10773. /**
  10774. * Strong typing of a Active Mesh related stage step action
  10775. */
  10776. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10777. /**
  10778. * Strong typing of a Camera related stage step action
  10779. */
  10780. export type CameraStageAction = (camera: Camera) => void;
  10781. /**
  10782. * Strong typing of a Camera Frame buffer related stage step action
  10783. */
  10784. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10785. /**
  10786. * Strong typing of a Render Target related stage step action
  10787. */
  10788. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10789. /**
  10790. * Strong typing of a RenderingGroup related stage step action
  10791. */
  10792. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10793. /**
  10794. * Strong typing of a Mesh Render related stage step action
  10795. */
  10796. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10797. /**
  10798. * Strong typing of a simple stage step action
  10799. */
  10800. export type SimpleStageAction = () => void;
  10801. /**
  10802. * Strong typing of a render target action.
  10803. */
  10804. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10805. /**
  10806. * Strong typing of a pointer move action.
  10807. */
  10808. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10809. /**
  10810. * Strong typing of a pointer up/down action.
  10811. */
  10812. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10813. /**
  10814. * Representation of a stage in the scene (Basically a list of ordered steps)
  10815. * @hidden
  10816. */
  10817. export class Stage<T extends Function> extends Array<{
  10818. index: number;
  10819. component: ISceneComponent;
  10820. action: T;
  10821. }> {
  10822. /**
  10823. * Hide ctor from the rest of the world.
  10824. * @param items The items to add.
  10825. */
  10826. private constructor();
  10827. /**
  10828. * Creates a new Stage.
  10829. * @returns A new instance of a Stage
  10830. */
  10831. static Create<T extends Function>(): Stage<T>;
  10832. /**
  10833. * Registers a step in an ordered way in the targeted stage.
  10834. * @param index Defines the position to register the step in
  10835. * @param component Defines the component attached to the step
  10836. * @param action Defines the action to launch during the step
  10837. */
  10838. registerStep(index: number, component: ISceneComponent, action: T): void;
  10839. /**
  10840. * Clears all the steps from the stage.
  10841. */
  10842. clear(): void;
  10843. }
  10844. }
  10845. declare module BABYLON {
  10846. interface Scene {
  10847. /** @hidden */
  10848. _pointerOverSprite: Nullable<Sprite>;
  10849. /** @hidden */
  10850. _pickedDownSprite: Nullable<Sprite>;
  10851. /** @hidden */
  10852. _tempSpritePickingRay: Nullable<Ray>;
  10853. /**
  10854. * All of the sprite managers added to this scene
  10855. * @see https://doc.babylonjs.com/babylon101/sprites
  10856. */
  10857. spriteManagers: Array<ISpriteManager>;
  10858. /**
  10859. * An event triggered when sprites rendering is about to start
  10860. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10861. */
  10862. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10863. /**
  10864. * An event triggered when sprites rendering is done
  10865. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10866. */
  10867. onAfterSpritesRenderingObservable: Observable<Scene>;
  10868. /** @hidden */
  10869. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10870. /** Launch a ray to try to pick a sprite in the scene
  10871. * @param x position on screen
  10872. * @param y position on screen
  10873. * @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
  10874. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10875. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10876. * @returns a PickingInfo
  10877. */
  10878. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10879. /** Use the given ray to pick a sprite in the scene
  10880. * @param ray The ray (in world space) to use to pick meshes
  10881. * @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
  10882. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10883. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10884. * @returns a PickingInfo
  10885. */
  10886. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10887. /** @hidden */
  10888. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10889. /** Launch a ray to try to pick sprites in the scene
  10890. * @param x position on screen
  10891. * @param y position on screen
  10892. * @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
  10893. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10894. * @returns a PickingInfo array
  10895. */
  10896. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10897. /** Use the given ray to pick sprites in the scene
  10898. * @param ray The ray (in world space) to use to pick meshes
  10899. * @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
  10900. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10901. * @returns a PickingInfo array
  10902. */
  10903. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10904. /**
  10905. * Force the sprite under the pointer
  10906. * @param sprite defines the sprite to use
  10907. */
  10908. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10909. /**
  10910. * Gets the sprite under the pointer
  10911. * @returns a Sprite or null if no sprite is under the pointer
  10912. */
  10913. getPointerOverSprite(): Nullable<Sprite>;
  10914. }
  10915. /**
  10916. * Defines the sprite scene component responsible to manage sprites
  10917. * in a given scene.
  10918. */
  10919. export class SpriteSceneComponent implements ISceneComponent {
  10920. /**
  10921. * The component name helpfull to identify the component in the list of scene components.
  10922. */
  10923. readonly name: string;
  10924. /**
  10925. * The scene the component belongs to.
  10926. */
  10927. scene: Scene;
  10928. /** @hidden */
  10929. private _spritePredicate;
  10930. /**
  10931. * Creates a new instance of the component for the given scene
  10932. * @param scene Defines the scene to register the component in
  10933. */
  10934. constructor(scene: Scene);
  10935. /**
  10936. * Registers the component in a given scene
  10937. */
  10938. register(): void;
  10939. /**
  10940. * Rebuilds the elements related to this component in case of
  10941. * context lost for instance.
  10942. */
  10943. rebuild(): void;
  10944. /**
  10945. * Disposes the component and the associated ressources.
  10946. */
  10947. dispose(): void;
  10948. private _pickSpriteButKeepRay;
  10949. private _pointerMove;
  10950. private _pointerDown;
  10951. private _pointerUp;
  10952. }
  10953. }
  10954. declare module BABYLON {
  10955. /** @hidden */
  10956. export var fogFragmentDeclaration: {
  10957. name: string;
  10958. shader: string;
  10959. };
  10960. }
  10961. declare module BABYLON {
  10962. /** @hidden */
  10963. export var fogFragment: {
  10964. name: string;
  10965. shader: string;
  10966. };
  10967. }
  10968. declare module BABYLON {
  10969. /** @hidden */
  10970. export var spritesPixelShader: {
  10971. name: string;
  10972. shader: string;
  10973. };
  10974. }
  10975. declare module BABYLON {
  10976. /** @hidden */
  10977. export var fogVertexDeclaration: {
  10978. name: string;
  10979. shader: string;
  10980. };
  10981. }
  10982. declare module BABYLON {
  10983. /** @hidden */
  10984. export var spritesVertexShader: {
  10985. name: string;
  10986. shader: string;
  10987. };
  10988. }
  10989. declare module BABYLON {
  10990. /**
  10991. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10992. */
  10993. export interface ISpriteManager extends IDisposable {
  10994. /**
  10995. * Gets manager's name
  10996. */
  10997. name: string;
  10998. /**
  10999. * Restricts the camera to viewing objects with the same layerMask.
  11000. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11001. */
  11002. layerMask: number;
  11003. /**
  11004. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11005. */
  11006. isPickable: boolean;
  11007. /**
  11008. * Gets the hosting scene
  11009. */
  11010. scene: Scene;
  11011. /**
  11012. * Specifies the rendering group id for this mesh (0 by default)
  11013. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11014. */
  11015. renderingGroupId: number;
  11016. /**
  11017. * Defines the list of sprites managed by the manager.
  11018. */
  11019. sprites: Array<Sprite>;
  11020. /**
  11021. * Gets or sets the spritesheet texture
  11022. */
  11023. texture: Texture;
  11024. /** Defines the default width of a cell in the spritesheet */
  11025. cellWidth: number;
  11026. /** Defines the default height of a cell in the spritesheet */
  11027. cellHeight: number;
  11028. /**
  11029. * Tests the intersection of a sprite with a specific ray.
  11030. * @param ray The ray we are sending to test the collision
  11031. * @param camera The camera space we are sending rays in
  11032. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11033. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11034. * @returns picking info or null.
  11035. */
  11036. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11037. /**
  11038. * Intersects the sprites with a ray
  11039. * @param ray defines the ray to intersect with
  11040. * @param camera defines the current active camera
  11041. * @param predicate defines a predicate used to select candidate sprites
  11042. * @returns null if no hit or a PickingInfo array
  11043. */
  11044. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11045. /**
  11046. * Renders the list of sprites on screen.
  11047. */
  11048. render(): void;
  11049. }
  11050. /**
  11051. * Class used to manage multiple sprites on the same spritesheet
  11052. * @see https://doc.babylonjs.com/babylon101/sprites
  11053. */
  11054. export class SpriteManager implements ISpriteManager {
  11055. /** defines the manager's name */
  11056. name: string;
  11057. /** Define the Url to load snippets */
  11058. static SnippetUrl: string;
  11059. /** Snippet ID if the manager was created from the snippet server */
  11060. snippetId: string;
  11061. /** Gets the list of sprites */
  11062. sprites: Sprite[];
  11063. /** Gets or sets the rendering group id (0 by default) */
  11064. renderingGroupId: number;
  11065. /** Gets or sets camera layer mask */
  11066. layerMask: number;
  11067. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11068. fogEnabled: boolean;
  11069. /** Gets or sets a boolean indicating if the sprites are pickable */
  11070. isPickable: boolean;
  11071. /** Defines the default width of a cell in the spritesheet */
  11072. cellWidth: number;
  11073. /** Defines the default height of a cell in the spritesheet */
  11074. cellHeight: number;
  11075. /** Associative array from JSON sprite data file */
  11076. private _cellData;
  11077. /** Array of sprite names from JSON sprite data file */
  11078. private _spriteMap;
  11079. /** True when packed cell data from JSON file is ready*/
  11080. private _packedAndReady;
  11081. private _textureContent;
  11082. private _useInstancing;
  11083. /**
  11084. * An event triggered when the manager is disposed.
  11085. */
  11086. onDisposeObservable: Observable<SpriteManager>;
  11087. private _onDisposeObserver;
  11088. /**
  11089. * Callback called when the manager is disposed
  11090. */
  11091. set onDispose(callback: () => void);
  11092. private _capacity;
  11093. private _fromPacked;
  11094. private _spriteTexture;
  11095. private _epsilon;
  11096. private _scene;
  11097. private _vertexData;
  11098. private _buffer;
  11099. private _vertexBuffers;
  11100. private _spriteBuffer;
  11101. private _indexBuffer;
  11102. private _effectBase;
  11103. private _effectFog;
  11104. private _vertexBufferSize;
  11105. /**
  11106. * Gets or sets the unique id of the sprite
  11107. */
  11108. uniqueId: number;
  11109. /**
  11110. * Gets the array of sprites
  11111. */
  11112. get children(): Sprite[];
  11113. /**
  11114. * Gets the hosting scene
  11115. */
  11116. get scene(): Scene;
  11117. /**
  11118. * Gets the capacity of the manager
  11119. */
  11120. get capacity(): number;
  11121. /**
  11122. * Gets or sets the spritesheet texture
  11123. */
  11124. get texture(): Texture;
  11125. set texture(value: Texture);
  11126. private _blendMode;
  11127. /**
  11128. * Blend mode use to render the particle, it can be any of
  11129. * the static Constants.ALPHA_x properties provided in this class.
  11130. * Default value is Constants.ALPHA_COMBINE
  11131. */
  11132. get blendMode(): number;
  11133. set blendMode(blendMode: number);
  11134. /** Disables writing to the depth buffer when rendering the sprites.
  11135. * It can be handy to disable depth writing when using textures without alpha channel
  11136. * and setting some specific blend modes.
  11137. */
  11138. disableDepthWrite: boolean;
  11139. /**
  11140. * Creates a new sprite manager
  11141. * @param name defines the manager's name
  11142. * @param imgUrl defines the sprite sheet url
  11143. * @param capacity defines the maximum allowed number of sprites
  11144. * @param cellSize defines the size of a sprite cell
  11145. * @param scene defines the hosting scene
  11146. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11147. * @param samplingMode defines the smapling mode to use with spritesheet
  11148. * @param fromPacked set to false; do not alter
  11149. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11150. */
  11151. constructor(
  11152. /** defines the manager's name */
  11153. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11154. /**
  11155. * Returns the string "SpriteManager"
  11156. * @returns "SpriteManager"
  11157. */
  11158. getClassName(): string;
  11159. private _makePacked;
  11160. private _appendSpriteVertex;
  11161. private _checkTextureAlpha;
  11162. /**
  11163. * Intersects the sprites with a ray
  11164. * @param ray defines the ray to intersect with
  11165. * @param camera defines the current active camera
  11166. * @param predicate defines a predicate used to select candidate sprites
  11167. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11168. * @returns null if no hit or a PickingInfo
  11169. */
  11170. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11171. /**
  11172. * Intersects the sprites with a ray
  11173. * @param ray defines the ray to intersect with
  11174. * @param camera defines the current active camera
  11175. * @param predicate defines a predicate used to select candidate sprites
  11176. * @returns null if no hit or a PickingInfo array
  11177. */
  11178. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11179. /**
  11180. * Render all child sprites
  11181. */
  11182. render(): void;
  11183. /**
  11184. * Release associated resources
  11185. */
  11186. dispose(): void;
  11187. /**
  11188. * Serializes the sprite manager to a JSON object
  11189. * @param serializeTexture defines if the texture must be serialized as well
  11190. * @returns the JSON object
  11191. */
  11192. serialize(serializeTexture?: boolean): any;
  11193. /**
  11194. * Parses a JSON object to create a new sprite manager.
  11195. * @param parsedManager The JSON object to parse
  11196. * @param scene The scene to create the sprite managerin
  11197. * @param rootUrl The root url to use to load external dependencies like texture
  11198. * @returns the new sprite manager
  11199. */
  11200. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11201. /**
  11202. * Creates a sprite manager from a snippet saved in a remote file
  11203. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11204. * @param url defines the url to load from
  11205. * @param scene defines the hosting scene
  11206. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11207. * @returns a promise that will resolve to the new sprite manager
  11208. */
  11209. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11210. /**
  11211. * Creates a sprite manager from a snippet saved by the sprite editor
  11212. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11213. * @param scene defines the hosting scene
  11214. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11215. * @returns a promise that will resolve to the new sprite manager
  11216. */
  11217. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11218. }
  11219. }
  11220. declare module BABYLON {
  11221. /** Interface used by value gradients (color, factor, ...) */
  11222. export interface IValueGradient {
  11223. /**
  11224. * Gets or sets the gradient value (between 0 and 1)
  11225. */
  11226. gradient: number;
  11227. }
  11228. /** Class used to store color4 gradient */
  11229. export class ColorGradient implements IValueGradient {
  11230. /**
  11231. * Gets or sets the gradient value (between 0 and 1)
  11232. */
  11233. gradient: number;
  11234. /**
  11235. * Gets or sets first associated color
  11236. */
  11237. color1: Color4;
  11238. /**
  11239. * Gets or sets second associated color
  11240. */
  11241. color2?: Color4 | undefined;
  11242. /**
  11243. * Creates a new color4 gradient
  11244. * @param gradient gets or sets the gradient value (between 0 and 1)
  11245. * @param color1 gets or sets first associated color
  11246. * @param color2 gets or sets first second color
  11247. */
  11248. constructor(
  11249. /**
  11250. * Gets or sets the gradient value (between 0 and 1)
  11251. */
  11252. gradient: number,
  11253. /**
  11254. * Gets or sets first associated color
  11255. */
  11256. color1: Color4,
  11257. /**
  11258. * Gets or sets second associated color
  11259. */
  11260. color2?: Color4 | undefined);
  11261. /**
  11262. * Will get a color picked randomly between color1 and color2.
  11263. * If color2 is undefined then color1 will be used
  11264. * @param result defines the target Color4 to store the result in
  11265. */
  11266. getColorToRef(result: Color4): void;
  11267. }
  11268. /** Class used to store color 3 gradient */
  11269. export class Color3Gradient implements IValueGradient {
  11270. /**
  11271. * Gets or sets the gradient value (between 0 and 1)
  11272. */
  11273. gradient: number;
  11274. /**
  11275. * Gets or sets the associated color
  11276. */
  11277. color: Color3;
  11278. /**
  11279. * Creates a new color3 gradient
  11280. * @param gradient gets or sets the gradient value (between 0 and 1)
  11281. * @param color gets or sets associated color
  11282. */
  11283. constructor(
  11284. /**
  11285. * Gets or sets the gradient value (between 0 and 1)
  11286. */
  11287. gradient: number,
  11288. /**
  11289. * Gets or sets the associated color
  11290. */
  11291. color: Color3);
  11292. }
  11293. /** Class used to store factor gradient */
  11294. export class FactorGradient implements IValueGradient {
  11295. /**
  11296. * Gets or sets the gradient value (between 0 and 1)
  11297. */
  11298. gradient: number;
  11299. /**
  11300. * Gets or sets first associated factor
  11301. */
  11302. factor1: number;
  11303. /**
  11304. * Gets or sets second associated factor
  11305. */
  11306. factor2?: number | undefined;
  11307. /**
  11308. * Creates a new factor gradient
  11309. * @param gradient gets or sets the gradient value (between 0 and 1)
  11310. * @param factor1 gets or sets first associated factor
  11311. * @param factor2 gets or sets second associated factor
  11312. */
  11313. constructor(
  11314. /**
  11315. * Gets or sets the gradient value (between 0 and 1)
  11316. */
  11317. gradient: number,
  11318. /**
  11319. * Gets or sets first associated factor
  11320. */
  11321. factor1: number,
  11322. /**
  11323. * Gets or sets second associated factor
  11324. */
  11325. factor2?: number | undefined);
  11326. /**
  11327. * Will get a number picked randomly between factor1 and factor2.
  11328. * If factor2 is undefined then factor1 will be used
  11329. * @returns the picked number
  11330. */
  11331. getFactor(): number;
  11332. }
  11333. /**
  11334. * Helper used to simplify some generic gradient tasks
  11335. */
  11336. export class GradientHelper {
  11337. /**
  11338. * Gets the current gradient from an array of IValueGradient
  11339. * @param ratio defines the current ratio to get
  11340. * @param gradients defines the array of IValueGradient
  11341. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11342. */
  11343. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11344. }
  11345. }
  11346. declare module BABYLON {
  11347. interface ThinEngine {
  11348. /**
  11349. * Creates a raw texture
  11350. * @param data defines the data to store in the texture
  11351. * @param width defines the width of the texture
  11352. * @param height defines the height of the texture
  11353. * @param format defines the format of the data
  11354. * @param generateMipMaps defines if the engine should generate the mip levels
  11355. * @param invertY defines if data must be stored with Y axis inverted
  11356. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11357. * @param compression defines the compression used (null by default)
  11358. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11359. * @returns the raw texture inside an InternalTexture
  11360. */
  11361. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11362. /**
  11363. * Update a raw texture
  11364. * @param texture defines the texture to update
  11365. * @param data defines the data to store in the texture
  11366. * @param format defines the format of the data
  11367. * @param invertY defines if data must be stored with Y axis inverted
  11368. */
  11369. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11370. /**
  11371. * Update a raw texture
  11372. * @param texture defines the texture to update
  11373. * @param data defines the data to store in the texture
  11374. * @param format defines the format of the data
  11375. * @param invertY defines if data must be stored with Y axis inverted
  11376. * @param compression defines the compression used (null by default)
  11377. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11378. */
  11379. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11380. /**
  11381. * Creates a new raw cube texture
  11382. * @param data defines the array of data to use to create each face
  11383. * @param size defines the size of the textures
  11384. * @param format defines the format of the data
  11385. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11386. * @param generateMipMaps defines if the engine should generate the mip levels
  11387. * @param invertY defines if data must be stored with Y axis inverted
  11388. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11389. * @param compression defines the compression used (null by default)
  11390. * @returns the cube texture as an InternalTexture
  11391. */
  11392. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11393. /**
  11394. * Update a raw cube texture
  11395. * @param texture defines the texture to udpdate
  11396. * @param data defines the data to store
  11397. * @param format defines the data format
  11398. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11399. * @param invertY defines if data must be stored with Y axis inverted
  11400. */
  11401. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11402. /**
  11403. * Update a raw cube texture
  11404. * @param texture defines the texture to udpdate
  11405. * @param data defines the data to store
  11406. * @param format defines the data format
  11407. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11408. * @param invertY defines if data must be stored with Y axis inverted
  11409. * @param compression defines the compression used (null by default)
  11410. */
  11411. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11412. /**
  11413. * Update a raw cube texture
  11414. * @param texture defines the texture to udpdate
  11415. * @param data defines the data to store
  11416. * @param format defines the data format
  11417. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11418. * @param invertY defines if data must be stored with Y axis inverted
  11419. * @param compression defines the compression used (null by default)
  11420. * @param level defines which level of the texture to update
  11421. */
  11422. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11423. /**
  11424. * Creates a new raw cube texture from a specified url
  11425. * @param url defines the url where the data is located
  11426. * @param scene defines the current scene
  11427. * @param size defines the size of the textures
  11428. * @param format defines the format of the data
  11429. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11430. * @param noMipmap defines if the engine should avoid generating the mip levels
  11431. * @param callback defines a callback used to extract texture data from loaded data
  11432. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11433. * @param onLoad defines a callback called when texture is loaded
  11434. * @param onError defines a callback called if there is an error
  11435. * @returns the cube texture as an InternalTexture
  11436. */
  11437. 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;
  11438. /**
  11439. * Creates a new raw cube texture from a specified url
  11440. * @param url defines the url where the data is located
  11441. * @param scene defines the current scene
  11442. * @param size defines the size of the textures
  11443. * @param format defines the format of the data
  11444. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11445. * @param noMipmap defines if the engine should avoid generating the mip levels
  11446. * @param callback defines a callback used to extract texture data from loaded data
  11447. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11448. * @param onLoad defines a callback called when texture is loaded
  11449. * @param onError defines a callback called if there is an error
  11450. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11451. * @param invertY defines if data must be stored with Y axis inverted
  11452. * @returns the cube texture as an InternalTexture
  11453. */
  11454. 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;
  11455. /**
  11456. * Creates a new raw 3D texture
  11457. * @param data defines the data used to create the texture
  11458. * @param width defines the width of the texture
  11459. * @param height defines the height of the texture
  11460. * @param depth defines the depth of the texture
  11461. * @param format defines the format of the texture
  11462. * @param generateMipMaps defines if the engine must generate mip levels
  11463. * @param invertY defines if data must be stored with Y axis inverted
  11464. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11465. * @param compression defines the compressed used (can be null)
  11466. * @param textureType defines the compressed used (can be null)
  11467. * @returns a new raw 3D texture (stored in an InternalTexture)
  11468. */
  11469. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11470. /**
  11471. * Update a raw 3D texture
  11472. * @param texture defines the texture to update
  11473. * @param data defines the data to store
  11474. * @param format defines the data format
  11475. * @param invertY defines if data must be stored with Y axis inverted
  11476. */
  11477. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11478. /**
  11479. * Update a raw 3D texture
  11480. * @param texture defines the texture to update
  11481. * @param data defines the data to store
  11482. * @param format defines the data format
  11483. * @param invertY defines if data must be stored with Y axis inverted
  11484. * @param compression defines the used compression (can be null)
  11485. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11486. */
  11487. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11488. /**
  11489. * Creates a new raw 2D array texture
  11490. * @param data defines the data used to create the texture
  11491. * @param width defines the width of the texture
  11492. * @param height defines the height of the texture
  11493. * @param depth defines the number of layers of the texture
  11494. * @param format defines the format of the texture
  11495. * @param generateMipMaps defines if the engine must generate mip levels
  11496. * @param invertY defines if data must be stored with Y axis inverted
  11497. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11498. * @param compression defines the compressed used (can be null)
  11499. * @param textureType defines the compressed used (can be null)
  11500. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11501. */
  11502. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11503. /**
  11504. * Update a raw 2D array texture
  11505. * @param texture defines the texture to update
  11506. * @param data defines the data to store
  11507. * @param format defines the data format
  11508. * @param invertY defines if data must be stored with Y axis inverted
  11509. */
  11510. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11511. /**
  11512. * Update a raw 2D array texture
  11513. * @param texture defines the texture to update
  11514. * @param data defines the data to store
  11515. * @param format defines the data format
  11516. * @param invertY defines if data must be stored with Y axis inverted
  11517. * @param compression defines the used compression (can be null)
  11518. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11519. */
  11520. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11521. }
  11522. }
  11523. declare module BABYLON {
  11524. /**
  11525. * Raw texture can help creating a texture directly from an array of data.
  11526. * This can be super useful if you either get the data from an uncompressed source or
  11527. * if you wish to create your texture pixel by pixel.
  11528. */
  11529. export class RawTexture extends Texture {
  11530. /**
  11531. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11532. */
  11533. format: number;
  11534. /**
  11535. * Instantiates a new RawTexture.
  11536. * Raw texture can help creating a texture directly from an array of data.
  11537. * This can be super useful if you either get the data from an uncompressed source or
  11538. * if you wish to create your texture pixel by pixel.
  11539. * @param data define the array of data to use to create the texture
  11540. * @param width define the width of the texture
  11541. * @param height define the height of the texture
  11542. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11543. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11544. * @param generateMipMaps define whether mip maps should be generated or not
  11545. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11546. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11547. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11548. */
  11549. constructor(data: ArrayBufferView, width: number, height: number,
  11550. /**
  11551. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11552. */
  11553. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11554. /**
  11555. * Updates the texture underlying data.
  11556. * @param data Define the new data of the texture
  11557. */
  11558. update(data: ArrayBufferView): void;
  11559. /**
  11560. * Creates a luminance texture from some data.
  11561. * @param data Define the texture data
  11562. * @param width Define the width of the texture
  11563. * @param height Define the height of the texture
  11564. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11565. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11566. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11567. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11568. * @returns the luminance texture
  11569. */
  11570. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11571. /**
  11572. * Creates a luminance alpha texture from some data.
  11573. * @param data Define the texture data
  11574. * @param width Define the width of the texture
  11575. * @param height Define the height of the texture
  11576. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11577. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11578. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11579. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11580. * @returns the luminance alpha texture
  11581. */
  11582. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11583. /**
  11584. * Creates an alpha texture from some data.
  11585. * @param data Define the texture data
  11586. * @param width Define the width of the texture
  11587. * @param height Define the height of the texture
  11588. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11589. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11590. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11591. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11592. * @returns the alpha texture
  11593. */
  11594. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11595. /**
  11596. * Creates a RGB texture from some data.
  11597. * @param data Define the texture data
  11598. * @param width Define the width of the texture
  11599. * @param height Define the height of the texture
  11600. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11601. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11602. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11603. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11604. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11605. * @returns the RGB alpha texture
  11606. */
  11607. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11608. /**
  11609. * Creates a RGBA texture from some data.
  11610. * @param data Define the texture data
  11611. * @param width Define the width of the texture
  11612. * @param height Define the height of the texture
  11613. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11614. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11615. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11616. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11617. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11618. * @returns the RGBA texture
  11619. */
  11620. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11621. /**
  11622. * Creates a R texture from some data.
  11623. * @param data Define the texture data
  11624. * @param width Define the width of the texture
  11625. * @param height Define the height of the texture
  11626. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11627. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11628. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11629. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11630. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11631. * @returns the R texture
  11632. */
  11633. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11634. }
  11635. }
  11636. declare module BABYLON {
  11637. interface ThinEngine {
  11638. /**
  11639. * Update a dynamic index buffer
  11640. * @param indexBuffer defines the target index buffer
  11641. * @param indices defines the data to update
  11642. * @param offset defines the offset in the target index buffer where update should start
  11643. */
  11644. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11645. /**
  11646. * Updates a dynamic vertex buffer.
  11647. * @param vertexBuffer the vertex buffer to update
  11648. * @param data the data used to update the vertex buffer
  11649. * @param byteOffset the byte offset of the data
  11650. * @param byteLength the byte length of the data
  11651. */
  11652. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11653. }
  11654. }
  11655. declare module BABYLON {
  11656. interface AbstractScene {
  11657. /**
  11658. * The list of procedural textures added to the scene
  11659. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11660. */
  11661. proceduralTextures: Array<ProceduralTexture>;
  11662. }
  11663. /**
  11664. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11665. * in a given scene.
  11666. */
  11667. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11668. /**
  11669. * The component name helpfull to identify the component in the list of scene components.
  11670. */
  11671. readonly name: string;
  11672. /**
  11673. * The scene the component belongs to.
  11674. */
  11675. scene: Scene;
  11676. /**
  11677. * Creates a new instance of the component for the given scene
  11678. * @param scene Defines the scene to register the component in
  11679. */
  11680. constructor(scene: Scene);
  11681. /**
  11682. * Registers the component in a given scene
  11683. */
  11684. register(): void;
  11685. /**
  11686. * Rebuilds the elements related to this component in case of
  11687. * context lost for instance.
  11688. */
  11689. rebuild(): void;
  11690. /**
  11691. * Disposes the component and the associated ressources.
  11692. */
  11693. dispose(): void;
  11694. private _beforeClear;
  11695. }
  11696. }
  11697. declare module BABYLON {
  11698. interface ThinEngine {
  11699. /**
  11700. * Creates a new render target cube texture
  11701. * @param size defines the size of the texture
  11702. * @param options defines the options used to create the texture
  11703. * @returns a new render target cube texture stored in an InternalTexture
  11704. */
  11705. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11706. }
  11707. }
  11708. declare module BABYLON {
  11709. /** @hidden */
  11710. export var proceduralVertexShader: {
  11711. name: string;
  11712. shader: string;
  11713. };
  11714. }
  11715. declare module BABYLON {
  11716. /**
  11717. * 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.
  11718. * This is the base class of any Procedural texture and contains most of the shareable code.
  11719. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11720. */
  11721. export class ProceduralTexture extends Texture {
  11722. /**
  11723. * Define if the texture is enabled or not (disabled texture will not render)
  11724. */
  11725. isEnabled: boolean;
  11726. /**
  11727. * Define if the texture must be cleared before rendering (default is true)
  11728. */
  11729. autoClear: boolean;
  11730. /**
  11731. * Callback called when the texture is generated
  11732. */
  11733. onGenerated: () => void;
  11734. /**
  11735. * Event raised when the texture is generated
  11736. */
  11737. onGeneratedObservable: Observable<ProceduralTexture>;
  11738. /**
  11739. * Event raised before the texture is generated
  11740. */
  11741. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  11742. /**
  11743. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  11744. */
  11745. nodeMaterialSource: Nullable<NodeMaterial>;
  11746. /** @hidden */
  11747. _generateMipMaps: boolean;
  11748. /** @hidden **/
  11749. _effect: Effect;
  11750. /** @hidden */
  11751. _textures: {
  11752. [key: string]: Texture;
  11753. };
  11754. /** @hidden */
  11755. protected _fallbackTexture: Nullable<Texture>;
  11756. private _size;
  11757. private _currentRefreshId;
  11758. private _frameId;
  11759. private _refreshRate;
  11760. private _vertexBuffers;
  11761. private _indexBuffer;
  11762. private _uniforms;
  11763. private _samplers;
  11764. private _fragment;
  11765. private _floats;
  11766. private _ints;
  11767. private _floatsArrays;
  11768. private _colors3;
  11769. private _colors4;
  11770. private _vectors2;
  11771. private _vectors3;
  11772. private _matrices;
  11773. private _fallbackTextureUsed;
  11774. private _fullEngine;
  11775. private _cachedDefines;
  11776. private _contentUpdateId;
  11777. private _contentData;
  11778. /**
  11779. * Instantiates a new procedural texture.
  11780. * 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.
  11781. * This is the base class of any Procedural texture and contains most of the shareable code.
  11782. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11783. * @param name Define the name of the texture
  11784. * @param size Define the size of the texture to create
  11785. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11786. * @param scene Define the scene the texture belongs to
  11787. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11788. * @param generateMipMaps Define if the texture should creates mip maps or not
  11789. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11790. */
  11791. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11792. /**
  11793. * The effect that is created when initializing the post process.
  11794. * @returns The created effect corresponding the the postprocess.
  11795. */
  11796. getEffect(): Effect;
  11797. /**
  11798. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11799. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11800. */
  11801. getContent(): Nullable<ArrayBufferView>;
  11802. private _createIndexBuffer;
  11803. /** @hidden */
  11804. _rebuild(): void;
  11805. /**
  11806. * Resets the texture in order to recreate its associated resources.
  11807. * This can be called in case of context loss
  11808. */
  11809. reset(): void;
  11810. protected _getDefines(): string;
  11811. /**
  11812. * Is the texture ready to be used ? (rendered at least once)
  11813. * @returns true if ready, otherwise, false.
  11814. */
  11815. isReady(): boolean;
  11816. /**
  11817. * Resets the refresh counter of the texture and start bak from scratch.
  11818. * Could be useful to regenerate the texture if it is setup to render only once.
  11819. */
  11820. resetRefreshCounter(): void;
  11821. /**
  11822. * Set the fragment shader to use in order to render the texture.
  11823. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11824. */
  11825. setFragment(fragment: any): void;
  11826. /**
  11827. * Define the refresh rate of the texture or the rendering frequency.
  11828. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11829. */
  11830. get refreshRate(): number;
  11831. set refreshRate(value: number);
  11832. /** @hidden */
  11833. _shouldRender(): boolean;
  11834. /**
  11835. * Get the size the texture is rendering at.
  11836. * @returns the size (on cube texture it is always squared)
  11837. */
  11838. getRenderSize(): RenderTargetTextureSize;
  11839. /**
  11840. * Resize the texture to new value.
  11841. * @param size Define the new size the texture should have
  11842. * @param generateMipMaps Define whether the new texture should create mip maps
  11843. */
  11844. resize(size: number, generateMipMaps: boolean): void;
  11845. private _checkUniform;
  11846. /**
  11847. * Set a texture in the shader program used to render.
  11848. * @param name Define the name of the uniform samplers as defined in the shader
  11849. * @param texture Define the texture to bind to this sampler
  11850. * @return the texture itself allowing "fluent" like uniform updates
  11851. */
  11852. setTexture(name: string, texture: Texture): ProceduralTexture;
  11853. /**
  11854. * Set a float in the shader.
  11855. * @param name Define the name of the uniform as defined in the shader
  11856. * @param value Define the value to give to the uniform
  11857. * @return the texture itself allowing "fluent" like uniform updates
  11858. */
  11859. setFloat(name: string, value: number): ProceduralTexture;
  11860. /**
  11861. * Set a int in the shader.
  11862. * @param name Define the name of the uniform as defined in the shader
  11863. * @param value Define the value to give to the uniform
  11864. * @return the texture itself allowing "fluent" like uniform updates
  11865. */
  11866. setInt(name: string, value: number): ProceduralTexture;
  11867. /**
  11868. * Set an array of floats in the shader.
  11869. * @param name Define the name of the uniform as defined in the shader
  11870. * @param value Define the value to give to the uniform
  11871. * @return the texture itself allowing "fluent" like uniform updates
  11872. */
  11873. setFloats(name: string, value: number[]): ProceduralTexture;
  11874. /**
  11875. * Set a vec3 in the shader from a Color3.
  11876. * @param name Define the name of the uniform as defined in the shader
  11877. * @param value Define the value to give to the uniform
  11878. * @return the texture itself allowing "fluent" like uniform updates
  11879. */
  11880. setColor3(name: string, value: Color3): ProceduralTexture;
  11881. /**
  11882. * Set a vec4 in the shader from a Color4.
  11883. * @param name Define the name of the uniform as defined in the shader
  11884. * @param value Define the value to give to the uniform
  11885. * @return the texture itself allowing "fluent" like uniform updates
  11886. */
  11887. setColor4(name: string, value: Color4): ProceduralTexture;
  11888. /**
  11889. * Set a vec2 in the shader from a Vector2.
  11890. * @param name Define the name of the uniform as defined in the shader
  11891. * @param value Define the value to give to the uniform
  11892. * @return the texture itself allowing "fluent" like uniform updates
  11893. */
  11894. setVector2(name: string, value: Vector2): ProceduralTexture;
  11895. /**
  11896. * Set a vec3 in the shader from a Vector3.
  11897. * @param name Define the name of the uniform as defined in the shader
  11898. * @param value Define the value to give to the uniform
  11899. * @return the texture itself allowing "fluent" like uniform updates
  11900. */
  11901. setVector3(name: string, value: Vector3): ProceduralTexture;
  11902. /**
  11903. * Set a mat4 in the shader from a MAtrix.
  11904. * @param name Define the name of the uniform as defined in the shader
  11905. * @param value Define the value to give to the uniform
  11906. * @return the texture itself allowing "fluent" like uniform updates
  11907. */
  11908. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11909. /**
  11910. * Render the texture to its associated render target.
  11911. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11912. */
  11913. render(useCameraPostProcess?: boolean): void;
  11914. /**
  11915. * Clone the texture.
  11916. * @returns the cloned texture
  11917. */
  11918. clone(): ProceduralTexture;
  11919. /**
  11920. * Dispose the texture and release its asoociated resources.
  11921. */
  11922. dispose(): void;
  11923. }
  11924. }
  11925. declare module BABYLON {
  11926. /**
  11927. * This represents the base class for particle system in Babylon.
  11928. * 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.
  11929. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11930. * @example https://doc.babylonjs.com/babylon101/particles
  11931. */
  11932. export class BaseParticleSystem {
  11933. /**
  11934. * Source color is added to the destination color without alpha affecting the result
  11935. */
  11936. static BLENDMODE_ONEONE: number;
  11937. /**
  11938. * Blend current color and particle color using particle’s alpha
  11939. */
  11940. static BLENDMODE_STANDARD: number;
  11941. /**
  11942. * Add current color and particle color multiplied by particle’s alpha
  11943. */
  11944. static BLENDMODE_ADD: number;
  11945. /**
  11946. * Multiply current color with particle color
  11947. */
  11948. static BLENDMODE_MULTIPLY: number;
  11949. /**
  11950. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11951. */
  11952. static BLENDMODE_MULTIPLYADD: number;
  11953. /**
  11954. * List of animations used by the particle system.
  11955. */
  11956. animations: Animation[];
  11957. /**
  11958. * Gets or sets the unique id of the particle system
  11959. */
  11960. uniqueId: number;
  11961. /**
  11962. * The id of the Particle system.
  11963. */
  11964. id: string;
  11965. /**
  11966. * The friendly name of the Particle system.
  11967. */
  11968. name: string;
  11969. /**
  11970. * Snippet ID if the particle system was created from the snippet server
  11971. */
  11972. snippetId: string;
  11973. /**
  11974. * The rendering group used by the Particle system to chose when to render.
  11975. */
  11976. renderingGroupId: number;
  11977. /**
  11978. * The emitter represents the Mesh or position we are attaching the particle system to.
  11979. */
  11980. emitter: Nullable<AbstractMesh | Vector3>;
  11981. /**
  11982. * The maximum number of particles to emit per frame
  11983. */
  11984. emitRate: number;
  11985. /**
  11986. * If you want to launch only a few particles at once, that can be done, as well.
  11987. */
  11988. manualEmitCount: number;
  11989. /**
  11990. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11991. */
  11992. updateSpeed: number;
  11993. /**
  11994. * The amount of time the particle system is running (depends of the overall update speed).
  11995. */
  11996. targetStopDuration: number;
  11997. /**
  11998. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11999. */
  12000. disposeOnStop: boolean;
  12001. /**
  12002. * Minimum power of emitting particles.
  12003. */
  12004. minEmitPower: number;
  12005. /**
  12006. * Maximum power of emitting particles.
  12007. */
  12008. maxEmitPower: number;
  12009. /**
  12010. * Minimum life time of emitting particles.
  12011. */
  12012. minLifeTime: number;
  12013. /**
  12014. * Maximum life time of emitting particles.
  12015. */
  12016. maxLifeTime: number;
  12017. /**
  12018. * Minimum Size of emitting particles.
  12019. */
  12020. minSize: number;
  12021. /**
  12022. * Maximum Size of emitting particles.
  12023. */
  12024. maxSize: number;
  12025. /**
  12026. * Minimum scale of emitting particles on X axis.
  12027. */
  12028. minScaleX: number;
  12029. /**
  12030. * Maximum scale of emitting particles on X axis.
  12031. */
  12032. maxScaleX: number;
  12033. /**
  12034. * Minimum scale of emitting particles on Y axis.
  12035. */
  12036. minScaleY: number;
  12037. /**
  12038. * Maximum scale of emitting particles on Y axis.
  12039. */
  12040. maxScaleY: number;
  12041. /**
  12042. * Gets or sets the minimal initial rotation in radians.
  12043. */
  12044. minInitialRotation: number;
  12045. /**
  12046. * Gets or sets the maximal initial rotation in radians.
  12047. */
  12048. maxInitialRotation: number;
  12049. /**
  12050. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12051. */
  12052. minAngularSpeed: number;
  12053. /**
  12054. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12055. */
  12056. maxAngularSpeed: number;
  12057. /**
  12058. * The texture used to render each particle. (this can be a spritesheet)
  12059. */
  12060. particleTexture: Nullable<BaseTexture>;
  12061. /**
  12062. * The layer mask we are rendering the particles through.
  12063. */
  12064. layerMask: number;
  12065. /**
  12066. * This can help using your own shader to render the particle system.
  12067. * The according effect will be created
  12068. */
  12069. customShader: any;
  12070. /**
  12071. * By default particle system starts as soon as they are created. This prevents the
  12072. * automatic start to happen and let you decide when to start emitting particles.
  12073. */
  12074. preventAutoStart: boolean;
  12075. private _noiseTexture;
  12076. /**
  12077. * Gets or sets a texture used to add random noise to particle positions
  12078. */
  12079. get noiseTexture(): Nullable<ProceduralTexture>;
  12080. set noiseTexture(value: Nullable<ProceduralTexture>);
  12081. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12082. noiseStrength: Vector3;
  12083. /**
  12084. * Callback triggered when the particle animation is ending.
  12085. */
  12086. onAnimationEnd: Nullable<() => void>;
  12087. /**
  12088. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12089. */
  12090. blendMode: number;
  12091. /**
  12092. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12093. * to override the particles.
  12094. */
  12095. forceDepthWrite: boolean;
  12096. /** 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 */
  12097. preWarmCycles: number;
  12098. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12099. preWarmStepOffset: number;
  12100. /**
  12101. * 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)
  12102. */
  12103. spriteCellChangeSpeed: number;
  12104. /**
  12105. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12106. */
  12107. startSpriteCellID: number;
  12108. /**
  12109. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12110. */
  12111. endSpriteCellID: number;
  12112. /**
  12113. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12114. */
  12115. spriteCellWidth: number;
  12116. /**
  12117. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12118. */
  12119. spriteCellHeight: number;
  12120. /**
  12121. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12122. */
  12123. spriteRandomStartCell: boolean;
  12124. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12125. translationPivot: Vector2;
  12126. /** @hidden */
  12127. protected _isAnimationSheetEnabled: boolean;
  12128. /**
  12129. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12130. */
  12131. beginAnimationOnStart: boolean;
  12132. /**
  12133. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12134. */
  12135. beginAnimationFrom: number;
  12136. /**
  12137. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12138. */
  12139. beginAnimationTo: number;
  12140. /**
  12141. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12142. */
  12143. beginAnimationLoop: boolean;
  12144. /**
  12145. * Gets or sets a world offset applied to all particles
  12146. */
  12147. worldOffset: Vector3;
  12148. /**
  12149. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12150. */
  12151. get isAnimationSheetEnabled(): boolean;
  12152. set isAnimationSheetEnabled(value: boolean);
  12153. /**
  12154. * Get hosting scene
  12155. * @returns the scene
  12156. */
  12157. getScene(): Nullable<Scene>;
  12158. /**
  12159. * You can use gravity if you want to give an orientation to your particles.
  12160. */
  12161. gravity: Vector3;
  12162. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12163. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12164. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12165. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12166. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12167. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12168. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12169. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12170. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12171. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12172. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12173. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12174. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12175. /**
  12176. * Defines the delay in milliseconds before starting the system (0 by default)
  12177. */
  12178. startDelay: number;
  12179. /**
  12180. * Gets the current list of drag gradients.
  12181. * You must use addDragGradient and removeDragGradient to udpate this list
  12182. * @returns the list of drag gradients
  12183. */
  12184. getDragGradients(): Nullable<Array<FactorGradient>>;
  12185. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12186. limitVelocityDamping: number;
  12187. /**
  12188. * Gets the current list of limit velocity gradients.
  12189. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12190. * @returns the list of limit velocity gradients
  12191. */
  12192. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12193. /**
  12194. * Gets the current list of color gradients.
  12195. * You must use addColorGradient and removeColorGradient to udpate this list
  12196. * @returns the list of color gradients
  12197. */
  12198. getColorGradients(): Nullable<Array<ColorGradient>>;
  12199. /**
  12200. * Gets the current list of size gradients.
  12201. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12202. * @returns the list of size gradients
  12203. */
  12204. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12205. /**
  12206. * Gets the current list of color remap gradients.
  12207. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12208. * @returns the list of color remap gradients
  12209. */
  12210. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12211. /**
  12212. * Gets the current list of alpha remap gradients.
  12213. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12214. * @returns the list of alpha remap gradients
  12215. */
  12216. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12217. /**
  12218. * Gets the current list of life time gradients.
  12219. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12220. * @returns the list of life time gradients
  12221. */
  12222. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12223. /**
  12224. * Gets the current list of angular speed gradients.
  12225. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12226. * @returns the list of angular speed gradients
  12227. */
  12228. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12229. /**
  12230. * Gets the current list of velocity gradients.
  12231. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12232. * @returns the list of velocity gradients
  12233. */
  12234. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12235. /**
  12236. * Gets the current list of start size gradients.
  12237. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12238. * @returns the list of start size gradients
  12239. */
  12240. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12241. /**
  12242. * Gets the current list of emit rate gradients.
  12243. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12244. * @returns the list of emit rate gradients
  12245. */
  12246. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12247. /**
  12248. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12249. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12250. */
  12251. get direction1(): Vector3;
  12252. set direction1(value: Vector3);
  12253. /**
  12254. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12255. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12256. */
  12257. get direction2(): Vector3;
  12258. set direction2(value: Vector3);
  12259. /**
  12260. * 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.
  12261. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12262. */
  12263. get minEmitBox(): Vector3;
  12264. set minEmitBox(value: Vector3);
  12265. /**
  12266. * 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.
  12267. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12268. */
  12269. get maxEmitBox(): Vector3;
  12270. set maxEmitBox(value: Vector3);
  12271. /**
  12272. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12273. */
  12274. color1: Color4;
  12275. /**
  12276. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12277. */
  12278. color2: Color4;
  12279. /**
  12280. * Color the particle will have at the end of its lifetime
  12281. */
  12282. colorDead: Color4;
  12283. /**
  12284. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12285. */
  12286. textureMask: Color4;
  12287. /**
  12288. * The particle emitter type defines the emitter used by the particle system.
  12289. * It can be for example box, sphere, or cone...
  12290. */
  12291. particleEmitterType: IParticleEmitterType;
  12292. /** @hidden */
  12293. _isSubEmitter: boolean;
  12294. /**
  12295. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12296. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12297. */
  12298. billboardMode: number;
  12299. protected _isBillboardBased: boolean;
  12300. /**
  12301. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12302. */
  12303. get isBillboardBased(): boolean;
  12304. set isBillboardBased(value: boolean);
  12305. /**
  12306. * The scene the particle system belongs to.
  12307. */
  12308. protected _scene: Nullable<Scene>;
  12309. /**
  12310. * The engine the particle system belongs to.
  12311. */
  12312. protected _engine: ThinEngine;
  12313. /**
  12314. * Local cache of defines for image processing.
  12315. */
  12316. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12317. /**
  12318. * Default configuration related to image processing available in the standard Material.
  12319. */
  12320. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12321. /**
  12322. * Gets the image processing configuration used either in this material.
  12323. */
  12324. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12325. /**
  12326. * Sets the Default image processing configuration used either in the this material.
  12327. *
  12328. * If sets to null, the scene one is in use.
  12329. */
  12330. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12331. /**
  12332. * Attaches a new image processing configuration to the Standard Material.
  12333. * @param configuration
  12334. */
  12335. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12336. /** @hidden */
  12337. protected _reset(): void;
  12338. /** @hidden */
  12339. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12340. /**
  12341. * Instantiates a particle system.
  12342. * 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.
  12343. * @param name The name of the particle system
  12344. */
  12345. constructor(name: string);
  12346. /**
  12347. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12348. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12349. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12350. * @returns the emitter
  12351. */
  12352. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12353. /**
  12354. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12355. * @param radius The radius of the hemisphere to emit from
  12356. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12357. * @returns the emitter
  12358. */
  12359. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12360. /**
  12361. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12362. * @param radius The radius of the sphere to emit from
  12363. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12364. * @returns the emitter
  12365. */
  12366. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12367. /**
  12368. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12369. * @param radius The radius of the sphere to emit from
  12370. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12371. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12372. * @returns the emitter
  12373. */
  12374. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12375. /**
  12376. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12377. * @param radius The radius of the emission cylinder
  12378. * @param height The height of the emission cylinder
  12379. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12380. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12381. * @returns the emitter
  12382. */
  12383. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12384. /**
  12385. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12386. * @param radius The radius of the cylinder to emit from
  12387. * @param height The height of the emission cylinder
  12388. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12389. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12390. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12391. * @returns the emitter
  12392. */
  12393. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12394. /**
  12395. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12396. * @param radius The radius of the cone to emit from
  12397. * @param angle The base angle of the cone
  12398. * @returns the emitter
  12399. */
  12400. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12401. /**
  12402. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12403. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12404. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12405. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12406. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12407. * @returns the emitter
  12408. */
  12409. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12410. }
  12411. }
  12412. declare module BABYLON {
  12413. /**
  12414. * Type of sub emitter
  12415. */
  12416. export enum SubEmitterType {
  12417. /**
  12418. * Attached to the particle over it's lifetime
  12419. */
  12420. ATTACHED = 0,
  12421. /**
  12422. * Created when the particle dies
  12423. */
  12424. END = 1
  12425. }
  12426. /**
  12427. * Sub emitter class used to emit particles from an existing particle
  12428. */
  12429. export class SubEmitter {
  12430. /**
  12431. * the particle system to be used by the sub emitter
  12432. */
  12433. particleSystem: ParticleSystem;
  12434. /**
  12435. * Type of the submitter (Default: END)
  12436. */
  12437. type: SubEmitterType;
  12438. /**
  12439. * 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)
  12440. * Note: This only is supported when using an emitter of type Mesh
  12441. */
  12442. inheritDirection: boolean;
  12443. /**
  12444. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12445. */
  12446. inheritedVelocityAmount: number;
  12447. /**
  12448. * Creates a sub emitter
  12449. * @param particleSystem the particle system to be used by the sub emitter
  12450. */
  12451. constructor(
  12452. /**
  12453. * the particle system to be used by the sub emitter
  12454. */
  12455. particleSystem: ParticleSystem);
  12456. /**
  12457. * Clones the sub emitter
  12458. * @returns the cloned sub emitter
  12459. */
  12460. clone(): SubEmitter;
  12461. /**
  12462. * Serialize current object to a JSON object
  12463. * @returns the serialized object
  12464. */
  12465. serialize(): any;
  12466. /** @hidden */
  12467. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12468. /**
  12469. * Creates a new SubEmitter from a serialized JSON version
  12470. * @param serializationObject defines the JSON object to read from
  12471. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12472. * @param rootUrl defines the rootUrl for data loading
  12473. * @returns a new SubEmitter
  12474. */
  12475. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12476. /** Release associated resources */
  12477. dispose(): void;
  12478. }
  12479. }
  12480. declare module BABYLON {
  12481. /** @hidden */
  12482. export var imageProcessingDeclaration: {
  12483. name: string;
  12484. shader: string;
  12485. };
  12486. }
  12487. declare module BABYLON {
  12488. /** @hidden */
  12489. export var imageProcessingFunctions: {
  12490. name: string;
  12491. shader: string;
  12492. };
  12493. }
  12494. declare module BABYLON {
  12495. /** @hidden */
  12496. export var particlesPixelShader: {
  12497. name: string;
  12498. shader: string;
  12499. };
  12500. }
  12501. declare module BABYLON {
  12502. /** @hidden */
  12503. export var particlesVertexShader: {
  12504. name: string;
  12505. shader: string;
  12506. };
  12507. }
  12508. declare module BABYLON {
  12509. /**
  12510. * Interface used to define entities containing multiple clip planes
  12511. */
  12512. export interface IClipPlanesHolder {
  12513. /**
  12514. * Gets or sets the active clipplane 1
  12515. */
  12516. clipPlane: Nullable<Plane>;
  12517. /**
  12518. * Gets or sets the active clipplane 2
  12519. */
  12520. clipPlane2: Nullable<Plane>;
  12521. /**
  12522. * Gets or sets the active clipplane 3
  12523. */
  12524. clipPlane3: Nullable<Plane>;
  12525. /**
  12526. * Gets or sets the active clipplane 4
  12527. */
  12528. clipPlane4: Nullable<Plane>;
  12529. /**
  12530. * Gets or sets the active clipplane 5
  12531. */
  12532. clipPlane5: Nullable<Plane>;
  12533. /**
  12534. * Gets or sets the active clipplane 6
  12535. */
  12536. clipPlane6: Nullable<Plane>;
  12537. }
  12538. }
  12539. declare module BABYLON {
  12540. /**
  12541. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12542. *
  12543. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12544. *
  12545. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12546. */
  12547. export class ThinMaterialHelper {
  12548. /**
  12549. * Binds the clip plane information from the holder to the effect.
  12550. * @param effect The effect we are binding the data to
  12551. * @param holder The entity containing the clip plane information
  12552. */
  12553. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12554. }
  12555. }
  12556. declare module BABYLON {
  12557. interface ThinEngine {
  12558. /**
  12559. * Sets alpha constants used by some alpha blending modes
  12560. * @param r defines the red component
  12561. * @param g defines the green component
  12562. * @param b defines the blue component
  12563. * @param a defines the alpha component
  12564. */
  12565. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12566. /**
  12567. * Sets the current alpha mode
  12568. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12569. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12570. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12571. */
  12572. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12573. /**
  12574. * Gets the current alpha mode
  12575. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12576. * @returns the current alpha mode
  12577. */
  12578. getAlphaMode(): number;
  12579. /**
  12580. * Sets the current alpha equation
  12581. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12582. */
  12583. setAlphaEquation(equation: number): void;
  12584. /**
  12585. * Gets the current alpha equation.
  12586. * @returns the current alpha equation
  12587. */
  12588. getAlphaEquation(): number;
  12589. }
  12590. }
  12591. declare module BABYLON {
  12592. /**
  12593. * This represents a particle system in Babylon.
  12594. * 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.
  12595. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12596. * @example https://doc.babylonjs.com/babylon101/particles
  12597. */
  12598. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12599. /**
  12600. * Billboard mode will only apply to Y axis
  12601. */
  12602. static readonly BILLBOARDMODE_Y: number;
  12603. /**
  12604. * Billboard mode will apply to all axes
  12605. */
  12606. static readonly BILLBOARDMODE_ALL: number;
  12607. /**
  12608. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12609. */
  12610. static readonly BILLBOARDMODE_STRETCHED: number;
  12611. /**
  12612. * This function can be defined to provide custom update for active particles.
  12613. * This function will be called instead of regular update (age, position, color, etc.).
  12614. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12615. */
  12616. updateFunction: (particles: Particle[]) => void;
  12617. private _emitterWorldMatrix;
  12618. /**
  12619. * This function can be defined to specify initial direction for every new particle.
  12620. * It by default use the emitterType defined function
  12621. */
  12622. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12623. /**
  12624. * This function can be defined to specify initial position for every new particle.
  12625. * It by default use the emitterType defined function
  12626. */
  12627. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12628. /**
  12629. * @hidden
  12630. */
  12631. _inheritedVelocityOffset: Vector3;
  12632. /**
  12633. * An event triggered when the system is disposed
  12634. */
  12635. onDisposeObservable: Observable<IParticleSystem>;
  12636. private _onDisposeObserver;
  12637. /**
  12638. * Sets a callback that will be triggered when the system is disposed
  12639. */
  12640. set onDispose(callback: () => void);
  12641. private _particles;
  12642. private _epsilon;
  12643. private _capacity;
  12644. private _stockParticles;
  12645. private _newPartsExcess;
  12646. private _vertexData;
  12647. private _vertexBuffer;
  12648. private _vertexBuffers;
  12649. private _spriteBuffer;
  12650. private _indexBuffer;
  12651. private _effect;
  12652. private _customEffect;
  12653. private _cachedDefines;
  12654. private _scaledColorStep;
  12655. private _colorDiff;
  12656. private _scaledDirection;
  12657. private _scaledGravity;
  12658. private _currentRenderId;
  12659. private _alive;
  12660. private _useInstancing;
  12661. private _started;
  12662. private _stopped;
  12663. private _actualFrame;
  12664. private _scaledUpdateSpeed;
  12665. private _vertexBufferSize;
  12666. /** @hidden */
  12667. _currentEmitRateGradient: Nullable<FactorGradient>;
  12668. /** @hidden */
  12669. _currentEmitRate1: number;
  12670. /** @hidden */
  12671. _currentEmitRate2: number;
  12672. /** @hidden */
  12673. _currentStartSizeGradient: Nullable<FactorGradient>;
  12674. /** @hidden */
  12675. _currentStartSize1: number;
  12676. /** @hidden */
  12677. _currentStartSize2: number;
  12678. private readonly _rawTextureWidth;
  12679. private _rampGradientsTexture;
  12680. private _useRampGradients;
  12681. /** Gets or sets a matrix to use to compute projection */
  12682. defaultProjectionMatrix: Matrix;
  12683. /** Gets or sets a matrix to use to compute view */
  12684. defaultViewMatrix: Matrix;
  12685. /** Gets or sets a boolean indicating that ramp gradients must be used
  12686. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12687. */
  12688. get useRampGradients(): boolean;
  12689. set useRampGradients(value: boolean);
  12690. /**
  12691. * 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.
  12692. * 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: [])
  12693. */
  12694. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12695. private _subEmitters;
  12696. /**
  12697. * @hidden
  12698. * If the particle systems emitter should be disposed when the particle system is disposed
  12699. */
  12700. _disposeEmitterOnDispose: boolean;
  12701. /**
  12702. * The current active Sub-systems, this property is used by the root particle system only.
  12703. */
  12704. activeSubSystems: Array<ParticleSystem>;
  12705. /**
  12706. * Specifies if the particles are updated in emitter local space or world space
  12707. */
  12708. isLocal: boolean;
  12709. private _rootParticleSystem;
  12710. /**
  12711. * Gets the current list of active particles
  12712. */
  12713. get particles(): Particle[];
  12714. /**
  12715. * Gets the number of particles active at the same time.
  12716. * @returns The number of active particles.
  12717. */
  12718. getActiveCount(): number;
  12719. /**
  12720. * Returns the string "ParticleSystem"
  12721. * @returns a string containing the class name
  12722. */
  12723. getClassName(): string;
  12724. /**
  12725. * Gets a boolean indicating that the system is stopping
  12726. * @returns true if the system is currently stopping
  12727. */
  12728. isStopping(): boolean;
  12729. /**
  12730. * Gets the custom effect used to render the particles
  12731. * @param blendMode Blend mode for which the effect should be retrieved
  12732. * @returns The effect
  12733. */
  12734. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12735. /**
  12736. * Sets the custom effect used to render the particles
  12737. * @param effect The effect to set
  12738. * @param blendMode Blend mode for which the effect should be set
  12739. */
  12740. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12741. /** @hidden */
  12742. private _onBeforeDrawParticlesObservable;
  12743. /**
  12744. * Observable that will be called just before the particles are drawn
  12745. */
  12746. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12747. /**
  12748. * Gets the name of the particle vertex shader
  12749. */
  12750. get vertexShaderName(): string;
  12751. /**
  12752. * Instantiates a particle system.
  12753. * 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.
  12754. * @param name The name of the particle system
  12755. * @param capacity The max number of particles alive at the same time
  12756. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12757. * @param customEffect a custom effect used to change the way particles are rendered by default
  12758. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12759. * @param epsilon Offset used to render the particles
  12760. */
  12761. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12762. private _addFactorGradient;
  12763. private _removeFactorGradient;
  12764. /**
  12765. * Adds a new life time gradient
  12766. * @param gradient defines the gradient to use (between 0 and 1)
  12767. * @param factor defines the life time factor to affect to the specified gradient
  12768. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12769. * @returns the current particle system
  12770. */
  12771. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12772. /**
  12773. * Remove a specific life time gradient
  12774. * @param gradient defines the gradient to remove
  12775. * @returns the current particle system
  12776. */
  12777. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12778. /**
  12779. * Adds a new size gradient
  12780. * @param gradient defines the gradient to use (between 0 and 1)
  12781. * @param factor defines the size factor to affect to the specified gradient
  12782. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12783. * @returns the current particle system
  12784. */
  12785. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12786. /**
  12787. * Remove a specific size gradient
  12788. * @param gradient defines the gradient to remove
  12789. * @returns the current particle system
  12790. */
  12791. removeSizeGradient(gradient: number): IParticleSystem;
  12792. /**
  12793. * Adds a new color remap gradient
  12794. * @param gradient defines the gradient to use (between 0 and 1)
  12795. * @param min defines the color remap minimal range
  12796. * @param max defines the color remap maximal range
  12797. * @returns the current particle system
  12798. */
  12799. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12800. /**
  12801. * Remove a specific color remap gradient
  12802. * @param gradient defines the gradient to remove
  12803. * @returns the current particle system
  12804. */
  12805. removeColorRemapGradient(gradient: number): IParticleSystem;
  12806. /**
  12807. * Adds a new alpha remap gradient
  12808. * @param gradient defines the gradient to use (between 0 and 1)
  12809. * @param min defines the alpha remap minimal range
  12810. * @param max defines the alpha remap maximal range
  12811. * @returns the current particle system
  12812. */
  12813. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12814. /**
  12815. * Remove a specific alpha remap gradient
  12816. * @param gradient defines the gradient to remove
  12817. * @returns the current particle system
  12818. */
  12819. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12820. /**
  12821. * Adds a new angular speed gradient
  12822. * @param gradient defines the gradient to use (between 0 and 1)
  12823. * @param factor defines the angular speed to affect to the specified gradient
  12824. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12825. * @returns the current particle system
  12826. */
  12827. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12828. /**
  12829. * Remove a specific angular speed gradient
  12830. * @param gradient defines the gradient to remove
  12831. * @returns the current particle system
  12832. */
  12833. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12834. /**
  12835. * Adds a new velocity gradient
  12836. * @param gradient defines the gradient to use (between 0 and 1)
  12837. * @param factor defines the velocity to affect to the specified gradient
  12838. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12839. * @returns the current particle system
  12840. */
  12841. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12842. /**
  12843. * Remove a specific velocity gradient
  12844. * @param gradient defines the gradient to remove
  12845. * @returns the current particle system
  12846. */
  12847. removeVelocityGradient(gradient: number): IParticleSystem;
  12848. /**
  12849. * Adds a new limit velocity gradient
  12850. * @param gradient defines the gradient to use (between 0 and 1)
  12851. * @param factor defines the limit velocity value to affect to the specified gradient
  12852. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12853. * @returns the current particle system
  12854. */
  12855. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12856. /**
  12857. * Remove a specific limit velocity gradient
  12858. * @param gradient defines the gradient to remove
  12859. * @returns the current particle system
  12860. */
  12861. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12862. /**
  12863. * Adds a new drag gradient
  12864. * @param gradient defines the gradient to use (between 0 and 1)
  12865. * @param factor defines the drag value to affect to the specified gradient
  12866. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12867. * @returns the current particle system
  12868. */
  12869. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12870. /**
  12871. * Remove a specific drag gradient
  12872. * @param gradient defines the gradient to remove
  12873. * @returns the current particle system
  12874. */
  12875. removeDragGradient(gradient: number): IParticleSystem;
  12876. /**
  12877. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12878. * @param gradient defines the gradient to use (between 0 and 1)
  12879. * @param factor defines the emit rate value to affect to the specified gradient
  12880. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12881. * @returns the current particle system
  12882. */
  12883. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12884. /**
  12885. * Remove a specific emit rate gradient
  12886. * @param gradient defines the gradient to remove
  12887. * @returns the current particle system
  12888. */
  12889. removeEmitRateGradient(gradient: number): IParticleSystem;
  12890. /**
  12891. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12892. * @param gradient defines the gradient to use (between 0 and 1)
  12893. * @param factor defines the start size value to affect to the specified gradient
  12894. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12895. * @returns the current particle system
  12896. */
  12897. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12898. /**
  12899. * Remove a specific start size gradient
  12900. * @param gradient defines the gradient to remove
  12901. * @returns the current particle system
  12902. */
  12903. removeStartSizeGradient(gradient: number): IParticleSystem;
  12904. private _createRampGradientTexture;
  12905. /**
  12906. * Gets the current list of ramp gradients.
  12907. * You must use addRampGradient and removeRampGradient to udpate this list
  12908. * @returns the list of ramp gradients
  12909. */
  12910. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12911. /** Force the system to rebuild all gradients that need to be resync */
  12912. forceRefreshGradients(): void;
  12913. private _syncRampGradientTexture;
  12914. /**
  12915. * Adds a new ramp gradient used to remap particle colors
  12916. * @param gradient defines the gradient to use (between 0 and 1)
  12917. * @param color defines the color to affect to the specified gradient
  12918. * @returns the current particle system
  12919. */
  12920. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12921. /**
  12922. * Remove a specific ramp gradient
  12923. * @param gradient defines the gradient to remove
  12924. * @returns the current particle system
  12925. */
  12926. removeRampGradient(gradient: number): ParticleSystem;
  12927. /**
  12928. * Adds a new color gradient
  12929. * @param gradient defines the gradient to use (between 0 and 1)
  12930. * @param color1 defines the color to affect to the specified gradient
  12931. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12932. * @returns this particle system
  12933. */
  12934. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12935. /**
  12936. * Remove a specific color gradient
  12937. * @param gradient defines the gradient to remove
  12938. * @returns this particle system
  12939. */
  12940. removeColorGradient(gradient: number): IParticleSystem;
  12941. private _fetchR;
  12942. protected _reset(): void;
  12943. private _resetEffect;
  12944. private _createVertexBuffers;
  12945. private _createIndexBuffer;
  12946. /**
  12947. * Gets the maximum number of particles active at the same time.
  12948. * @returns The max number of active particles.
  12949. */
  12950. getCapacity(): number;
  12951. /**
  12952. * Gets whether there are still active particles in the system.
  12953. * @returns True if it is alive, otherwise false.
  12954. */
  12955. isAlive(): boolean;
  12956. /**
  12957. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12958. * @returns True if it has been started, otherwise false.
  12959. */
  12960. isStarted(): boolean;
  12961. private _prepareSubEmitterInternalArray;
  12962. /**
  12963. * Starts the particle system and begins to emit
  12964. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12965. */
  12966. start(delay?: number): void;
  12967. /**
  12968. * Stops the particle system.
  12969. * @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.
  12970. */
  12971. stop(stopSubEmitters?: boolean): void;
  12972. /**
  12973. * Remove all active particles
  12974. */
  12975. reset(): void;
  12976. /**
  12977. * @hidden (for internal use only)
  12978. */
  12979. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12980. /**
  12981. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12982. * Its lifetime will start back at 0.
  12983. */
  12984. recycleParticle: (particle: Particle) => void;
  12985. private _stopSubEmitters;
  12986. private _createParticle;
  12987. private _removeFromRoot;
  12988. private _emitFromParticle;
  12989. private _update;
  12990. /** @hidden */
  12991. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12992. /** @hidden */
  12993. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12994. /**
  12995. * Fill the defines array according to the current settings of the particle system
  12996. * @param defines Array to be updated
  12997. * @param blendMode blend mode to take into account when updating the array
  12998. */
  12999. fillDefines(defines: Array<string>, blendMode: number): void;
  13000. /**
  13001. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13002. * @param uniforms Uniforms array to fill
  13003. * @param attributes Attributes array to fill
  13004. * @param samplers Samplers array to fill
  13005. */
  13006. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13007. /** @hidden */
  13008. private _getEffect;
  13009. /**
  13010. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13011. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13012. */
  13013. animate(preWarmOnly?: boolean): void;
  13014. private _appendParticleVertices;
  13015. /**
  13016. * Rebuilds the particle system.
  13017. */
  13018. rebuild(): void;
  13019. /**
  13020. * Is this system ready to be used/rendered
  13021. * @return true if the system is ready
  13022. */
  13023. isReady(): boolean;
  13024. private _render;
  13025. /**
  13026. * Renders the particle system in its current state.
  13027. * @returns the current number of particles
  13028. */
  13029. render(): number;
  13030. /**
  13031. * Disposes the particle system and free the associated resources
  13032. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13033. */
  13034. dispose(disposeTexture?: boolean): void;
  13035. /**
  13036. * Clones the particle system.
  13037. * @param name The name of the cloned object
  13038. * @param newEmitter The new emitter to use
  13039. * @returns the cloned particle system
  13040. */
  13041. clone(name: string, newEmitter: any): ParticleSystem;
  13042. /**
  13043. * Serializes the particle system to a JSON object
  13044. * @param serializeTexture defines if the texture must be serialized as well
  13045. * @returns the JSON object
  13046. */
  13047. serialize(serializeTexture?: boolean): any;
  13048. /** @hidden */
  13049. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13050. /** @hidden */
  13051. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13052. /**
  13053. * Parses a JSON object to create a particle system.
  13054. * @param parsedParticleSystem The JSON object to parse
  13055. * @param sceneOrEngine The scene or the engine to create the particle system in
  13056. * @param rootUrl The root url to use to load external dependencies like texture
  13057. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13058. * @returns the Parsed particle system
  13059. */
  13060. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13061. }
  13062. }
  13063. declare module BABYLON {
  13064. /**
  13065. * A particle represents one of the element emitted by a particle system.
  13066. * This is mainly define by its coordinates, direction, velocity and age.
  13067. */
  13068. export class Particle {
  13069. /**
  13070. * The particle system the particle belongs to.
  13071. */
  13072. particleSystem: ParticleSystem;
  13073. private static _Count;
  13074. /**
  13075. * Unique ID of the particle
  13076. */
  13077. id: number;
  13078. /**
  13079. * The world position of the particle in the scene.
  13080. */
  13081. position: Vector3;
  13082. /**
  13083. * The world direction of the particle in the scene.
  13084. */
  13085. direction: Vector3;
  13086. /**
  13087. * The color of the particle.
  13088. */
  13089. color: Color4;
  13090. /**
  13091. * The color change of the particle per step.
  13092. */
  13093. colorStep: Color4;
  13094. /**
  13095. * Defines how long will the life of the particle be.
  13096. */
  13097. lifeTime: number;
  13098. /**
  13099. * The current age of the particle.
  13100. */
  13101. age: number;
  13102. /**
  13103. * The current size of the particle.
  13104. */
  13105. size: number;
  13106. /**
  13107. * The current scale of the particle.
  13108. */
  13109. scale: Vector2;
  13110. /**
  13111. * The current angle of the particle.
  13112. */
  13113. angle: number;
  13114. /**
  13115. * Defines how fast is the angle changing.
  13116. */
  13117. angularSpeed: number;
  13118. /**
  13119. * Defines the cell index used by the particle to be rendered from a sprite.
  13120. */
  13121. cellIndex: number;
  13122. /**
  13123. * The information required to support color remapping
  13124. */
  13125. remapData: Vector4;
  13126. /** @hidden */
  13127. _randomCellOffset?: number;
  13128. /** @hidden */
  13129. _initialDirection: Nullable<Vector3>;
  13130. /** @hidden */
  13131. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13132. /** @hidden */
  13133. _initialStartSpriteCellID: number;
  13134. /** @hidden */
  13135. _initialEndSpriteCellID: number;
  13136. /** @hidden */
  13137. _currentColorGradient: Nullable<ColorGradient>;
  13138. /** @hidden */
  13139. _currentColor1: Color4;
  13140. /** @hidden */
  13141. _currentColor2: Color4;
  13142. /** @hidden */
  13143. _currentSizeGradient: Nullable<FactorGradient>;
  13144. /** @hidden */
  13145. _currentSize1: number;
  13146. /** @hidden */
  13147. _currentSize2: number;
  13148. /** @hidden */
  13149. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13150. /** @hidden */
  13151. _currentAngularSpeed1: number;
  13152. /** @hidden */
  13153. _currentAngularSpeed2: number;
  13154. /** @hidden */
  13155. _currentVelocityGradient: Nullable<FactorGradient>;
  13156. /** @hidden */
  13157. _currentVelocity1: number;
  13158. /** @hidden */
  13159. _currentVelocity2: number;
  13160. /** @hidden */
  13161. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13162. /** @hidden */
  13163. _currentLimitVelocity1: number;
  13164. /** @hidden */
  13165. _currentLimitVelocity2: number;
  13166. /** @hidden */
  13167. _currentDragGradient: Nullable<FactorGradient>;
  13168. /** @hidden */
  13169. _currentDrag1: number;
  13170. /** @hidden */
  13171. _currentDrag2: number;
  13172. /** @hidden */
  13173. _randomNoiseCoordinates1: Vector3;
  13174. /** @hidden */
  13175. _randomNoiseCoordinates2: Vector3;
  13176. /** @hidden */
  13177. _localPosition?: Vector3;
  13178. /**
  13179. * Creates a new instance Particle
  13180. * @param particleSystem the particle system the particle belongs to
  13181. */
  13182. constructor(
  13183. /**
  13184. * The particle system the particle belongs to.
  13185. */
  13186. particleSystem: ParticleSystem);
  13187. private updateCellInfoFromSystem;
  13188. /**
  13189. * Defines how the sprite cell index is updated for the particle
  13190. */
  13191. updateCellIndex(): void;
  13192. /** @hidden */
  13193. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13194. /** @hidden */
  13195. _inheritParticleInfoToSubEmitters(): void;
  13196. /** @hidden */
  13197. _reset(): void;
  13198. /**
  13199. * Copy the properties of particle to another one.
  13200. * @param other the particle to copy the information to.
  13201. */
  13202. copyTo(other: Particle): void;
  13203. }
  13204. }
  13205. declare module BABYLON {
  13206. /**
  13207. * Particle emitter represents a volume emitting particles.
  13208. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13209. */
  13210. export interface IParticleEmitterType {
  13211. /**
  13212. * Called by the particle System when the direction is computed for the created particle.
  13213. * @param worldMatrix is the world matrix of the particle system
  13214. * @param directionToUpdate is the direction vector to update with the result
  13215. * @param particle is the particle we are computed the direction for
  13216. * @param isLocal defines if the direction should be set in local space
  13217. */
  13218. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13219. /**
  13220. * Called by the particle System when the position is computed for the created particle.
  13221. * @param worldMatrix is the world matrix of the particle system
  13222. * @param positionToUpdate is the position vector to update with the result
  13223. * @param particle is the particle we are computed the position for
  13224. * @param isLocal defines if the position should be set in local space
  13225. */
  13226. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13227. /**
  13228. * Clones the current emitter and returns a copy of it
  13229. * @returns the new emitter
  13230. */
  13231. clone(): IParticleEmitterType;
  13232. /**
  13233. * Called by the GPUParticleSystem to setup the update shader
  13234. * @param effect defines the update shader
  13235. */
  13236. applyToShader(effect: Effect): void;
  13237. /**
  13238. * Returns a string to use to update the GPU particles update shader
  13239. * @returns the effect defines string
  13240. */
  13241. getEffectDefines(): string;
  13242. /**
  13243. * Returns a string representing the class name
  13244. * @returns a string containing the class name
  13245. */
  13246. getClassName(): string;
  13247. /**
  13248. * Serializes the particle system to a JSON object.
  13249. * @returns the JSON object
  13250. */
  13251. serialize(): any;
  13252. /**
  13253. * Parse properties from a JSON object
  13254. * @param serializationObject defines the JSON object
  13255. * @param scene defines the hosting scene
  13256. */
  13257. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13258. }
  13259. }
  13260. declare module BABYLON {
  13261. /**
  13262. * Particle emitter emitting particles from the inside of a box.
  13263. * It emits the particles randomly between 2 given directions.
  13264. */
  13265. export class BoxParticleEmitter implements IParticleEmitterType {
  13266. /**
  13267. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13268. */
  13269. direction1: Vector3;
  13270. /**
  13271. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13272. */
  13273. direction2: Vector3;
  13274. /**
  13275. * 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.
  13276. */
  13277. minEmitBox: Vector3;
  13278. /**
  13279. * 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.
  13280. */
  13281. maxEmitBox: Vector3;
  13282. /**
  13283. * Creates a new instance BoxParticleEmitter
  13284. */
  13285. constructor();
  13286. /**
  13287. * Called by the particle System when the direction is computed for the created particle.
  13288. * @param worldMatrix is the world matrix of the particle system
  13289. * @param directionToUpdate is the direction vector to update with the result
  13290. * @param particle is the particle we are computed the direction for
  13291. * @param isLocal defines if the direction should be set in local space
  13292. */
  13293. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13294. /**
  13295. * Called by the particle System when the position is computed for the created particle.
  13296. * @param worldMatrix is the world matrix of the particle system
  13297. * @param positionToUpdate is the position vector to update with the result
  13298. * @param particle is the particle we are computed the position for
  13299. * @param isLocal defines if the position should be set in local space
  13300. */
  13301. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13302. /**
  13303. * Clones the current emitter and returns a copy of it
  13304. * @returns the new emitter
  13305. */
  13306. clone(): BoxParticleEmitter;
  13307. /**
  13308. * Called by the GPUParticleSystem to setup the update shader
  13309. * @param effect defines the update shader
  13310. */
  13311. applyToShader(effect: Effect): void;
  13312. /**
  13313. * Returns a string to use to update the GPU particles update shader
  13314. * @returns a string containng the defines string
  13315. */
  13316. getEffectDefines(): string;
  13317. /**
  13318. * Returns the string "BoxParticleEmitter"
  13319. * @returns a string containing the class name
  13320. */
  13321. getClassName(): string;
  13322. /**
  13323. * Serializes the particle system to a JSON object.
  13324. * @returns the JSON object
  13325. */
  13326. serialize(): any;
  13327. /**
  13328. * Parse properties from a JSON object
  13329. * @param serializationObject defines the JSON object
  13330. */
  13331. parse(serializationObject: any): void;
  13332. }
  13333. }
  13334. declare module BABYLON {
  13335. /**
  13336. * Particle emitter emitting particles from the inside of a cone.
  13337. * It emits the particles alongside the cone volume from the base to the particle.
  13338. * The emission direction might be randomized.
  13339. */
  13340. export class ConeParticleEmitter implements IParticleEmitterType {
  13341. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13342. directionRandomizer: number;
  13343. private _radius;
  13344. private _angle;
  13345. private _height;
  13346. /**
  13347. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13348. */
  13349. radiusRange: number;
  13350. /**
  13351. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13352. */
  13353. heightRange: number;
  13354. /**
  13355. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13356. */
  13357. emitFromSpawnPointOnly: boolean;
  13358. /**
  13359. * Gets or sets the radius of the emission cone
  13360. */
  13361. get radius(): number;
  13362. set radius(value: number);
  13363. /**
  13364. * Gets or sets the angle of the emission cone
  13365. */
  13366. get angle(): number;
  13367. set angle(value: number);
  13368. private _buildHeight;
  13369. /**
  13370. * Creates a new instance ConeParticleEmitter
  13371. * @param radius the radius of the emission cone (1 by default)
  13372. * @param angle the cone base angle (PI by default)
  13373. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13374. */
  13375. constructor(radius?: number, angle?: number,
  13376. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13377. directionRandomizer?: number);
  13378. /**
  13379. * Called by the particle System when the direction is computed for the created particle.
  13380. * @param worldMatrix is the world matrix of the particle system
  13381. * @param directionToUpdate is the direction vector to update with the result
  13382. * @param particle is the particle we are computed the direction for
  13383. * @param isLocal defines if the direction should be set in local space
  13384. */
  13385. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13386. /**
  13387. * Called by the particle System when the position is computed for the created particle.
  13388. * @param worldMatrix is the world matrix of the particle system
  13389. * @param positionToUpdate is the position vector to update with the result
  13390. * @param particle is the particle we are computed the position for
  13391. * @param isLocal defines if the position should be set in local space
  13392. */
  13393. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13394. /**
  13395. * Clones the current emitter and returns a copy of it
  13396. * @returns the new emitter
  13397. */
  13398. clone(): ConeParticleEmitter;
  13399. /**
  13400. * Called by the GPUParticleSystem to setup the update shader
  13401. * @param effect defines the update shader
  13402. */
  13403. applyToShader(effect: Effect): void;
  13404. /**
  13405. * Returns a string to use to update the GPU particles update shader
  13406. * @returns a string containng the defines string
  13407. */
  13408. getEffectDefines(): string;
  13409. /**
  13410. * Returns the string "ConeParticleEmitter"
  13411. * @returns a string containing the class name
  13412. */
  13413. getClassName(): string;
  13414. /**
  13415. * Serializes the particle system to a JSON object.
  13416. * @returns the JSON object
  13417. */
  13418. serialize(): any;
  13419. /**
  13420. * Parse properties from a JSON object
  13421. * @param serializationObject defines the JSON object
  13422. */
  13423. parse(serializationObject: any): void;
  13424. }
  13425. }
  13426. declare module BABYLON {
  13427. /**
  13428. * Particle emitter emitting particles from the inside of a cylinder.
  13429. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13430. */
  13431. export class CylinderParticleEmitter implements IParticleEmitterType {
  13432. /**
  13433. * The radius of the emission cylinder.
  13434. */
  13435. radius: number;
  13436. /**
  13437. * The height of the emission cylinder.
  13438. */
  13439. height: number;
  13440. /**
  13441. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13442. */
  13443. radiusRange: number;
  13444. /**
  13445. * How much to randomize the particle direction [0-1].
  13446. */
  13447. directionRandomizer: number;
  13448. /**
  13449. * Creates a new instance CylinderParticleEmitter
  13450. * @param radius the radius of the emission cylinder (1 by default)
  13451. * @param height the height of the emission cylinder (1 by default)
  13452. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13453. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13454. */
  13455. constructor(
  13456. /**
  13457. * The radius of the emission cylinder.
  13458. */
  13459. radius?: number,
  13460. /**
  13461. * The height of the emission cylinder.
  13462. */
  13463. height?: number,
  13464. /**
  13465. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13466. */
  13467. radiusRange?: number,
  13468. /**
  13469. * How much to randomize the particle direction [0-1].
  13470. */
  13471. directionRandomizer?: number);
  13472. /**
  13473. * Called by the particle System when the direction is computed for the created particle.
  13474. * @param worldMatrix is the world matrix of the particle system
  13475. * @param directionToUpdate is the direction vector to update with the result
  13476. * @param particle is the particle we are computed the direction for
  13477. * @param isLocal defines if the direction should be set in local space
  13478. */
  13479. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13480. /**
  13481. * Called by the particle System when the position is computed for the created particle.
  13482. * @param worldMatrix is the world matrix of the particle system
  13483. * @param positionToUpdate is the position vector to update with the result
  13484. * @param particle is the particle we are computed the position for
  13485. * @param isLocal defines if the position should be set in local space
  13486. */
  13487. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13488. /**
  13489. * Clones the current emitter and returns a copy of it
  13490. * @returns the new emitter
  13491. */
  13492. clone(): CylinderParticleEmitter;
  13493. /**
  13494. * Called by the GPUParticleSystem to setup the update shader
  13495. * @param effect defines the update shader
  13496. */
  13497. applyToShader(effect: Effect): void;
  13498. /**
  13499. * Returns a string to use to update the GPU particles update shader
  13500. * @returns a string containng the defines string
  13501. */
  13502. getEffectDefines(): string;
  13503. /**
  13504. * Returns the string "CylinderParticleEmitter"
  13505. * @returns a string containing the class name
  13506. */
  13507. getClassName(): string;
  13508. /**
  13509. * Serializes the particle system to a JSON object.
  13510. * @returns the JSON object
  13511. */
  13512. serialize(): any;
  13513. /**
  13514. * Parse properties from a JSON object
  13515. * @param serializationObject defines the JSON object
  13516. */
  13517. parse(serializationObject: any): void;
  13518. }
  13519. /**
  13520. * Particle emitter emitting particles from the inside of a cylinder.
  13521. * It emits the particles randomly between two vectors.
  13522. */
  13523. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13524. /**
  13525. * The min limit of the emission direction.
  13526. */
  13527. direction1: Vector3;
  13528. /**
  13529. * The max limit of the emission direction.
  13530. */
  13531. direction2: Vector3;
  13532. /**
  13533. * Creates a new instance CylinderDirectedParticleEmitter
  13534. * @param radius the radius of the emission cylinder (1 by default)
  13535. * @param height the height of the emission cylinder (1 by default)
  13536. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13537. * @param direction1 the min limit of the emission direction (up vector by default)
  13538. * @param direction2 the max limit of the emission direction (up vector by default)
  13539. */
  13540. constructor(radius?: number, height?: number, radiusRange?: number,
  13541. /**
  13542. * The min limit of the emission direction.
  13543. */
  13544. direction1?: Vector3,
  13545. /**
  13546. * The max limit of the emission direction.
  13547. */
  13548. direction2?: Vector3);
  13549. /**
  13550. * Called by the particle System when the direction is computed for the created particle.
  13551. * @param worldMatrix is the world matrix of the particle system
  13552. * @param directionToUpdate is the direction vector to update with the result
  13553. * @param particle is the particle we are computed the direction for
  13554. */
  13555. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13556. /**
  13557. * Clones the current emitter and returns a copy of it
  13558. * @returns the new emitter
  13559. */
  13560. clone(): CylinderDirectedParticleEmitter;
  13561. /**
  13562. * Called by the GPUParticleSystem to setup the update shader
  13563. * @param effect defines the update shader
  13564. */
  13565. applyToShader(effect: Effect): void;
  13566. /**
  13567. * Returns a string to use to update the GPU particles update shader
  13568. * @returns a string containng the defines string
  13569. */
  13570. getEffectDefines(): string;
  13571. /**
  13572. * Returns the string "CylinderDirectedParticleEmitter"
  13573. * @returns a string containing the class name
  13574. */
  13575. getClassName(): string;
  13576. /**
  13577. * Serializes the particle system to a JSON object.
  13578. * @returns the JSON object
  13579. */
  13580. serialize(): any;
  13581. /**
  13582. * Parse properties from a JSON object
  13583. * @param serializationObject defines the JSON object
  13584. */
  13585. parse(serializationObject: any): void;
  13586. }
  13587. }
  13588. declare module BABYLON {
  13589. /**
  13590. * Particle emitter emitting particles from the inside of a hemisphere.
  13591. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13592. */
  13593. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13594. /**
  13595. * The radius of the emission hemisphere.
  13596. */
  13597. radius: number;
  13598. /**
  13599. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13600. */
  13601. radiusRange: number;
  13602. /**
  13603. * How much to randomize the particle direction [0-1].
  13604. */
  13605. directionRandomizer: number;
  13606. /**
  13607. * Creates a new instance HemisphericParticleEmitter
  13608. * @param radius the radius of the emission hemisphere (1 by default)
  13609. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13610. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13611. */
  13612. constructor(
  13613. /**
  13614. * The radius of the emission hemisphere.
  13615. */
  13616. radius?: number,
  13617. /**
  13618. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13619. */
  13620. radiusRange?: number,
  13621. /**
  13622. * How much to randomize the particle direction [0-1].
  13623. */
  13624. directionRandomizer?: number);
  13625. /**
  13626. * Called by the particle System when the direction is computed for the created particle.
  13627. * @param worldMatrix is the world matrix of the particle system
  13628. * @param directionToUpdate is the direction vector to update with the result
  13629. * @param particle is the particle we are computed the direction for
  13630. * @param isLocal defines if the direction should be set in local space
  13631. */
  13632. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13633. /**
  13634. * Called by the particle System when the position is computed for the created particle.
  13635. * @param worldMatrix is the world matrix of the particle system
  13636. * @param positionToUpdate is the position vector to update with the result
  13637. * @param particle is the particle we are computed the position for
  13638. * @param isLocal defines if the position should be set in local space
  13639. */
  13640. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13641. /**
  13642. * Clones the current emitter and returns a copy of it
  13643. * @returns the new emitter
  13644. */
  13645. clone(): HemisphericParticleEmitter;
  13646. /**
  13647. * Called by the GPUParticleSystem to setup the update shader
  13648. * @param effect defines the update shader
  13649. */
  13650. applyToShader(effect: Effect): void;
  13651. /**
  13652. * Returns a string to use to update the GPU particles update shader
  13653. * @returns a string containng the defines string
  13654. */
  13655. getEffectDefines(): string;
  13656. /**
  13657. * Returns the string "HemisphericParticleEmitter"
  13658. * @returns a string containing the class name
  13659. */
  13660. getClassName(): string;
  13661. /**
  13662. * Serializes the particle system to a JSON object.
  13663. * @returns the JSON object
  13664. */
  13665. serialize(): any;
  13666. /**
  13667. * Parse properties from a JSON object
  13668. * @param serializationObject defines the JSON object
  13669. */
  13670. parse(serializationObject: any): void;
  13671. }
  13672. }
  13673. declare module BABYLON {
  13674. /**
  13675. * Particle emitter emitting particles from a point.
  13676. * It emits the particles randomly between 2 given directions.
  13677. */
  13678. export class PointParticleEmitter implements IParticleEmitterType {
  13679. /**
  13680. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13681. */
  13682. direction1: Vector3;
  13683. /**
  13684. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13685. */
  13686. direction2: Vector3;
  13687. /**
  13688. * Creates a new instance PointParticleEmitter
  13689. */
  13690. constructor();
  13691. /**
  13692. * Called by the particle System when the direction is computed for the created particle.
  13693. * @param worldMatrix is the world matrix of the particle system
  13694. * @param directionToUpdate is the direction vector to update with the result
  13695. * @param particle is the particle we are computed the direction for
  13696. * @param isLocal defines if the direction should be set in local space
  13697. */
  13698. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13699. /**
  13700. * Called by the particle System when the position is computed for the created particle.
  13701. * @param worldMatrix is the world matrix of the particle system
  13702. * @param positionToUpdate is the position vector to update with the result
  13703. * @param particle is the particle we are computed the position for
  13704. * @param isLocal defines if the position should be set in local space
  13705. */
  13706. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13707. /**
  13708. * Clones the current emitter and returns a copy of it
  13709. * @returns the new emitter
  13710. */
  13711. clone(): PointParticleEmitter;
  13712. /**
  13713. * Called by the GPUParticleSystem to setup the update shader
  13714. * @param effect defines the update shader
  13715. */
  13716. applyToShader(effect: Effect): void;
  13717. /**
  13718. * Returns a string to use to update the GPU particles update shader
  13719. * @returns a string containng the defines string
  13720. */
  13721. getEffectDefines(): string;
  13722. /**
  13723. * Returns the string "PointParticleEmitter"
  13724. * @returns a string containing the class name
  13725. */
  13726. getClassName(): string;
  13727. /**
  13728. * Serializes the particle system to a JSON object.
  13729. * @returns the JSON object
  13730. */
  13731. serialize(): any;
  13732. /**
  13733. * Parse properties from a JSON object
  13734. * @param serializationObject defines the JSON object
  13735. */
  13736. parse(serializationObject: any): void;
  13737. }
  13738. }
  13739. declare module BABYLON {
  13740. /**
  13741. * Particle emitter emitting particles from the inside of a sphere.
  13742. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13743. */
  13744. export class SphereParticleEmitter implements IParticleEmitterType {
  13745. /**
  13746. * The radius of the emission sphere.
  13747. */
  13748. radius: number;
  13749. /**
  13750. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13751. */
  13752. radiusRange: number;
  13753. /**
  13754. * How much to randomize the particle direction [0-1].
  13755. */
  13756. directionRandomizer: number;
  13757. /**
  13758. * Creates a new instance SphereParticleEmitter
  13759. * @param radius the radius of the emission sphere (1 by default)
  13760. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13761. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13762. */
  13763. constructor(
  13764. /**
  13765. * The radius of the emission sphere.
  13766. */
  13767. radius?: number,
  13768. /**
  13769. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13770. */
  13771. radiusRange?: number,
  13772. /**
  13773. * How much to randomize the particle direction [0-1].
  13774. */
  13775. directionRandomizer?: number);
  13776. /**
  13777. * Called by the particle System when the direction is computed for the created particle.
  13778. * @param worldMatrix is the world matrix of the particle system
  13779. * @param directionToUpdate is the direction vector to update with the result
  13780. * @param particle is the particle we are computed the direction for
  13781. * @param isLocal defines if the direction should be set in local space
  13782. */
  13783. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13784. /**
  13785. * Called by the particle System when the position is computed for the created particle.
  13786. * @param worldMatrix is the world matrix of the particle system
  13787. * @param positionToUpdate is the position vector to update with the result
  13788. * @param particle is the particle we are computed the position for
  13789. * @param isLocal defines if the position should be set in local space
  13790. */
  13791. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13792. /**
  13793. * Clones the current emitter and returns a copy of it
  13794. * @returns the new emitter
  13795. */
  13796. clone(): SphereParticleEmitter;
  13797. /**
  13798. * Called by the GPUParticleSystem to setup the update shader
  13799. * @param effect defines the update shader
  13800. */
  13801. applyToShader(effect: Effect): void;
  13802. /**
  13803. * Returns a string to use to update the GPU particles update shader
  13804. * @returns a string containng the defines string
  13805. */
  13806. getEffectDefines(): string;
  13807. /**
  13808. * Returns the string "SphereParticleEmitter"
  13809. * @returns a string containing the class name
  13810. */
  13811. getClassName(): string;
  13812. /**
  13813. * Serializes the particle system to a JSON object.
  13814. * @returns the JSON object
  13815. */
  13816. serialize(): any;
  13817. /**
  13818. * Parse properties from a JSON object
  13819. * @param serializationObject defines the JSON object
  13820. */
  13821. parse(serializationObject: any): void;
  13822. }
  13823. /**
  13824. * Particle emitter emitting particles from the inside of a sphere.
  13825. * It emits the particles randomly between two vectors.
  13826. */
  13827. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13828. /**
  13829. * The min limit of the emission direction.
  13830. */
  13831. direction1: Vector3;
  13832. /**
  13833. * The max limit of the emission direction.
  13834. */
  13835. direction2: Vector3;
  13836. /**
  13837. * Creates a new instance SphereDirectedParticleEmitter
  13838. * @param radius the radius of the emission sphere (1 by default)
  13839. * @param direction1 the min limit of the emission direction (up vector by default)
  13840. * @param direction2 the max limit of the emission direction (up vector by default)
  13841. */
  13842. constructor(radius?: number,
  13843. /**
  13844. * The min limit of the emission direction.
  13845. */
  13846. direction1?: Vector3,
  13847. /**
  13848. * The max limit of the emission direction.
  13849. */
  13850. direction2?: Vector3);
  13851. /**
  13852. * Called by the particle System when the direction is computed for the created particle.
  13853. * @param worldMatrix is the world matrix of the particle system
  13854. * @param directionToUpdate is the direction vector to update with the result
  13855. * @param particle is the particle we are computed the direction for
  13856. */
  13857. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13858. /**
  13859. * Clones the current emitter and returns a copy of it
  13860. * @returns the new emitter
  13861. */
  13862. clone(): SphereDirectedParticleEmitter;
  13863. /**
  13864. * Called by the GPUParticleSystem to setup the update shader
  13865. * @param effect defines the update shader
  13866. */
  13867. applyToShader(effect: Effect): void;
  13868. /**
  13869. * Returns a string to use to update the GPU particles update shader
  13870. * @returns a string containng the defines string
  13871. */
  13872. getEffectDefines(): string;
  13873. /**
  13874. * Returns the string "SphereDirectedParticleEmitter"
  13875. * @returns a string containing the class name
  13876. */
  13877. getClassName(): string;
  13878. /**
  13879. * Serializes the particle system to a JSON object.
  13880. * @returns the JSON object
  13881. */
  13882. serialize(): any;
  13883. /**
  13884. * Parse properties from a JSON object
  13885. * @param serializationObject defines the JSON object
  13886. */
  13887. parse(serializationObject: any): void;
  13888. }
  13889. }
  13890. declare module BABYLON {
  13891. /**
  13892. * Particle emitter emitting particles from a custom list of positions.
  13893. */
  13894. export class CustomParticleEmitter implements IParticleEmitterType {
  13895. /**
  13896. * Gets or sets the position generator that will create the inital position of each particle.
  13897. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13898. */
  13899. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13900. /**
  13901. * Gets or sets the destination generator that will create the final destination of each particle.
  13902. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13903. */
  13904. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13905. /**
  13906. * Creates a new instance CustomParticleEmitter
  13907. */
  13908. constructor();
  13909. /**
  13910. * Called by the particle System when the direction is computed for the created particle.
  13911. * @param worldMatrix is the world matrix of the particle system
  13912. * @param directionToUpdate is the direction vector to update with the result
  13913. * @param particle is the particle we are computed the direction for
  13914. * @param isLocal defines if the direction should be set in local space
  13915. */
  13916. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13917. /**
  13918. * Called by the particle System when the position is computed for the created particle.
  13919. * @param worldMatrix is the world matrix of the particle system
  13920. * @param positionToUpdate is the position vector to update with the result
  13921. * @param particle is the particle we are computed the position for
  13922. * @param isLocal defines if the position should be set in local space
  13923. */
  13924. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13925. /**
  13926. * Clones the current emitter and returns a copy of it
  13927. * @returns the new emitter
  13928. */
  13929. clone(): CustomParticleEmitter;
  13930. /**
  13931. * Called by the GPUParticleSystem to setup the update shader
  13932. * @param effect defines the update shader
  13933. */
  13934. applyToShader(effect: Effect): void;
  13935. /**
  13936. * Returns a string to use to update the GPU particles update shader
  13937. * @returns a string containng the defines string
  13938. */
  13939. getEffectDefines(): string;
  13940. /**
  13941. * Returns the string "PointParticleEmitter"
  13942. * @returns a string containing the class name
  13943. */
  13944. getClassName(): string;
  13945. /**
  13946. * Serializes the particle system to a JSON object.
  13947. * @returns the JSON object
  13948. */
  13949. serialize(): any;
  13950. /**
  13951. * Parse properties from a JSON object
  13952. * @param serializationObject defines the JSON object
  13953. */
  13954. parse(serializationObject: any): void;
  13955. }
  13956. }
  13957. declare module BABYLON {
  13958. /**
  13959. * Particle emitter emitting particles from the inside of a box.
  13960. * It emits the particles randomly between 2 given directions.
  13961. */
  13962. export class MeshParticleEmitter implements IParticleEmitterType {
  13963. private _indices;
  13964. private _positions;
  13965. private _normals;
  13966. private _storedNormal;
  13967. private _mesh;
  13968. /**
  13969. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13970. */
  13971. direction1: Vector3;
  13972. /**
  13973. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13974. */
  13975. direction2: Vector3;
  13976. /**
  13977. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13978. */
  13979. useMeshNormalsForDirection: boolean;
  13980. /** Defines the mesh to use as source */
  13981. get mesh(): Nullable<AbstractMesh>;
  13982. set mesh(value: Nullable<AbstractMesh>);
  13983. /**
  13984. * Creates a new instance MeshParticleEmitter
  13985. * @param mesh defines the mesh to use as source
  13986. */
  13987. constructor(mesh?: Nullable<AbstractMesh>);
  13988. /**
  13989. * Called by the particle System when the direction is computed for the created particle.
  13990. * @param worldMatrix is the world matrix of the particle system
  13991. * @param directionToUpdate is the direction vector to update with the result
  13992. * @param particle is the particle we are computed the direction for
  13993. * @param isLocal defines if the direction should be set in local space
  13994. */
  13995. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13996. /**
  13997. * Called by the particle System when the position is computed for the created particle.
  13998. * @param worldMatrix is the world matrix of the particle system
  13999. * @param positionToUpdate is the position vector to update with the result
  14000. * @param particle is the particle we are computed the position for
  14001. * @param isLocal defines if the position should be set in local space
  14002. */
  14003. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14004. /**
  14005. * Clones the current emitter and returns a copy of it
  14006. * @returns the new emitter
  14007. */
  14008. clone(): MeshParticleEmitter;
  14009. /**
  14010. * Called by the GPUParticleSystem to setup the update shader
  14011. * @param effect defines the update shader
  14012. */
  14013. applyToShader(effect: Effect): void;
  14014. /**
  14015. * Returns a string to use to update the GPU particles update shader
  14016. * @returns a string containng the defines string
  14017. */
  14018. getEffectDefines(): string;
  14019. /**
  14020. * Returns the string "BoxParticleEmitter"
  14021. * @returns a string containing the class name
  14022. */
  14023. getClassName(): string;
  14024. /**
  14025. * Serializes the particle system to a JSON object.
  14026. * @returns the JSON object
  14027. */
  14028. serialize(): any;
  14029. /**
  14030. * Parse properties from a JSON object
  14031. * @param serializationObject defines the JSON object
  14032. * @param scene defines the hosting scene
  14033. */
  14034. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14035. }
  14036. }
  14037. declare module BABYLON {
  14038. /**
  14039. * Interface representing a particle system in Babylon.js.
  14040. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14041. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14042. */
  14043. export interface IParticleSystem {
  14044. /**
  14045. * List of animations used by the particle system.
  14046. */
  14047. animations: Animation[];
  14048. /**
  14049. * The id of the Particle system.
  14050. */
  14051. id: string;
  14052. /**
  14053. * The name of the Particle system.
  14054. */
  14055. name: string;
  14056. /**
  14057. * The emitter represents the Mesh or position we are attaching the particle system to.
  14058. */
  14059. emitter: Nullable<AbstractMesh | Vector3>;
  14060. /**
  14061. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14062. */
  14063. isBillboardBased: boolean;
  14064. /**
  14065. * The rendering group used by the Particle system to chose when to render.
  14066. */
  14067. renderingGroupId: number;
  14068. /**
  14069. * The layer mask we are rendering the particles through.
  14070. */
  14071. layerMask: number;
  14072. /**
  14073. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14074. */
  14075. updateSpeed: number;
  14076. /**
  14077. * The amount of time the particle system is running (depends of the overall update speed).
  14078. */
  14079. targetStopDuration: number;
  14080. /**
  14081. * The texture used to render each particle. (this can be a spritesheet)
  14082. */
  14083. particleTexture: Nullable<BaseTexture>;
  14084. /**
  14085. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14086. */
  14087. blendMode: number;
  14088. /**
  14089. * Minimum life time of emitting particles.
  14090. */
  14091. minLifeTime: number;
  14092. /**
  14093. * Maximum life time of emitting particles.
  14094. */
  14095. maxLifeTime: number;
  14096. /**
  14097. * Minimum Size of emitting particles.
  14098. */
  14099. minSize: number;
  14100. /**
  14101. * Maximum Size of emitting particles.
  14102. */
  14103. maxSize: number;
  14104. /**
  14105. * Minimum scale of emitting particles on X axis.
  14106. */
  14107. minScaleX: number;
  14108. /**
  14109. * Maximum scale of emitting particles on X axis.
  14110. */
  14111. maxScaleX: number;
  14112. /**
  14113. * Minimum scale of emitting particles on Y axis.
  14114. */
  14115. minScaleY: number;
  14116. /**
  14117. * Maximum scale of emitting particles on Y axis.
  14118. */
  14119. maxScaleY: number;
  14120. /**
  14121. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14122. */
  14123. color1: Color4;
  14124. /**
  14125. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14126. */
  14127. color2: Color4;
  14128. /**
  14129. * Color the particle will have at the end of its lifetime.
  14130. */
  14131. colorDead: Color4;
  14132. /**
  14133. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14134. */
  14135. emitRate: number;
  14136. /**
  14137. * You can use gravity if you want to give an orientation to your particles.
  14138. */
  14139. gravity: Vector3;
  14140. /**
  14141. * Minimum power of emitting particles.
  14142. */
  14143. minEmitPower: number;
  14144. /**
  14145. * Maximum power of emitting particles.
  14146. */
  14147. maxEmitPower: number;
  14148. /**
  14149. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14150. */
  14151. minAngularSpeed: number;
  14152. /**
  14153. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14154. */
  14155. maxAngularSpeed: number;
  14156. /**
  14157. * Gets or sets the minimal initial rotation in radians.
  14158. */
  14159. minInitialRotation: number;
  14160. /**
  14161. * Gets or sets the maximal initial rotation in radians.
  14162. */
  14163. maxInitialRotation: number;
  14164. /**
  14165. * The particle emitter type defines the emitter used by the particle system.
  14166. * It can be for example box, sphere, or cone...
  14167. */
  14168. particleEmitterType: Nullable<IParticleEmitterType>;
  14169. /**
  14170. * Defines the delay in milliseconds before starting the system (0 by default)
  14171. */
  14172. startDelay: number;
  14173. /**
  14174. * 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
  14175. */
  14176. preWarmCycles: number;
  14177. /**
  14178. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14179. */
  14180. preWarmStepOffset: number;
  14181. /**
  14182. * 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)
  14183. */
  14184. spriteCellChangeSpeed: number;
  14185. /**
  14186. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14187. */
  14188. startSpriteCellID: number;
  14189. /**
  14190. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14191. */
  14192. endSpriteCellID: number;
  14193. /**
  14194. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14195. */
  14196. spriteCellWidth: number;
  14197. /**
  14198. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14199. */
  14200. spriteCellHeight: number;
  14201. /**
  14202. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14203. */
  14204. spriteRandomStartCell: boolean;
  14205. /**
  14206. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14207. */
  14208. isAnimationSheetEnabled: boolean;
  14209. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14210. translationPivot: Vector2;
  14211. /**
  14212. * Gets or sets a texture used to add random noise to particle positions
  14213. */
  14214. noiseTexture: Nullable<BaseTexture>;
  14215. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14216. noiseStrength: Vector3;
  14217. /**
  14218. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14219. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14220. */
  14221. billboardMode: number;
  14222. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14223. limitVelocityDamping: number;
  14224. /**
  14225. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14226. */
  14227. beginAnimationOnStart: boolean;
  14228. /**
  14229. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14230. */
  14231. beginAnimationFrom: number;
  14232. /**
  14233. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14234. */
  14235. beginAnimationTo: number;
  14236. /**
  14237. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14238. */
  14239. beginAnimationLoop: boolean;
  14240. /**
  14241. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14242. */
  14243. disposeOnStop: boolean;
  14244. /**
  14245. * Specifies if the particles are updated in emitter local space or world space
  14246. */
  14247. isLocal: boolean;
  14248. /** Snippet ID if the particle system was created from the snippet server */
  14249. snippetId: string;
  14250. /** Gets or sets a matrix to use to compute projection */
  14251. defaultProjectionMatrix: Matrix;
  14252. /**
  14253. * Gets the maximum number of particles active at the same time.
  14254. * @returns The max number of active particles.
  14255. */
  14256. getCapacity(): number;
  14257. /**
  14258. * Gets the number of particles active at the same time.
  14259. * @returns The number of active particles.
  14260. */
  14261. getActiveCount(): number;
  14262. /**
  14263. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14264. * @returns True if it has been started, otherwise false.
  14265. */
  14266. isStarted(): boolean;
  14267. /**
  14268. * Animates the particle system for this frame.
  14269. */
  14270. animate(): void;
  14271. /**
  14272. * Renders the particle system in its current state.
  14273. * @returns the current number of particles
  14274. */
  14275. render(): number;
  14276. /**
  14277. * Dispose the particle system and frees its associated resources.
  14278. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14279. */
  14280. dispose(disposeTexture?: boolean): void;
  14281. /**
  14282. * An event triggered when the system is disposed
  14283. */
  14284. onDisposeObservable: Observable<IParticleSystem>;
  14285. /**
  14286. * Clones the particle system.
  14287. * @param name The name of the cloned object
  14288. * @param newEmitter The new emitter to use
  14289. * @returns the cloned particle system
  14290. */
  14291. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14292. /**
  14293. * Serializes the particle system to a JSON object
  14294. * @param serializeTexture defines if the texture must be serialized as well
  14295. * @returns the JSON object
  14296. */
  14297. serialize(serializeTexture: boolean): any;
  14298. /**
  14299. * Rebuild the particle system
  14300. */
  14301. rebuild(): void;
  14302. /** Force the system to rebuild all gradients that need to be resync */
  14303. forceRefreshGradients(): void;
  14304. /**
  14305. * Starts the particle system and begins to emit
  14306. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14307. */
  14308. start(delay?: number): void;
  14309. /**
  14310. * Stops the particle system.
  14311. */
  14312. stop(): void;
  14313. /**
  14314. * Remove all active particles
  14315. */
  14316. reset(): void;
  14317. /**
  14318. * Gets a boolean indicating that the system is stopping
  14319. * @returns true if the system is currently stopping
  14320. */
  14321. isStopping(): boolean;
  14322. /**
  14323. * Is this system ready to be used/rendered
  14324. * @return true if the system is ready
  14325. */
  14326. isReady(): boolean;
  14327. /**
  14328. * Returns the string "ParticleSystem"
  14329. * @returns a string containing the class name
  14330. */
  14331. getClassName(): string;
  14332. /**
  14333. * Gets the custom effect used to render the particles
  14334. * @param blendMode Blend mode for which the effect should be retrieved
  14335. * @returns The effect
  14336. */
  14337. getCustomEffect(blendMode: number): Nullable<Effect>;
  14338. /**
  14339. * Sets the custom effect used to render the particles
  14340. * @param effect The effect to set
  14341. * @param blendMode Blend mode for which the effect should be set
  14342. */
  14343. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14344. /**
  14345. * Fill the defines array according to the current settings of the particle system
  14346. * @param defines Array to be updated
  14347. * @param blendMode blend mode to take into account when updating the array
  14348. */
  14349. fillDefines(defines: Array<string>, blendMode: number): void;
  14350. /**
  14351. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14352. * @param uniforms Uniforms array to fill
  14353. * @param attributes Attributes array to fill
  14354. * @param samplers Samplers array to fill
  14355. */
  14356. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14357. /**
  14358. * Observable that will be called just before the particles are drawn
  14359. */
  14360. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14361. /**
  14362. * Gets the name of the particle vertex shader
  14363. */
  14364. vertexShaderName: string;
  14365. /**
  14366. * Adds a new color gradient
  14367. * @param gradient defines the gradient to use (between 0 and 1)
  14368. * @param color1 defines the color to affect to the specified gradient
  14369. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14370. * @returns the current particle system
  14371. */
  14372. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14373. /**
  14374. * Remove a specific color gradient
  14375. * @param gradient defines the gradient to remove
  14376. * @returns the current particle system
  14377. */
  14378. removeColorGradient(gradient: number): IParticleSystem;
  14379. /**
  14380. * Adds a new size gradient
  14381. * @param gradient defines the gradient to use (between 0 and 1)
  14382. * @param factor defines the size factor to affect to the specified gradient
  14383. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14384. * @returns the current particle system
  14385. */
  14386. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14387. /**
  14388. * Remove a specific size gradient
  14389. * @param gradient defines the gradient to remove
  14390. * @returns the current particle system
  14391. */
  14392. removeSizeGradient(gradient: number): IParticleSystem;
  14393. /**
  14394. * Gets the current list of color gradients.
  14395. * You must use addColorGradient and removeColorGradient to udpate this list
  14396. * @returns the list of color gradients
  14397. */
  14398. getColorGradients(): Nullable<Array<ColorGradient>>;
  14399. /**
  14400. * Gets the current list of size gradients.
  14401. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14402. * @returns the list of size gradients
  14403. */
  14404. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14405. /**
  14406. * Gets the current list of angular speed gradients.
  14407. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14408. * @returns the list of angular speed gradients
  14409. */
  14410. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14411. /**
  14412. * Adds a new angular speed gradient
  14413. * @param gradient defines the gradient to use (between 0 and 1)
  14414. * @param factor defines the angular speed to affect to the specified gradient
  14415. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14416. * @returns the current particle system
  14417. */
  14418. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14419. /**
  14420. * Remove a specific angular speed gradient
  14421. * @param gradient defines the gradient to remove
  14422. * @returns the current particle system
  14423. */
  14424. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14425. /**
  14426. * Gets the current list of velocity gradients.
  14427. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14428. * @returns the list of velocity gradients
  14429. */
  14430. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14431. /**
  14432. * Adds a new velocity gradient
  14433. * @param gradient defines the gradient to use (between 0 and 1)
  14434. * @param factor defines the velocity to affect to the specified gradient
  14435. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14436. * @returns the current particle system
  14437. */
  14438. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14439. /**
  14440. * Remove a specific velocity gradient
  14441. * @param gradient defines the gradient to remove
  14442. * @returns the current particle system
  14443. */
  14444. removeVelocityGradient(gradient: number): IParticleSystem;
  14445. /**
  14446. * Gets the current list of limit velocity gradients.
  14447. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14448. * @returns the list of limit velocity gradients
  14449. */
  14450. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14451. /**
  14452. * Adds a new limit velocity gradient
  14453. * @param gradient defines the gradient to use (between 0 and 1)
  14454. * @param factor defines the limit velocity to affect to the specified gradient
  14455. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14456. * @returns the current particle system
  14457. */
  14458. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14459. /**
  14460. * Remove a specific limit velocity gradient
  14461. * @param gradient defines the gradient to remove
  14462. * @returns the current particle system
  14463. */
  14464. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14465. /**
  14466. * Adds a new drag gradient
  14467. * @param gradient defines the gradient to use (between 0 and 1)
  14468. * @param factor defines the drag to affect to the specified gradient
  14469. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14470. * @returns the current particle system
  14471. */
  14472. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14473. /**
  14474. * Remove a specific drag gradient
  14475. * @param gradient defines the gradient to remove
  14476. * @returns the current particle system
  14477. */
  14478. removeDragGradient(gradient: number): IParticleSystem;
  14479. /**
  14480. * Gets the current list of drag gradients.
  14481. * You must use addDragGradient and removeDragGradient to udpate this list
  14482. * @returns the list of drag gradients
  14483. */
  14484. getDragGradients(): Nullable<Array<FactorGradient>>;
  14485. /**
  14486. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14487. * @param gradient defines the gradient to use (between 0 and 1)
  14488. * @param factor defines the emit rate to affect to the specified gradient
  14489. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14490. * @returns the current particle system
  14491. */
  14492. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14493. /**
  14494. * Remove a specific emit rate gradient
  14495. * @param gradient defines the gradient to remove
  14496. * @returns the current particle system
  14497. */
  14498. removeEmitRateGradient(gradient: number): IParticleSystem;
  14499. /**
  14500. * Gets the current list of emit rate gradients.
  14501. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14502. * @returns the list of emit rate gradients
  14503. */
  14504. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14505. /**
  14506. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14507. * @param gradient defines the gradient to use (between 0 and 1)
  14508. * @param factor defines the start size to affect to the specified gradient
  14509. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14510. * @returns the current particle system
  14511. */
  14512. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14513. /**
  14514. * Remove a specific start size gradient
  14515. * @param gradient defines the gradient to remove
  14516. * @returns the current particle system
  14517. */
  14518. removeStartSizeGradient(gradient: number): IParticleSystem;
  14519. /**
  14520. * Gets the current list of start size gradients.
  14521. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14522. * @returns the list of start size gradients
  14523. */
  14524. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14525. /**
  14526. * Adds a new life time gradient
  14527. * @param gradient defines the gradient to use (between 0 and 1)
  14528. * @param factor defines the life time factor to affect to the specified gradient
  14529. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14530. * @returns the current particle system
  14531. */
  14532. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14533. /**
  14534. * Remove a specific life time gradient
  14535. * @param gradient defines the gradient to remove
  14536. * @returns the current particle system
  14537. */
  14538. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14539. /**
  14540. * Gets the current list of life time gradients.
  14541. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14542. * @returns the list of life time gradients
  14543. */
  14544. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14545. /**
  14546. * Gets the current list of color gradients.
  14547. * You must use addColorGradient and removeColorGradient to udpate this list
  14548. * @returns the list of color gradients
  14549. */
  14550. getColorGradients(): Nullable<Array<ColorGradient>>;
  14551. /**
  14552. * Adds a new ramp gradient used to remap particle colors
  14553. * @param gradient defines the gradient to use (between 0 and 1)
  14554. * @param color defines the color to affect to the specified gradient
  14555. * @returns the current particle system
  14556. */
  14557. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14558. /**
  14559. * Gets the current list of ramp gradients.
  14560. * You must use addRampGradient and removeRampGradient to udpate this list
  14561. * @returns the list of ramp gradients
  14562. */
  14563. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14564. /** Gets or sets a boolean indicating that ramp gradients must be used
  14565. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14566. */
  14567. useRampGradients: boolean;
  14568. /**
  14569. * Adds a new color remap gradient
  14570. * @param gradient defines the gradient to use (between 0 and 1)
  14571. * @param min defines the color remap minimal range
  14572. * @param max defines the color remap maximal range
  14573. * @returns the current particle system
  14574. */
  14575. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14576. /**
  14577. * Gets the current list of color remap gradients.
  14578. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14579. * @returns the list of color remap gradients
  14580. */
  14581. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14582. /**
  14583. * Adds a new alpha remap gradient
  14584. * @param gradient defines the gradient to use (between 0 and 1)
  14585. * @param min defines the alpha remap minimal range
  14586. * @param max defines the alpha remap maximal range
  14587. * @returns the current particle system
  14588. */
  14589. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14590. /**
  14591. * Gets the current list of alpha remap gradients.
  14592. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14593. * @returns the list of alpha remap gradients
  14594. */
  14595. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14596. /**
  14597. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14598. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14599. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14600. * @returns the emitter
  14601. */
  14602. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14603. /**
  14604. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14605. * @param radius The radius of the hemisphere to emit from
  14606. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14607. * @returns the emitter
  14608. */
  14609. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14610. /**
  14611. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14612. * @param radius The radius of the sphere to emit from
  14613. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14614. * @returns the emitter
  14615. */
  14616. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14617. /**
  14618. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14619. * @param radius The radius of the sphere to emit from
  14620. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14621. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14622. * @returns the emitter
  14623. */
  14624. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14625. /**
  14626. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14627. * @param radius The radius of the emission cylinder
  14628. * @param height The height of the emission cylinder
  14629. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14630. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14631. * @returns the emitter
  14632. */
  14633. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14634. /**
  14635. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14636. * @param radius The radius of the cylinder to emit from
  14637. * @param height The height of the emission cylinder
  14638. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14639. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14640. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14641. * @returns the emitter
  14642. */
  14643. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14644. /**
  14645. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14646. * @param radius The radius of the cone to emit from
  14647. * @param angle The base angle of the cone
  14648. * @returns the emitter
  14649. */
  14650. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14651. /**
  14652. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14653. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14654. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14655. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14656. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14657. * @returns the emitter
  14658. */
  14659. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14660. /**
  14661. * Get hosting scene
  14662. * @returns the scene
  14663. */
  14664. getScene(): Nullable<Scene>;
  14665. }
  14666. }
  14667. declare module BABYLON {
  14668. /**
  14669. * 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.
  14670. * @see https://doc.babylonjs.com/how_to/transformnode
  14671. */
  14672. export class TransformNode extends Node {
  14673. /**
  14674. * Object will not rotate to face the camera
  14675. */
  14676. static BILLBOARDMODE_NONE: number;
  14677. /**
  14678. * Object will rotate to face the camera but only on the x axis
  14679. */
  14680. static BILLBOARDMODE_X: number;
  14681. /**
  14682. * Object will rotate to face the camera but only on the y axis
  14683. */
  14684. static BILLBOARDMODE_Y: number;
  14685. /**
  14686. * Object will rotate to face the camera but only on the z axis
  14687. */
  14688. static BILLBOARDMODE_Z: number;
  14689. /**
  14690. * Object will rotate to face the camera
  14691. */
  14692. static BILLBOARDMODE_ALL: number;
  14693. /**
  14694. * Object will rotate to face the camera's position instead of orientation
  14695. */
  14696. static BILLBOARDMODE_USE_POSITION: number;
  14697. private static _TmpRotation;
  14698. private static _TmpScaling;
  14699. private static _TmpTranslation;
  14700. private _forward;
  14701. private _forwardInverted;
  14702. private _up;
  14703. private _right;
  14704. private _rightInverted;
  14705. private _position;
  14706. private _rotation;
  14707. private _rotationQuaternion;
  14708. protected _scaling: Vector3;
  14709. protected _isDirty: boolean;
  14710. private _transformToBoneReferal;
  14711. private _isAbsoluteSynced;
  14712. private _billboardMode;
  14713. /**
  14714. * Gets or sets the billboard mode. Default is 0.
  14715. *
  14716. * | Value | Type | Description |
  14717. * | --- | --- | --- |
  14718. * | 0 | BILLBOARDMODE_NONE | |
  14719. * | 1 | BILLBOARDMODE_X | |
  14720. * | 2 | BILLBOARDMODE_Y | |
  14721. * | 4 | BILLBOARDMODE_Z | |
  14722. * | 7 | BILLBOARDMODE_ALL | |
  14723. *
  14724. */
  14725. get billboardMode(): number;
  14726. set billboardMode(value: number);
  14727. private _preserveParentRotationForBillboard;
  14728. /**
  14729. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14730. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14731. */
  14732. get preserveParentRotationForBillboard(): boolean;
  14733. set preserveParentRotationForBillboard(value: boolean);
  14734. /**
  14735. * 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
  14736. */
  14737. scalingDeterminant: number;
  14738. private _infiniteDistance;
  14739. /**
  14740. * Gets or sets the distance of the object to max, often used by skybox
  14741. */
  14742. get infiniteDistance(): boolean;
  14743. set infiniteDistance(value: boolean);
  14744. /**
  14745. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14746. * By default the system will update normals to compensate
  14747. */
  14748. ignoreNonUniformScaling: boolean;
  14749. /**
  14750. * 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
  14751. */
  14752. reIntegrateRotationIntoRotationQuaternion: boolean;
  14753. /** @hidden */
  14754. _poseMatrix: Nullable<Matrix>;
  14755. /** @hidden */
  14756. _localMatrix: Matrix;
  14757. private _usePivotMatrix;
  14758. private _absolutePosition;
  14759. private _absoluteScaling;
  14760. private _absoluteRotationQuaternion;
  14761. private _pivotMatrix;
  14762. private _pivotMatrixInverse;
  14763. /** @hidden */
  14764. _postMultiplyPivotMatrix: boolean;
  14765. protected _isWorldMatrixFrozen: boolean;
  14766. /** @hidden */
  14767. _indexInSceneTransformNodesArray: number;
  14768. /**
  14769. * An event triggered after the world matrix is updated
  14770. */
  14771. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14772. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14773. /**
  14774. * Gets a string identifying the name of the class
  14775. * @returns "TransformNode" string
  14776. */
  14777. getClassName(): string;
  14778. /**
  14779. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14780. */
  14781. get position(): Vector3;
  14782. set position(newPosition: Vector3);
  14783. /**
  14784. * 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)).
  14785. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14786. */
  14787. get rotation(): Vector3;
  14788. set rotation(newRotation: Vector3);
  14789. /**
  14790. * 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)).
  14791. */
  14792. get scaling(): Vector3;
  14793. set scaling(newScaling: Vector3);
  14794. /**
  14795. * 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).
  14796. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14797. */
  14798. get rotationQuaternion(): Nullable<Quaternion>;
  14799. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14800. /**
  14801. * The forward direction of that transform in world space.
  14802. */
  14803. get forward(): Vector3;
  14804. /**
  14805. * The up direction of that transform in world space.
  14806. */
  14807. get up(): Vector3;
  14808. /**
  14809. * The right direction of that transform in world space.
  14810. */
  14811. get right(): Vector3;
  14812. /**
  14813. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14814. * @param matrix the matrix to copy the pose from
  14815. * @returns this TransformNode.
  14816. */
  14817. updatePoseMatrix(matrix: Matrix): TransformNode;
  14818. /**
  14819. * Returns the mesh Pose matrix.
  14820. * @returns the pose matrix
  14821. */
  14822. getPoseMatrix(): Matrix;
  14823. /** @hidden */
  14824. _isSynchronized(): boolean;
  14825. /** @hidden */
  14826. _initCache(): void;
  14827. /**
  14828. * Flag the transform node as dirty (Forcing it to update everything)
  14829. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14830. * @returns this transform node
  14831. */
  14832. markAsDirty(property: string): TransformNode;
  14833. /**
  14834. * Returns the current mesh absolute position.
  14835. * Returns a Vector3.
  14836. */
  14837. get absolutePosition(): Vector3;
  14838. /**
  14839. * Returns the current mesh absolute scaling.
  14840. * Returns a Vector3.
  14841. */
  14842. get absoluteScaling(): Vector3;
  14843. /**
  14844. * Returns the current mesh absolute rotation.
  14845. * Returns a Quaternion.
  14846. */
  14847. get absoluteRotationQuaternion(): Quaternion;
  14848. /**
  14849. * Sets a new matrix to apply before all other transformation
  14850. * @param matrix defines the transform matrix
  14851. * @returns the current TransformNode
  14852. */
  14853. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14854. /**
  14855. * Sets a new pivot matrix to the current node
  14856. * @param matrix defines the new pivot matrix to use
  14857. * @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
  14858. * @returns the current TransformNode
  14859. */
  14860. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14861. /**
  14862. * Returns the mesh pivot matrix.
  14863. * Default : Identity.
  14864. * @returns the matrix
  14865. */
  14866. getPivotMatrix(): Matrix;
  14867. /**
  14868. * Instantiate (when possible) or clone that node with its hierarchy
  14869. * @param newParent defines the new parent to use for the instance (or clone)
  14870. * @param options defines options to configure how copy is done
  14871. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14872. * @returns an instance (or a clone) of the current node with its hiearchy
  14873. */
  14874. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14875. doNotInstantiate: boolean;
  14876. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14877. /**
  14878. * Prevents the World matrix to be computed any longer
  14879. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14880. * @returns the TransformNode.
  14881. */
  14882. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14883. /**
  14884. * Allows back the World matrix computation.
  14885. * @returns the TransformNode.
  14886. */
  14887. unfreezeWorldMatrix(): this;
  14888. /**
  14889. * True if the World matrix has been frozen.
  14890. */
  14891. get isWorldMatrixFrozen(): boolean;
  14892. /**
  14893. * Retuns the mesh absolute position in the World.
  14894. * @returns a Vector3.
  14895. */
  14896. getAbsolutePosition(): Vector3;
  14897. /**
  14898. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14899. * @param absolutePosition the absolute position to set
  14900. * @returns the TransformNode.
  14901. */
  14902. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14903. /**
  14904. * Sets the mesh position in its local space.
  14905. * @param vector3 the position to set in localspace
  14906. * @returns the TransformNode.
  14907. */
  14908. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14909. /**
  14910. * Returns the mesh position in the local space from the current World matrix values.
  14911. * @returns a new Vector3.
  14912. */
  14913. getPositionExpressedInLocalSpace(): Vector3;
  14914. /**
  14915. * Translates the mesh along the passed Vector3 in its local space.
  14916. * @param vector3 the distance to translate in localspace
  14917. * @returns the TransformNode.
  14918. */
  14919. locallyTranslate(vector3: Vector3): TransformNode;
  14920. private static _lookAtVectorCache;
  14921. /**
  14922. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14923. * @param targetPoint the position (must be in same space as current mesh) to look at
  14924. * @param yawCor optional yaw (y-axis) correction in radians
  14925. * @param pitchCor optional pitch (x-axis) correction in radians
  14926. * @param rollCor optional roll (z-axis) correction in radians
  14927. * @param space the choosen space of the target
  14928. * @returns the TransformNode.
  14929. */
  14930. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14931. /**
  14932. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14933. * This Vector3 is expressed in the World space.
  14934. * @param localAxis axis to rotate
  14935. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14936. */
  14937. getDirection(localAxis: Vector3): Vector3;
  14938. /**
  14939. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14940. * localAxis is expressed in the mesh local space.
  14941. * result is computed in the Wordl space from the mesh World matrix.
  14942. * @param localAxis axis to rotate
  14943. * @param result the resulting transformnode
  14944. * @returns this TransformNode.
  14945. */
  14946. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14947. /**
  14948. * Sets this transform node rotation to the given local axis.
  14949. * @param localAxis the axis in local space
  14950. * @param yawCor optional yaw (y-axis) correction in radians
  14951. * @param pitchCor optional pitch (x-axis) correction in radians
  14952. * @param rollCor optional roll (z-axis) correction in radians
  14953. * @returns this TransformNode
  14954. */
  14955. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14956. /**
  14957. * Sets a new pivot point to the current node
  14958. * @param point defines the new pivot point to use
  14959. * @param space defines if the point is in world or local space (local by default)
  14960. * @returns the current TransformNode
  14961. */
  14962. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14963. /**
  14964. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14965. * @returns the pivot point
  14966. */
  14967. getPivotPoint(): Vector3;
  14968. /**
  14969. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14970. * @param result the vector3 to store the result
  14971. * @returns this TransformNode.
  14972. */
  14973. getPivotPointToRef(result: Vector3): TransformNode;
  14974. /**
  14975. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14976. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14977. */
  14978. getAbsolutePivotPoint(): Vector3;
  14979. /**
  14980. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14981. * @param result vector3 to store the result
  14982. * @returns this TransformNode.
  14983. */
  14984. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14985. /**
  14986. * Defines the passed node as the parent of the current node.
  14987. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14988. * @see https://doc.babylonjs.com/how_to/parenting
  14989. * @param node the node ot set as the parent
  14990. * @returns this TransformNode.
  14991. */
  14992. setParent(node: Nullable<Node>): TransformNode;
  14993. private _nonUniformScaling;
  14994. /**
  14995. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14996. */
  14997. get nonUniformScaling(): boolean;
  14998. /** @hidden */
  14999. _updateNonUniformScalingState(value: boolean): boolean;
  15000. /**
  15001. * Attach the current TransformNode to another TransformNode associated with a bone
  15002. * @param bone Bone affecting the TransformNode
  15003. * @param affectedTransformNode TransformNode associated with the bone
  15004. * @returns this object
  15005. */
  15006. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15007. /**
  15008. * Detach the transform node if its associated with a bone
  15009. * @returns this object
  15010. */
  15011. detachFromBone(): TransformNode;
  15012. private static _rotationAxisCache;
  15013. /**
  15014. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15015. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15016. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15017. * The passed axis is also normalized.
  15018. * @param axis the axis to rotate around
  15019. * @param amount the amount to rotate in radians
  15020. * @param space Space to rotate in (Default: local)
  15021. * @returns the TransformNode.
  15022. */
  15023. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15024. /**
  15025. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15026. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15027. * The passed axis is also normalized. .
  15028. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15029. * @param point the point to rotate around
  15030. * @param axis the axis to rotate around
  15031. * @param amount the amount to rotate in radians
  15032. * @returns the TransformNode
  15033. */
  15034. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15035. /**
  15036. * Translates the mesh along the axis vector for the passed distance in the given space.
  15037. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15038. * @param axis the axis to translate in
  15039. * @param distance the distance to translate
  15040. * @param space Space to rotate in (Default: local)
  15041. * @returns the TransformNode.
  15042. */
  15043. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15044. /**
  15045. * Adds a rotation step to the mesh current rotation.
  15046. * x, y, z are Euler angles expressed in radians.
  15047. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15048. * This means this rotation is made in the mesh local space only.
  15049. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15050. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15051. * ```javascript
  15052. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15053. * ```
  15054. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15055. * 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.
  15056. * @param x Rotation to add
  15057. * @param y Rotation to add
  15058. * @param z Rotation to add
  15059. * @returns the TransformNode.
  15060. */
  15061. addRotation(x: number, y: number, z: number): TransformNode;
  15062. /**
  15063. * @hidden
  15064. */
  15065. protected _getEffectiveParent(): Nullable<Node>;
  15066. /**
  15067. * Computes the world matrix of the node
  15068. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15069. * @returns the world matrix
  15070. */
  15071. computeWorldMatrix(force?: boolean): Matrix;
  15072. /**
  15073. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15074. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15075. */
  15076. resetLocalMatrix(independentOfChildren?: boolean): void;
  15077. protected _afterComputeWorldMatrix(): void;
  15078. /**
  15079. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15080. * @param func callback function to add
  15081. *
  15082. * @returns the TransformNode.
  15083. */
  15084. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15085. /**
  15086. * Removes a registered callback function.
  15087. * @param func callback function to remove
  15088. * @returns the TransformNode.
  15089. */
  15090. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15091. /**
  15092. * Gets the position of the current mesh in camera space
  15093. * @param camera defines the camera to use
  15094. * @returns a position
  15095. */
  15096. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15097. /**
  15098. * Returns the distance from the mesh to the active camera
  15099. * @param camera defines the camera to use
  15100. * @returns the distance
  15101. */
  15102. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15103. /**
  15104. * Clone the current transform node
  15105. * @param name Name of the new clone
  15106. * @param newParent New parent for the clone
  15107. * @param doNotCloneChildren Do not clone children hierarchy
  15108. * @returns the new transform node
  15109. */
  15110. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15111. /**
  15112. * Serializes the objects information.
  15113. * @param currentSerializationObject defines the object to serialize in
  15114. * @returns the serialized object
  15115. */
  15116. serialize(currentSerializationObject?: any): any;
  15117. /**
  15118. * Returns a new TransformNode object parsed from the source provided.
  15119. * @param parsedTransformNode is the source.
  15120. * @param scene the scne the object belongs to
  15121. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15122. * @returns a new TransformNode object parsed from the source provided.
  15123. */
  15124. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15125. /**
  15126. * Get all child-transformNodes of this node
  15127. * @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
  15128. * @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
  15129. * @returns an array of TransformNode
  15130. */
  15131. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15132. /**
  15133. * Releases resources associated with this transform node.
  15134. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15135. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15136. */
  15137. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15138. /**
  15139. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15140. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15141. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15142. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15143. * @returns the current mesh
  15144. */
  15145. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15146. private _syncAbsoluteScalingAndRotation;
  15147. }
  15148. }
  15149. declare module BABYLON {
  15150. /**
  15151. * Class used to override all child animations of a given target
  15152. */
  15153. export class AnimationPropertiesOverride {
  15154. /**
  15155. * Gets or sets a value indicating if animation blending must be used
  15156. */
  15157. enableBlending: boolean;
  15158. /**
  15159. * Gets or sets the blending speed to use when enableBlending is true
  15160. */
  15161. blendingSpeed: number;
  15162. /**
  15163. * Gets or sets the default loop mode to use
  15164. */
  15165. loopMode: number;
  15166. }
  15167. }
  15168. declare module BABYLON {
  15169. /**
  15170. * Class used to store bone information
  15171. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15172. */
  15173. export class Bone extends Node {
  15174. /**
  15175. * defines the bone name
  15176. */
  15177. name: string;
  15178. private static _tmpVecs;
  15179. private static _tmpQuat;
  15180. private static _tmpMats;
  15181. /**
  15182. * Gets the list of child bones
  15183. */
  15184. children: Bone[];
  15185. /** Gets the animations associated with this bone */
  15186. animations: Animation[];
  15187. /**
  15188. * Gets or sets bone length
  15189. */
  15190. length: number;
  15191. /**
  15192. * @hidden Internal only
  15193. * Set this value to map this bone to a different index in the transform matrices
  15194. * Set this value to -1 to exclude the bone from the transform matrices
  15195. */
  15196. _index: Nullable<number>;
  15197. private _skeleton;
  15198. private _localMatrix;
  15199. private _restPose;
  15200. private _bindPose;
  15201. private _baseMatrix;
  15202. private _absoluteTransform;
  15203. private _invertedAbsoluteTransform;
  15204. private _parent;
  15205. private _scalingDeterminant;
  15206. private _worldTransform;
  15207. private _localScaling;
  15208. private _localRotation;
  15209. private _localPosition;
  15210. private _needToDecompose;
  15211. private _needToCompose;
  15212. /** @hidden */
  15213. _linkedTransformNode: Nullable<TransformNode>;
  15214. /** @hidden */
  15215. _waitingTransformNodeId: Nullable<string>;
  15216. /** @hidden */
  15217. get _matrix(): Matrix;
  15218. /** @hidden */
  15219. set _matrix(value: Matrix);
  15220. /**
  15221. * Create a new bone
  15222. * @param name defines the bone name
  15223. * @param skeleton defines the parent skeleton
  15224. * @param parentBone defines the parent (can be null if the bone is the root)
  15225. * @param localMatrix defines the local matrix
  15226. * @param restPose defines the rest pose matrix
  15227. * @param baseMatrix defines the base matrix
  15228. * @param index defines index of the bone in the hiearchy
  15229. */
  15230. constructor(
  15231. /**
  15232. * defines the bone name
  15233. */
  15234. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15235. /**
  15236. * Gets the current object class name.
  15237. * @return the class name
  15238. */
  15239. getClassName(): string;
  15240. /**
  15241. * Gets the parent skeleton
  15242. * @returns a skeleton
  15243. */
  15244. getSkeleton(): Skeleton;
  15245. /**
  15246. * Gets parent bone
  15247. * @returns a bone or null if the bone is the root of the bone hierarchy
  15248. */
  15249. getParent(): Nullable<Bone>;
  15250. /**
  15251. * Returns an array containing the root bones
  15252. * @returns an array containing the root bones
  15253. */
  15254. getChildren(): Array<Bone>;
  15255. /**
  15256. * Gets the node index in matrix array generated for rendering
  15257. * @returns the node index
  15258. */
  15259. getIndex(): number;
  15260. /**
  15261. * Sets the parent bone
  15262. * @param parent defines the parent (can be null if the bone is the root)
  15263. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15264. */
  15265. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15266. /**
  15267. * Gets the local matrix
  15268. * @returns a matrix
  15269. */
  15270. getLocalMatrix(): Matrix;
  15271. /**
  15272. * Gets the base matrix (initial matrix which remains unchanged)
  15273. * @returns a matrix
  15274. */
  15275. getBaseMatrix(): Matrix;
  15276. /**
  15277. * Gets the rest pose matrix
  15278. * @returns a matrix
  15279. */
  15280. getRestPose(): Matrix;
  15281. /**
  15282. * Sets the rest pose matrix
  15283. * @param matrix the local-space rest pose to set for this bone
  15284. */
  15285. setRestPose(matrix: Matrix): void;
  15286. /**
  15287. * Gets the bind pose matrix
  15288. * @returns the bind pose matrix
  15289. */
  15290. getBindPose(): Matrix;
  15291. /**
  15292. * Sets the bind pose matrix
  15293. * @param matrix the local-space bind pose to set for this bone
  15294. */
  15295. setBindPose(matrix: Matrix): void;
  15296. /**
  15297. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15298. */
  15299. getWorldMatrix(): Matrix;
  15300. /**
  15301. * Sets the local matrix to rest pose matrix
  15302. */
  15303. returnToRest(): void;
  15304. /**
  15305. * Gets the inverse of the absolute transform matrix.
  15306. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15307. * @returns a matrix
  15308. */
  15309. getInvertedAbsoluteTransform(): Matrix;
  15310. /**
  15311. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15312. * @returns a matrix
  15313. */
  15314. getAbsoluteTransform(): Matrix;
  15315. /**
  15316. * Links with the given transform node.
  15317. * The local matrix of this bone is copied from the transform node every frame.
  15318. * @param transformNode defines the transform node to link to
  15319. */
  15320. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15321. /**
  15322. * Gets the node used to drive the bone's transformation
  15323. * @returns a transform node or null
  15324. */
  15325. getTransformNode(): Nullable<TransformNode>;
  15326. /** Gets or sets current position (in local space) */
  15327. get position(): Vector3;
  15328. set position(newPosition: Vector3);
  15329. /** Gets or sets current rotation (in local space) */
  15330. get rotation(): Vector3;
  15331. set rotation(newRotation: Vector3);
  15332. /** Gets or sets current rotation quaternion (in local space) */
  15333. get rotationQuaternion(): Quaternion;
  15334. set rotationQuaternion(newRotation: Quaternion);
  15335. /** Gets or sets current scaling (in local space) */
  15336. get scaling(): Vector3;
  15337. set scaling(newScaling: Vector3);
  15338. /**
  15339. * Gets the animation properties override
  15340. */
  15341. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15342. private _decompose;
  15343. private _compose;
  15344. /**
  15345. * Update the base and local matrices
  15346. * @param matrix defines the new base or local matrix
  15347. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15348. * @param updateLocalMatrix defines if the local matrix should be updated
  15349. */
  15350. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15351. /** @hidden */
  15352. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15353. /**
  15354. * Flag the bone as dirty (Forcing it to update everything)
  15355. */
  15356. markAsDirty(): void;
  15357. /** @hidden */
  15358. _markAsDirtyAndCompose(): void;
  15359. private _markAsDirtyAndDecompose;
  15360. /**
  15361. * Translate the bone in local or world space
  15362. * @param vec The amount to translate the bone
  15363. * @param space The space that the translation is in
  15364. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15365. */
  15366. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15367. /**
  15368. * Set the postion of the bone in local or world space
  15369. * @param position The position to set the bone
  15370. * @param space The space that the position is in
  15371. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15372. */
  15373. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15374. /**
  15375. * Set the absolute position of the bone (world space)
  15376. * @param position The position to set the bone
  15377. * @param mesh The mesh that this bone is attached to
  15378. */
  15379. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15380. /**
  15381. * Scale the bone on the x, y and z axes (in local space)
  15382. * @param x The amount to scale the bone on the x axis
  15383. * @param y The amount to scale the bone on the y axis
  15384. * @param z The amount to scale the bone on the z axis
  15385. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15386. */
  15387. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15388. /**
  15389. * Set the bone scaling in local space
  15390. * @param scale defines the scaling vector
  15391. */
  15392. setScale(scale: Vector3): void;
  15393. /**
  15394. * Gets the current scaling in local space
  15395. * @returns the current scaling vector
  15396. */
  15397. getScale(): Vector3;
  15398. /**
  15399. * Gets the current scaling in local space and stores it in a target vector
  15400. * @param result defines the target vector
  15401. */
  15402. getScaleToRef(result: Vector3): void;
  15403. /**
  15404. * Set the yaw, pitch, and roll of the bone in local or world space
  15405. * @param yaw The rotation of the bone on the y axis
  15406. * @param pitch The rotation of the bone on the x axis
  15407. * @param roll The rotation of the bone on the z axis
  15408. * @param space The space that the axes of rotation are in
  15409. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15410. */
  15411. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15412. /**
  15413. * Add a rotation to the bone on an axis in local or world space
  15414. * @param axis The axis to rotate the bone on
  15415. * @param amount The amount to rotate the bone
  15416. * @param space The space that the axis is in
  15417. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15418. */
  15419. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15420. /**
  15421. * Set the rotation of the bone to a particular axis angle in local or world space
  15422. * @param axis The axis to rotate the bone on
  15423. * @param angle The angle that the bone should be rotated to
  15424. * @param space The space that the axis is in
  15425. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15426. */
  15427. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15428. /**
  15429. * Set the euler rotation of the bone in local or world space
  15430. * @param rotation The euler rotation that the bone should be set to
  15431. * @param space The space that the rotation is in
  15432. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15433. */
  15434. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15435. /**
  15436. * Set the quaternion rotation of the bone in local or world space
  15437. * @param quat The quaternion rotation that the bone should be set to
  15438. * @param space The space that the rotation is in
  15439. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15440. */
  15441. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15442. /**
  15443. * Set the rotation matrix of the bone in local or world space
  15444. * @param rotMat The rotation matrix that the bone should be set to
  15445. * @param space The space that the rotation is in
  15446. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15447. */
  15448. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15449. private _rotateWithMatrix;
  15450. private _getNegativeRotationToRef;
  15451. /**
  15452. * Get the position of the bone in local or world space
  15453. * @param space The space that the returned position is in
  15454. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15455. * @returns The position of the bone
  15456. */
  15457. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15458. /**
  15459. * Copy the position of the bone to a vector3 in local or world space
  15460. * @param space The space that the returned position is in
  15461. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15462. * @param result The vector3 to copy the position to
  15463. */
  15464. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15465. /**
  15466. * Get the absolute position of the bone (world space)
  15467. * @param mesh The mesh that this bone is attached to
  15468. * @returns The absolute position of the bone
  15469. */
  15470. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15471. /**
  15472. * Copy the absolute position of the bone (world space) to the result param
  15473. * @param mesh The mesh that this bone is attached to
  15474. * @param result The vector3 to copy the absolute position to
  15475. */
  15476. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15477. /**
  15478. * Compute the absolute transforms of this bone and its children
  15479. */
  15480. computeAbsoluteTransforms(): void;
  15481. /**
  15482. * Get the world direction from an axis that is in the local space of the bone
  15483. * @param localAxis The local direction that is used to compute the world direction
  15484. * @param mesh The mesh that this bone is attached to
  15485. * @returns The world direction
  15486. */
  15487. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15488. /**
  15489. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15490. * @param localAxis The local direction that is used to compute the world direction
  15491. * @param mesh The mesh that this bone is attached to
  15492. * @param result The vector3 that the world direction will be copied to
  15493. */
  15494. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15495. /**
  15496. * Get the euler rotation of the bone in local or world space
  15497. * @param space The space that the rotation should be in
  15498. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15499. * @returns The euler rotation
  15500. */
  15501. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15502. /**
  15503. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15504. * @param space The space that the rotation should be in
  15505. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15506. * @param result The vector3 that the rotation should be copied to
  15507. */
  15508. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15509. /**
  15510. * Get the quaternion rotation of the bone in either local or world space
  15511. * @param space The space that the rotation should be in
  15512. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15513. * @returns The quaternion rotation
  15514. */
  15515. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15516. /**
  15517. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15518. * @param space The space that the rotation should be in
  15519. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15520. * @param result The quaternion that the rotation should be copied to
  15521. */
  15522. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15523. /**
  15524. * Get the rotation matrix of the bone in local or world space
  15525. * @param space The space that the rotation should be in
  15526. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15527. * @returns The rotation matrix
  15528. */
  15529. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15530. /**
  15531. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15532. * @param space The space that the rotation should be in
  15533. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15534. * @param result The quaternion that the rotation should be copied to
  15535. */
  15536. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15537. /**
  15538. * Get the world position of a point that is in the local space of the bone
  15539. * @param position The local position
  15540. * @param mesh The mesh that this bone is attached to
  15541. * @returns The world position
  15542. */
  15543. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15544. /**
  15545. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15546. * @param position The local position
  15547. * @param mesh The mesh that this bone is attached to
  15548. * @param result The vector3 that the world position should be copied to
  15549. */
  15550. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15551. /**
  15552. * Get the local position of a point that is in world space
  15553. * @param position The world position
  15554. * @param mesh The mesh that this bone is attached to
  15555. * @returns The local position
  15556. */
  15557. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15558. /**
  15559. * Get the local position of a point that is in world space and copy it to the result param
  15560. * @param position The world position
  15561. * @param mesh The mesh that this bone is attached to
  15562. * @param result The vector3 that the local position should be copied to
  15563. */
  15564. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15565. /**
  15566. * Set the current local matrix as the restPose for this bone.
  15567. */
  15568. setCurrentPoseAsRest(): void;
  15569. }
  15570. }
  15571. declare module BABYLON {
  15572. /**
  15573. * Defines a runtime animation
  15574. */
  15575. export class RuntimeAnimation {
  15576. private _events;
  15577. /**
  15578. * The current frame of the runtime animation
  15579. */
  15580. private _currentFrame;
  15581. /**
  15582. * The animation used by the runtime animation
  15583. */
  15584. private _animation;
  15585. /**
  15586. * The target of the runtime animation
  15587. */
  15588. private _target;
  15589. /**
  15590. * The initiating animatable
  15591. */
  15592. private _host;
  15593. /**
  15594. * The original value of the runtime animation
  15595. */
  15596. private _originalValue;
  15597. /**
  15598. * The original blend value of the runtime animation
  15599. */
  15600. private _originalBlendValue;
  15601. /**
  15602. * The offsets cache of the runtime animation
  15603. */
  15604. private _offsetsCache;
  15605. /**
  15606. * The high limits cache of the runtime animation
  15607. */
  15608. private _highLimitsCache;
  15609. /**
  15610. * Specifies if the runtime animation has been stopped
  15611. */
  15612. private _stopped;
  15613. /**
  15614. * The blending factor of the runtime animation
  15615. */
  15616. private _blendingFactor;
  15617. /**
  15618. * The BabylonJS scene
  15619. */
  15620. private _scene;
  15621. /**
  15622. * The current value of the runtime animation
  15623. */
  15624. private _currentValue;
  15625. /** @hidden */
  15626. _animationState: _IAnimationState;
  15627. /**
  15628. * The active target of the runtime animation
  15629. */
  15630. private _activeTargets;
  15631. private _currentActiveTarget;
  15632. private _directTarget;
  15633. /**
  15634. * The target path of the runtime animation
  15635. */
  15636. private _targetPath;
  15637. /**
  15638. * The weight of the runtime animation
  15639. */
  15640. private _weight;
  15641. /**
  15642. * The ratio offset of the runtime animation
  15643. */
  15644. private _ratioOffset;
  15645. /**
  15646. * The previous delay of the runtime animation
  15647. */
  15648. private _previousDelay;
  15649. /**
  15650. * The previous ratio of the runtime animation
  15651. */
  15652. private _previousRatio;
  15653. private _enableBlending;
  15654. private _keys;
  15655. private _minFrame;
  15656. private _maxFrame;
  15657. private _minValue;
  15658. private _maxValue;
  15659. private _targetIsArray;
  15660. /**
  15661. * Gets the current frame of the runtime animation
  15662. */
  15663. get currentFrame(): number;
  15664. /**
  15665. * Gets the weight of the runtime animation
  15666. */
  15667. get weight(): number;
  15668. /**
  15669. * Gets the current value of the runtime animation
  15670. */
  15671. get currentValue(): any;
  15672. /**
  15673. * Gets the target path of the runtime animation
  15674. */
  15675. get targetPath(): string;
  15676. /**
  15677. * Gets the actual target of the runtime animation
  15678. */
  15679. get target(): any;
  15680. /**
  15681. * Gets the additive state of the runtime animation
  15682. */
  15683. get isAdditive(): boolean;
  15684. /** @hidden */
  15685. _onLoop: () => void;
  15686. /**
  15687. * Create a new RuntimeAnimation object
  15688. * @param target defines the target of the animation
  15689. * @param animation defines the source animation object
  15690. * @param scene defines the hosting scene
  15691. * @param host defines the initiating Animatable
  15692. */
  15693. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15694. private _preparePath;
  15695. /**
  15696. * Gets the animation from the runtime animation
  15697. */
  15698. get animation(): Animation;
  15699. /**
  15700. * Resets the runtime animation to the beginning
  15701. * @param restoreOriginal defines whether to restore the target property to the original value
  15702. */
  15703. reset(restoreOriginal?: boolean): void;
  15704. /**
  15705. * Specifies if the runtime animation is stopped
  15706. * @returns Boolean specifying if the runtime animation is stopped
  15707. */
  15708. isStopped(): boolean;
  15709. /**
  15710. * Disposes of the runtime animation
  15711. */
  15712. dispose(): void;
  15713. /**
  15714. * Apply the interpolated value to the target
  15715. * @param currentValue defines the value computed by the animation
  15716. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15717. */
  15718. setValue(currentValue: any, weight: number): void;
  15719. private _getOriginalValues;
  15720. private _setValue;
  15721. /**
  15722. * Gets the loop pmode of the runtime animation
  15723. * @returns Loop Mode
  15724. */
  15725. private _getCorrectLoopMode;
  15726. /**
  15727. * Move the current animation to a given frame
  15728. * @param frame defines the frame to move to
  15729. */
  15730. goToFrame(frame: number): void;
  15731. /**
  15732. * @hidden Internal use only
  15733. */
  15734. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15735. /**
  15736. * Execute the current animation
  15737. * @param delay defines the delay to add to the current frame
  15738. * @param from defines the lower bound of the animation range
  15739. * @param to defines the upper bound of the animation range
  15740. * @param loop defines if the current animation must loop
  15741. * @param speedRatio defines the current speed ratio
  15742. * @param weight defines the weight of the animation (default is -1 so no weight)
  15743. * @param onLoop optional callback called when animation loops
  15744. * @returns a boolean indicating if the animation is running
  15745. */
  15746. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15747. }
  15748. }
  15749. declare module BABYLON {
  15750. /**
  15751. * Class used to store an actual running animation
  15752. */
  15753. export class Animatable {
  15754. /** defines the target object */
  15755. target: any;
  15756. /** defines the starting frame number (default is 0) */
  15757. fromFrame: number;
  15758. /** defines the ending frame number (default is 100) */
  15759. toFrame: number;
  15760. /** defines if the animation must loop (default is false) */
  15761. loopAnimation: boolean;
  15762. /** defines a callback to call when animation ends if it is not looping */
  15763. onAnimationEnd?: (() => void) | null | undefined;
  15764. /** defines a callback to call when animation loops */
  15765. onAnimationLoop?: (() => void) | null | undefined;
  15766. /** defines whether the animation should be evaluated additively */
  15767. isAdditive: boolean;
  15768. private _localDelayOffset;
  15769. private _pausedDelay;
  15770. private _runtimeAnimations;
  15771. private _paused;
  15772. private _scene;
  15773. private _speedRatio;
  15774. private _weight;
  15775. private _syncRoot;
  15776. /**
  15777. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15778. * This will only apply for non looping animation (default is true)
  15779. */
  15780. disposeOnEnd: boolean;
  15781. /**
  15782. * Gets a boolean indicating if the animation has started
  15783. */
  15784. animationStarted: boolean;
  15785. /**
  15786. * Observer raised when the animation ends
  15787. */
  15788. onAnimationEndObservable: Observable<Animatable>;
  15789. /**
  15790. * Observer raised when the animation loops
  15791. */
  15792. onAnimationLoopObservable: Observable<Animatable>;
  15793. /**
  15794. * Gets the root Animatable used to synchronize and normalize animations
  15795. */
  15796. get syncRoot(): Nullable<Animatable>;
  15797. /**
  15798. * Gets the current frame of the first RuntimeAnimation
  15799. * Used to synchronize Animatables
  15800. */
  15801. get masterFrame(): number;
  15802. /**
  15803. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15804. */
  15805. get weight(): number;
  15806. set weight(value: number);
  15807. /**
  15808. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15809. */
  15810. get speedRatio(): number;
  15811. set speedRatio(value: number);
  15812. /**
  15813. * Creates a new Animatable
  15814. * @param scene defines the hosting scene
  15815. * @param target defines the target object
  15816. * @param fromFrame defines the starting frame number (default is 0)
  15817. * @param toFrame defines the ending frame number (default is 100)
  15818. * @param loopAnimation defines if the animation must loop (default is false)
  15819. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15820. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15821. * @param animations defines a group of animation to add to the new Animatable
  15822. * @param onAnimationLoop defines a callback to call when animation loops
  15823. * @param isAdditive defines whether the animation should be evaluated additively
  15824. */
  15825. constructor(scene: Scene,
  15826. /** defines the target object */
  15827. target: any,
  15828. /** defines the starting frame number (default is 0) */
  15829. fromFrame?: number,
  15830. /** defines the ending frame number (default is 100) */
  15831. toFrame?: number,
  15832. /** defines if the animation must loop (default is false) */
  15833. loopAnimation?: boolean, speedRatio?: number,
  15834. /** defines a callback to call when animation ends if it is not looping */
  15835. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15836. /** defines a callback to call when animation loops */
  15837. onAnimationLoop?: (() => void) | null | undefined,
  15838. /** defines whether the animation should be evaluated additively */
  15839. isAdditive?: boolean);
  15840. /**
  15841. * Synchronize and normalize current Animatable with a source Animatable
  15842. * This is useful when using animation weights and when animations are not of the same length
  15843. * @param root defines the root Animatable to synchronize with
  15844. * @returns the current Animatable
  15845. */
  15846. syncWith(root: Animatable): Animatable;
  15847. /**
  15848. * Gets the list of runtime animations
  15849. * @returns an array of RuntimeAnimation
  15850. */
  15851. getAnimations(): RuntimeAnimation[];
  15852. /**
  15853. * Adds more animations to the current animatable
  15854. * @param target defines the target of the animations
  15855. * @param animations defines the new animations to add
  15856. */
  15857. appendAnimations(target: any, animations: Animation[]): void;
  15858. /**
  15859. * Gets the source animation for a specific property
  15860. * @param property defines the propertyu to look for
  15861. * @returns null or the source animation for the given property
  15862. */
  15863. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15864. /**
  15865. * Gets the runtime animation for a specific property
  15866. * @param property defines the propertyu to look for
  15867. * @returns null or the runtime animation for the given property
  15868. */
  15869. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15870. /**
  15871. * Resets the animatable to its original state
  15872. */
  15873. reset(): void;
  15874. /**
  15875. * Allows the animatable to blend with current running animations
  15876. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15877. * @param blendingSpeed defines the blending speed to use
  15878. */
  15879. enableBlending(blendingSpeed: number): void;
  15880. /**
  15881. * Disable animation blending
  15882. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15883. */
  15884. disableBlending(): void;
  15885. /**
  15886. * Jump directly to a given frame
  15887. * @param frame defines the frame to jump to
  15888. */
  15889. goToFrame(frame: number): void;
  15890. /**
  15891. * Pause the animation
  15892. */
  15893. pause(): void;
  15894. /**
  15895. * Restart the animation
  15896. */
  15897. restart(): void;
  15898. private _raiseOnAnimationEnd;
  15899. /**
  15900. * Stop and delete the current animation
  15901. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15902. * @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)
  15903. */
  15904. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15905. /**
  15906. * Wait asynchronously for the animation to end
  15907. * @returns a promise which will be fullfilled when the animation ends
  15908. */
  15909. waitAsync(): Promise<Animatable>;
  15910. /** @hidden */
  15911. _animate(delay: number): boolean;
  15912. }
  15913. interface Scene {
  15914. /** @hidden */
  15915. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15916. /** @hidden */
  15917. _processLateAnimationBindingsForMatrices(holder: {
  15918. totalWeight: number;
  15919. totalAdditiveWeight: number;
  15920. animations: RuntimeAnimation[];
  15921. additiveAnimations: RuntimeAnimation[];
  15922. originalValue: Matrix;
  15923. }): any;
  15924. /** @hidden */
  15925. _processLateAnimationBindingsForQuaternions(holder: {
  15926. totalWeight: number;
  15927. totalAdditiveWeight: number;
  15928. animations: RuntimeAnimation[];
  15929. additiveAnimations: RuntimeAnimation[];
  15930. originalValue: Quaternion;
  15931. }, refQuaternion: Quaternion): Quaternion;
  15932. /** @hidden */
  15933. _processLateAnimationBindings(): void;
  15934. /**
  15935. * Will start the animation sequence of a given target
  15936. * @param target defines the target
  15937. * @param from defines from which frame should animation start
  15938. * @param to defines until which frame should animation run.
  15939. * @param weight defines the weight to apply to the animation (1.0 by default)
  15940. * @param loop defines if the animation loops
  15941. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15942. * @param onAnimationEnd defines the function to be executed when the animation ends
  15943. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15944. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15945. * @param onAnimationLoop defines the callback to call when an animation loops
  15946. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15947. * @returns the animatable object created for this animation
  15948. */
  15949. 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;
  15950. /**
  15951. * Will start the animation sequence of a given target
  15952. * @param target defines the target
  15953. * @param from defines from which frame should animation start
  15954. * @param to defines until which frame should animation run.
  15955. * @param loop defines if the animation loops
  15956. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15957. * @param onAnimationEnd defines the function to be executed when the animation ends
  15958. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15959. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15960. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15961. * @param onAnimationLoop defines the callback to call when an animation loops
  15962. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15963. * @returns the animatable object created for this animation
  15964. */
  15965. 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;
  15966. /**
  15967. * Will start the animation sequence of a given target and its hierarchy
  15968. * @param target defines the target
  15969. * @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.
  15970. * @param from defines from which frame should animation start
  15971. * @param to defines until which frame should animation run.
  15972. * @param loop defines if the animation loops
  15973. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15974. * @param onAnimationEnd defines the function to be executed when the animation ends
  15975. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15976. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15977. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15978. * @param onAnimationLoop defines the callback to call when an animation loops
  15979. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15980. * @returns the list of created animatables
  15981. */
  15982. 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[];
  15983. /**
  15984. * Begin a new animation on a given node
  15985. * @param target defines the target where the animation will take place
  15986. * @param animations defines the list of animations to start
  15987. * @param from defines the initial value
  15988. * @param to defines the final value
  15989. * @param loop defines if you want animation to loop (off by default)
  15990. * @param speedRatio defines the speed ratio to apply to all animations
  15991. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15992. * @param onAnimationLoop defines the callback to call when an animation loops
  15993. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15994. * @returns the list of created animatables
  15995. */
  15996. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15997. /**
  15998. * Begin a new animation on a given node and its hierarchy
  15999. * @param target defines the root node where the animation will take place
  16000. * @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.
  16001. * @param animations defines the list of animations to start
  16002. * @param from defines the initial value
  16003. * @param to defines the final value
  16004. * @param loop defines if you want animation to loop (off by default)
  16005. * @param speedRatio defines the speed ratio to apply to all animations
  16006. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16007. * @param onAnimationLoop defines the callback to call when an animation loops
  16008. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16009. * @returns the list of animatables created for all nodes
  16010. */
  16011. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16012. /**
  16013. * Gets the animatable associated with a specific target
  16014. * @param target defines the target of the animatable
  16015. * @returns the required animatable if found
  16016. */
  16017. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16018. /**
  16019. * Gets all animatables associated with a given target
  16020. * @param target defines the target to look animatables for
  16021. * @returns an array of Animatables
  16022. */
  16023. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16024. /**
  16025. * Stops and removes all animations that have been applied to the scene
  16026. */
  16027. stopAllAnimations(): void;
  16028. /**
  16029. * Gets the current delta time used by animation engine
  16030. */
  16031. deltaTime: number;
  16032. }
  16033. interface Bone {
  16034. /**
  16035. * Copy an animation range from another bone
  16036. * @param source defines the source bone
  16037. * @param rangeName defines the range name to copy
  16038. * @param frameOffset defines the frame offset
  16039. * @param rescaleAsRequired defines if rescaling must be applied if required
  16040. * @param skelDimensionsRatio defines the scaling ratio
  16041. * @returns true if operation was successful
  16042. */
  16043. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16044. }
  16045. }
  16046. declare module BABYLON {
  16047. /**
  16048. * Class used to handle skinning animations
  16049. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16050. */
  16051. export class Skeleton implements IAnimatable {
  16052. /** defines the skeleton name */
  16053. name: string;
  16054. /** defines the skeleton Id */
  16055. id: string;
  16056. /**
  16057. * Defines the list of child bones
  16058. */
  16059. bones: Bone[];
  16060. /**
  16061. * Defines an estimate of the dimension of the skeleton at rest
  16062. */
  16063. dimensionsAtRest: Vector3;
  16064. /**
  16065. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16066. */
  16067. needInitialSkinMatrix: boolean;
  16068. /**
  16069. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16070. */
  16071. overrideMesh: Nullable<AbstractMesh>;
  16072. /**
  16073. * Gets the list of animations attached to this skeleton
  16074. */
  16075. animations: Array<Animation>;
  16076. private _scene;
  16077. private _isDirty;
  16078. private _transformMatrices;
  16079. private _transformMatrixTexture;
  16080. private _meshesWithPoseMatrix;
  16081. private _animatables;
  16082. private _identity;
  16083. private _synchronizedWithMesh;
  16084. private _ranges;
  16085. private _lastAbsoluteTransformsUpdateId;
  16086. private _canUseTextureForBones;
  16087. private _uniqueId;
  16088. /** @hidden */
  16089. _numBonesWithLinkedTransformNode: number;
  16090. /** @hidden */
  16091. _hasWaitingData: Nullable<boolean>;
  16092. /** @hidden */
  16093. _waitingOverrideMeshId: Nullable<string>;
  16094. /**
  16095. * Specifies if the skeleton should be serialized
  16096. */
  16097. doNotSerialize: boolean;
  16098. private _useTextureToStoreBoneMatrices;
  16099. /**
  16100. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16101. * Please note that this option is not available if the hardware does not support it
  16102. */
  16103. get useTextureToStoreBoneMatrices(): boolean;
  16104. set useTextureToStoreBoneMatrices(value: boolean);
  16105. private _animationPropertiesOverride;
  16106. /**
  16107. * Gets or sets the animation properties override
  16108. */
  16109. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16110. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16111. /**
  16112. * List of inspectable custom properties (used by the Inspector)
  16113. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16114. */
  16115. inspectableCustomProperties: IInspectable[];
  16116. /**
  16117. * An observable triggered before computing the skeleton's matrices
  16118. */
  16119. onBeforeComputeObservable: Observable<Skeleton>;
  16120. /**
  16121. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16122. */
  16123. get isUsingTextureForMatrices(): boolean;
  16124. /**
  16125. * Gets the unique ID of this skeleton
  16126. */
  16127. get uniqueId(): number;
  16128. /**
  16129. * Creates a new skeleton
  16130. * @param name defines the skeleton name
  16131. * @param id defines the skeleton Id
  16132. * @param scene defines the hosting scene
  16133. */
  16134. constructor(
  16135. /** defines the skeleton name */
  16136. name: string,
  16137. /** defines the skeleton Id */
  16138. id: string, scene: Scene);
  16139. /**
  16140. * Gets the current object class name.
  16141. * @return the class name
  16142. */
  16143. getClassName(): string;
  16144. /**
  16145. * Returns an array containing the root bones
  16146. * @returns an array containing the root bones
  16147. */
  16148. getChildren(): Array<Bone>;
  16149. /**
  16150. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16151. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16152. * @returns a Float32Array containing matrices data
  16153. */
  16154. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16155. /**
  16156. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16157. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16158. * @returns a raw texture containing the data
  16159. */
  16160. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16161. /**
  16162. * Gets the current hosting scene
  16163. * @returns a scene object
  16164. */
  16165. getScene(): Scene;
  16166. /**
  16167. * Gets a string representing the current skeleton data
  16168. * @param fullDetails defines a boolean indicating if we want a verbose version
  16169. * @returns a string representing the current skeleton data
  16170. */
  16171. toString(fullDetails?: boolean): string;
  16172. /**
  16173. * Get bone's index searching by name
  16174. * @param name defines bone's name to search for
  16175. * @return the indice of the bone. Returns -1 if not found
  16176. */
  16177. getBoneIndexByName(name: string): number;
  16178. /**
  16179. * Creater a new animation range
  16180. * @param name defines the name of the range
  16181. * @param from defines the start key
  16182. * @param to defines the end key
  16183. */
  16184. createAnimationRange(name: string, from: number, to: number): void;
  16185. /**
  16186. * Delete a specific animation range
  16187. * @param name defines the name of the range
  16188. * @param deleteFrames defines if frames must be removed as well
  16189. */
  16190. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16191. /**
  16192. * Gets a specific animation range
  16193. * @param name defines the name of the range to look for
  16194. * @returns the requested animation range or null if not found
  16195. */
  16196. getAnimationRange(name: string): Nullable<AnimationRange>;
  16197. /**
  16198. * Gets the list of all animation ranges defined on this skeleton
  16199. * @returns an array
  16200. */
  16201. getAnimationRanges(): Nullable<AnimationRange>[];
  16202. /**
  16203. * Copy animation range from a source skeleton.
  16204. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16205. * @param source defines the source skeleton
  16206. * @param name defines the name of the range to copy
  16207. * @param rescaleAsRequired defines if rescaling must be applied if required
  16208. * @returns true if operation was successful
  16209. */
  16210. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16211. /**
  16212. * Forces the skeleton to go to rest pose
  16213. */
  16214. returnToRest(): void;
  16215. private _getHighestAnimationFrame;
  16216. /**
  16217. * Begin a specific animation range
  16218. * @param name defines the name of the range to start
  16219. * @param loop defines if looping must be turned on (false by default)
  16220. * @param speedRatio defines the speed ratio to apply (1 by default)
  16221. * @param onAnimationEnd defines a callback which will be called when animation will end
  16222. * @returns a new animatable
  16223. */
  16224. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16225. /**
  16226. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16227. * @param skeleton defines the Skeleton containing the animation range to convert
  16228. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16229. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16230. * @returns the original skeleton
  16231. */
  16232. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16233. /** @hidden */
  16234. _markAsDirty(): void;
  16235. /** @hidden */
  16236. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16237. /** @hidden */
  16238. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16239. private _computeTransformMatrices;
  16240. /**
  16241. * Build all resources required to render a skeleton
  16242. */
  16243. prepare(): void;
  16244. /**
  16245. * Gets the list of animatables currently running for this skeleton
  16246. * @returns an array of animatables
  16247. */
  16248. getAnimatables(): IAnimatable[];
  16249. /**
  16250. * Clone the current skeleton
  16251. * @param name defines the name of the new skeleton
  16252. * @param id defines the id of the new skeleton
  16253. * @returns the new skeleton
  16254. */
  16255. clone(name: string, id?: string): Skeleton;
  16256. /**
  16257. * Enable animation blending for this skeleton
  16258. * @param blendingSpeed defines the blending speed to apply
  16259. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16260. */
  16261. enableBlending(blendingSpeed?: number): void;
  16262. /**
  16263. * Releases all resources associated with the current skeleton
  16264. */
  16265. dispose(): void;
  16266. /**
  16267. * Serialize the skeleton in a JSON object
  16268. * @returns a JSON object
  16269. */
  16270. serialize(): any;
  16271. /**
  16272. * Creates a new skeleton from serialized data
  16273. * @param parsedSkeleton defines the serialized data
  16274. * @param scene defines the hosting scene
  16275. * @returns a new skeleton
  16276. */
  16277. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16278. /**
  16279. * Compute all node absolute transforms
  16280. * @param forceUpdate defines if computation must be done even if cache is up to date
  16281. */
  16282. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16283. /**
  16284. * Gets the root pose matrix
  16285. * @returns a matrix
  16286. */
  16287. getPoseMatrix(): Nullable<Matrix>;
  16288. /**
  16289. * Sorts bones per internal index
  16290. */
  16291. sortBones(): void;
  16292. private _sortBones;
  16293. /**
  16294. * Set the current local matrix as the restPose for all bones in the skeleton.
  16295. */
  16296. setCurrentPoseAsRest(): void;
  16297. }
  16298. }
  16299. declare module BABYLON {
  16300. /**
  16301. * Creates an instance based on a source mesh.
  16302. */
  16303. export class InstancedMesh extends AbstractMesh {
  16304. private _sourceMesh;
  16305. private _currentLOD;
  16306. /** @hidden */
  16307. _indexInSourceMeshInstanceArray: number;
  16308. constructor(name: string, source: Mesh);
  16309. /**
  16310. * Returns the string "InstancedMesh".
  16311. */
  16312. getClassName(): string;
  16313. /** Gets the list of lights affecting that mesh */
  16314. get lightSources(): Light[];
  16315. _resyncLightSources(): void;
  16316. _resyncLightSource(light: Light): void;
  16317. _removeLightSource(light: Light, dispose: boolean): void;
  16318. /**
  16319. * If the source mesh receives shadows
  16320. */
  16321. get receiveShadows(): boolean;
  16322. /**
  16323. * The material of the source mesh
  16324. */
  16325. get material(): Nullable<Material>;
  16326. /**
  16327. * Visibility of the source mesh
  16328. */
  16329. get visibility(): number;
  16330. /**
  16331. * Skeleton of the source mesh
  16332. */
  16333. get skeleton(): Nullable<Skeleton>;
  16334. /**
  16335. * Rendering ground id of the source mesh
  16336. */
  16337. get renderingGroupId(): number;
  16338. set renderingGroupId(value: number);
  16339. /**
  16340. * Returns the total number of vertices (integer).
  16341. */
  16342. getTotalVertices(): number;
  16343. /**
  16344. * Returns a positive integer : the total number of indices in this mesh geometry.
  16345. * @returns the numner of indices or zero if the mesh has no geometry.
  16346. */
  16347. getTotalIndices(): number;
  16348. /**
  16349. * The source mesh of the instance
  16350. */
  16351. get sourceMesh(): Mesh;
  16352. /**
  16353. * Creates a new InstancedMesh object from the mesh model.
  16354. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16355. * @param name defines the name of the new instance
  16356. * @returns a new InstancedMesh
  16357. */
  16358. createInstance(name: string): InstancedMesh;
  16359. /**
  16360. * Is this node ready to be used/rendered
  16361. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16362. * @return {boolean} is it ready
  16363. */
  16364. isReady(completeCheck?: boolean): boolean;
  16365. /**
  16366. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16367. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16368. * @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.
  16369. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16370. */
  16371. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16372. /**
  16373. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16374. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16375. * The `data` are either a numeric array either a Float32Array.
  16376. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16377. * 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).
  16378. * Note that a new underlying VertexBuffer object is created each call.
  16379. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16380. *
  16381. * Possible `kind` values :
  16382. * - VertexBuffer.PositionKind
  16383. * - VertexBuffer.UVKind
  16384. * - VertexBuffer.UV2Kind
  16385. * - VertexBuffer.UV3Kind
  16386. * - VertexBuffer.UV4Kind
  16387. * - VertexBuffer.UV5Kind
  16388. * - VertexBuffer.UV6Kind
  16389. * - VertexBuffer.ColorKind
  16390. * - VertexBuffer.MatricesIndicesKind
  16391. * - VertexBuffer.MatricesIndicesExtraKind
  16392. * - VertexBuffer.MatricesWeightsKind
  16393. * - VertexBuffer.MatricesWeightsExtraKind
  16394. *
  16395. * Returns the Mesh.
  16396. */
  16397. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16398. /**
  16399. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16400. * If the mesh has no geometry, it is simply returned as it is.
  16401. * The `data` are either a numeric array either a Float32Array.
  16402. * No new underlying VertexBuffer object is created.
  16403. * 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.
  16404. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16405. *
  16406. * Possible `kind` values :
  16407. * - VertexBuffer.PositionKind
  16408. * - VertexBuffer.UVKind
  16409. * - VertexBuffer.UV2Kind
  16410. * - VertexBuffer.UV3Kind
  16411. * - VertexBuffer.UV4Kind
  16412. * - VertexBuffer.UV5Kind
  16413. * - VertexBuffer.UV6Kind
  16414. * - VertexBuffer.ColorKind
  16415. * - VertexBuffer.MatricesIndicesKind
  16416. * - VertexBuffer.MatricesIndicesExtraKind
  16417. * - VertexBuffer.MatricesWeightsKind
  16418. * - VertexBuffer.MatricesWeightsExtraKind
  16419. *
  16420. * Returns the Mesh.
  16421. */
  16422. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16423. /**
  16424. * Sets the mesh indices.
  16425. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16426. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16427. * This method creates a new index buffer each call.
  16428. * Returns the Mesh.
  16429. */
  16430. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16431. /**
  16432. * Boolean : True if the mesh owns the requested kind of data.
  16433. */
  16434. isVerticesDataPresent(kind: string): boolean;
  16435. /**
  16436. * Returns an array of indices (IndicesArray).
  16437. */
  16438. getIndices(): Nullable<IndicesArray>;
  16439. get _positions(): Nullable<Vector3[]>;
  16440. /**
  16441. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16442. * This means the mesh underlying bounding box and sphere are recomputed.
  16443. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16444. * @returns the current mesh
  16445. */
  16446. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16447. /** @hidden */
  16448. _preActivate(): InstancedMesh;
  16449. /** @hidden */
  16450. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16451. /** @hidden */
  16452. _postActivate(): void;
  16453. getWorldMatrix(): Matrix;
  16454. get isAnInstance(): boolean;
  16455. /**
  16456. * Returns the current associated LOD AbstractMesh.
  16457. */
  16458. getLOD(camera: Camera): AbstractMesh;
  16459. /** @hidden */
  16460. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16461. /** @hidden */
  16462. _syncSubMeshes(): InstancedMesh;
  16463. /** @hidden */
  16464. _generatePointsArray(): boolean;
  16465. /** @hidden */
  16466. _updateBoundingInfo(): AbstractMesh;
  16467. /**
  16468. * Creates a new InstancedMesh from the current mesh.
  16469. * - name (string) : the cloned mesh name
  16470. * - newParent (optional Node) : the optional Node to parent the clone to.
  16471. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16472. *
  16473. * Returns the clone.
  16474. */
  16475. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16476. /**
  16477. * Disposes the InstancedMesh.
  16478. * Returns nothing.
  16479. */
  16480. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16481. }
  16482. interface Mesh {
  16483. /**
  16484. * Register a custom buffer that will be instanced
  16485. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16486. * @param kind defines the buffer kind
  16487. * @param stride defines the stride in floats
  16488. */
  16489. registerInstancedBuffer(kind: string, stride: number): void;
  16490. /**
  16491. * true to use the edge renderer for all instances of this mesh
  16492. */
  16493. edgesShareWithInstances: boolean;
  16494. /** @hidden */
  16495. _userInstancedBuffersStorage: {
  16496. data: {
  16497. [key: string]: Float32Array;
  16498. };
  16499. sizes: {
  16500. [key: string]: number;
  16501. };
  16502. vertexBuffers: {
  16503. [key: string]: Nullable<VertexBuffer>;
  16504. };
  16505. strides: {
  16506. [key: string]: number;
  16507. };
  16508. };
  16509. }
  16510. interface AbstractMesh {
  16511. /**
  16512. * Object used to store instanced buffers defined by user
  16513. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16514. */
  16515. instancedBuffers: {
  16516. [key: string]: any;
  16517. };
  16518. }
  16519. }
  16520. declare module BABYLON {
  16521. /**
  16522. * Defines the options associated with the creation of a shader material.
  16523. */
  16524. export interface IShaderMaterialOptions {
  16525. /**
  16526. * Does the material work in alpha blend mode
  16527. */
  16528. needAlphaBlending: boolean;
  16529. /**
  16530. * Does the material work in alpha test mode
  16531. */
  16532. needAlphaTesting: boolean;
  16533. /**
  16534. * The list of attribute names used in the shader
  16535. */
  16536. attributes: string[];
  16537. /**
  16538. * The list of unifrom names used in the shader
  16539. */
  16540. uniforms: string[];
  16541. /**
  16542. * The list of UBO names used in the shader
  16543. */
  16544. uniformBuffers: string[];
  16545. /**
  16546. * The list of sampler names used in the shader
  16547. */
  16548. samplers: string[];
  16549. /**
  16550. * The list of defines used in the shader
  16551. */
  16552. defines: string[];
  16553. }
  16554. /**
  16555. * 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.
  16556. *
  16557. * This returned material effects how the mesh will look based on the code in the shaders.
  16558. *
  16559. * @see https://doc.babylonjs.com/how_to/shader_material
  16560. */
  16561. export class ShaderMaterial extends Material {
  16562. private _shaderPath;
  16563. private _options;
  16564. private _textures;
  16565. private _textureArrays;
  16566. private _floats;
  16567. private _ints;
  16568. private _floatsArrays;
  16569. private _colors3;
  16570. private _colors3Arrays;
  16571. private _colors4;
  16572. private _colors4Arrays;
  16573. private _vectors2;
  16574. private _vectors3;
  16575. private _vectors4;
  16576. private _matrices;
  16577. private _matrixArrays;
  16578. private _matrices3x3;
  16579. private _matrices2x2;
  16580. private _vectors2Arrays;
  16581. private _vectors3Arrays;
  16582. private _vectors4Arrays;
  16583. private _cachedWorldViewMatrix;
  16584. private _cachedWorldViewProjectionMatrix;
  16585. private _renderId;
  16586. private _multiview;
  16587. private _cachedDefines;
  16588. /** Define the Url to load snippets */
  16589. static SnippetUrl: string;
  16590. /** Snippet ID if the material was created from the snippet server */
  16591. snippetId: string;
  16592. /**
  16593. * Instantiate a new shader material.
  16594. * 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.
  16595. * This returned material effects how the mesh will look based on the code in the shaders.
  16596. * @see https://doc.babylonjs.com/how_to/shader_material
  16597. * @param name Define the name of the material in the scene
  16598. * @param scene Define the scene the material belongs to
  16599. * @param shaderPath Defines the route to the shader code in one of three ways:
  16600. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16601. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16602. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16603. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16604. * @param options Define the options used to create the shader
  16605. */
  16606. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16607. /**
  16608. * Gets the shader path used to define the shader code
  16609. * It can be modified to trigger a new compilation
  16610. */
  16611. get shaderPath(): any;
  16612. /**
  16613. * Sets the shader path used to define the shader code
  16614. * It can be modified to trigger a new compilation
  16615. */
  16616. set shaderPath(shaderPath: any);
  16617. /**
  16618. * Gets the options used to compile the shader.
  16619. * They can be modified to trigger a new compilation
  16620. */
  16621. get options(): IShaderMaterialOptions;
  16622. /**
  16623. * Gets the current class name of the material e.g. "ShaderMaterial"
  16624. * Mainly use in serialization.
  16625. * @returns the class name
  16626. */
  16627. getClassName(): string;
  16628. /**
  16629. * Specifies if the material will require alpha blending
  16630. * @returns a boolean specifying if alpha blending is needed
  16631. */
  16632. needAlphaBlending(): boolean;
  16633. /**
  16634. * Specifies if this material should be rendered in alpha test mode
  16635. * @returns a boolean specifying if an alpha test is needed.
  16636. */
  16637. needAlphaTesting(): boolean;
  16638. private _checkUniform;
  16639. /**
  16640. * Set a texture in the shader.
  16641. * @param name Define the name of the uniform samplers as defined in the shader
  16642. * @param texture Define the texture to bind to this sampler
  16643. * @return the material itself allowing "fluent" like uniform updates
  16644. */
  16645. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16646. /**
  16647. * Set a texture array in the shader.
  16648. * @param name Define the name of the uniform sampler array as defined in the shader
  16649. * @param textures Define the list of textures to bind to this sampler
  16650. * @return the material itself allowing "fluent" like uniform updates
  16651. */
  16652. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16653. /**
  16654. * Set a float in the shader.
  16655. * @param name Define the name of the uniform as defined in the shader
  16656. * @param value Define the value to give to the uniform
  16657. * @return the material itself allowing "fluent" like uniform updates
  16658. */
  16659. setFloat(name: string, value: number): ShaderMaterial;
  16660. /**
  16661. * Set a int in the shader.
  16662. * @param name Define the name of the uniform as defined in the shader
  16663. * @param value Define the value to give to the uniform
  16664. * @return the material itself allowing "fluent" like uniform updates
  16665. */
  16666. setInt(name: string, value: number): ShaderMaterial;
  16667. /**
  16668. * Set an array of floats in the shader.
  16669. * @param name Define the name of the uniform as defined in the shader
  16670. * @param value Define the value to give to the uniform
  16671. * @return the material itself allowing "fluent" like uniform updates
  16672. */
  16673. setFloats(name: string, value: number[]): ShaderMaterial;
  16674. /**
  16675. * Set a vec3 in the shader from a Color3.
  16676. * @param name Define the name of the uniform as defined in the shader
  16677. * @param value Define the value to give to the uniform
  16678. * @return the material itself allowing "fluent" like uniform updates
  16679. */
  16680. setColor3(name: string, value: Color3): ShaderMaterial;
  16681. /**
  16682. * Set a vec3 array in the shader from a Color3 array.
  16683. * @param name Define the name of the uniform as defined in the shader
  16684. * @param value Define the value to give to the uniform
  16685. * @return the material itself allowing "fluent" like uniform updates
  16686. */
  16687. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16688. /**
  16689. * Set a vec4 in the shader from a Color4.
  16690. * @param name Define the name of the uniform as defined in the shader
  16691. * @param value Define the value to give to the uniform
  16692. * @return the material itself allowing "fluent" like uniform updates
  16693. */
  16694. setColor4(name: string, value: Color4): ShaderMaterial;
  16695. /**
  16696. * Set a vec4 array in the shader from a Color4 array.
  16697. * @param name Define the name of the uniform as defined in the shader
  16698. * @param value Define the value to give to the uniform
  16699. * @return the material itself allowing "fluent" like uniform updates
  16700. */
  16701. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16702. /**
  16703. * Set a vec2 in the shader from a Vector2.
  16704. * @param name Define the name of the uniform as defined in the shader
  16705. * @param value Define the value to give to the uniform
  16706. * @return the material itself allowing "fluent" like uniform updates
  16707. */
  16708. setVector2(name: string, value: Vector2): ShaderMaterial;
  16709. /**
  16710. * Set a vec3 in the shader from a Vector3.
  16711. * @param name Define the name of the uniform as defined in the shader
  16712. * @param value Define the value to give to the uniform
  16713. * @return the material itself allowing "fluent" like uniform updates
  16714. */
  16715. setVector3(name: string, value: Vector3): ShaderMaterial;
  16716. /**
  16717. * Set a vec4 in the shader from a Vector4.
  16718. * @param name Define the name of the uniform as defined in the shader
  16719. * @param value Define the value to give to the uniform
  16720. * @return the material itself allowing "fluent" like uniform updates
  16721. */
  16722. setVector4(name: string, value: Vector4): ShaderMaterial;
  16723. /**
  16724. * Set a mat4 in the shader from a Matrix.
  16725. * @param name Define the name of the uniform as defined in the shader
  16726. * @param value Define the value to give to the uniform
  16727. * @return the material itself allowing "fluent" like uniform updates
  16728. */
  16729. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16730. /**
  16731. * Set a float32Array in the shader from a matrix array.
  16732. * @param name Define the name of the uniform as defined in the shader
  16733. * @param value Define the value to give to the uniform
  16734. * @return the material itself allowing "fluent" like uniform updates
  16735. */
  16736. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16737. /**
  16738. * Set a mat3 in the shader from a Float32Array.
  16739. * @param name Define the name of the uniform as defined in the shader
  16740. * @param value Define the value to give to the uniform
  16741. * @return the material itself allowing "fluent" like uniform updates
  16742. */
  16743. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16744. /**
  16745. * Set a mat2 in the shader from a Float32Array.
  16746. * @param name Define the name of the uniform as defined in the shader
  16747. * @param value Define the value to give to the uniform
  16748. * @return the material itself allowing "fluent" like uniform updates
  16749. */
  16750. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16751. /**
  16752. * Set a vec2 array in the shader from a number array.
  16753. * @param name Define the name of the uniform as defined in the shader
  16754. * @param value Define the value to give to the uniform
  16755. * @return the material itself allowing "fluent" like uniform updates
  16756. */
  16757. setArray2(name: string, value: number[]): ShaderMaterial;
  16758. /**
  16759. * Set a vec3 array in the shader from a number array.
  16760. * @param name Define the name of the uniform as defined in the shader
  16761. * @param value Define the value to give to the uniform
  16762. * @return the material itself allowing "fluent" like uniform updates
  16763. */
  16764. setArray3(name: string, value: number[]): ShaderMaterial;
  16765. /**
  16766. * Set a vec4 array in the shader from a number array.
  16767. * @param name Define the name of the uniform as defined in the shader
  16768. * @param value Define the value to give to the uniform
  16769. * @return the material itself allowing "fluent" like uniform updates
  16770. */
  16771. setArray4(name: string, value: number[]): ShaderMaterial;
  16772. private _checkCache;
  16773. /**
  16774. * Specifies that the submesh is ready to be used
  16775. * @param mesh defines the mesh to check
  16776. * @param subMesh defines which submesh to check
  16777. * @param useInstances specifies that instances should be used
  16778. * @returns a boolean indicating that the submesh is ready or not
  16779. */
  16780. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16781. /**
  16782. * Checks if the material is ready to render the requested mesh
  16783. * @param mesh Define the mesh to render
  16784. * @param useInstances Define whether or not the material is used with instances
  16785. * @returns true if ready, otherwise false
  16786. */
  16787. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16788. /**
  16789. * Binds the world matrix to the material
  16790. * @param world defines the world transformation matrix
  16791. * @param effectOverride - If provided, use this effect instead of internal effect
  16792. */
  16793. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16794. /**
  16795. * Binds the submesh to this material by preparing the effect and shader to draw
  16796. * @param world defines the world transformation matrix
  16797. * @param mesh defines the mesh containing the submesh
  16798. * @param subMesh defines the submesh to bind the material to
  16799. */
  16800. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16801. /**
  16802. * Binds the material to the mesh
  16803. * @param world defines the world transformation matrix
  16804. * @param mesh defines the mesh to bind the material to
  16805. * @param effectOverride - If provided, use this effect instead of internal effect
  16806. */
  16807. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16808. protected _afterBind(mesh?: Mesh): void;
  16809. /**
  16810. * Gets the active textures from the material
  16811. * @returns an array of textures
  16812. */
  16813. getActiveTextures(): BaseTexture[];
  16814. /**
  16815. * Specifies if the material uses a texture
  16816. * @param texture defines the texture to check against the material
  16817. * @returns a boolean specifying if the material uses the texture
  16818. */
  16819. hasTexture(texture: BaseTexture): boolean;
  16820. /**
  16821. * Makes a duplicate of the material, and gives it a new name
  16822. * @param name defines the new name for the duplicated material
  16823. * @returns the cloned material
  16824. */
  16825. clone(name: string): ShaderMaterial;
  16826. /**
  16827. * Disposes the material
  16828. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16829. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16830. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16831. */
  16832. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16833. /**
  16834. * Serializes this material in a JSON representation
  16835. * @returns the serialized material object
  16836. */
  16837. serialize(): any;
  16838. /**
  16839. * Creates a shader material from parsed shader material data
  16840. * @param source defines the JSON represnetation of the material
  16841. * @param scene defines the hosting scene
  16842. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16843. * @returns a new material
  16844. */
  16845. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16846. /**
  16847. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16848. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16849. * @param url defines the url to load from
  16850. * @param scene defines the hosting scene
  16851. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16852. * @returns a promise that will resolve to the new ShaderMaterial
  16853. */
  16854. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16855. /**
  16856. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16857. * @param snippetId defines the snippet to load
  16858. * @param scene defines the hosting scene
  16859. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16860. * @returns a promise that will resolve to the new ShaderMaterial
  16861. */
  16862. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16863. }
  16864. }
  16865. declare module BABYLON {
  16866. /** @hidden */
  16867. export var colorPixelShader: {
  16868. name: string;
  16869. shader: string;
  16870. };
  16871. }
  16872. declare module BABYLON {
  16873. /** @hidden */
  16874. export var colorVertexShader: {
  16875. name: string;
  16876. shader: string;
  16877. };
  16878. }
  16879. declare module BABYLON {
  16880. /**
  16881. * Line mesh
  16882. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16883. */
  16884. export class LinesMesh extends Mesh {
  16885. /**
  16886. * If vertex color should be applied to the mesh
  16887. */
  16888. readonly useVertexColor?: boolean | undefined;
  16889. /**
  16890. * If vertex alpha should be applied to the mesh
  16891. */
  16892. readonly useVertexAlpha?: boolean | undefined;
  16893. /**
  16894. * Color of the line (Default: White)
  16895. */
  16896. color: Color3;
  16897. /**
  16898. * Alpha of the line (Default: 1)
  16899. */
  16900. alpha: number;
  16901. /**
  16902. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16903. * This margin is expressed in world space coordinates, so its value may vary.
  16904. * Default value is 0.1
  16905. */
  16906. intersectionThreshold: number;
  16907. private _colorShader;
  16908. private color4;
  16909. /**
  16910. * Creates a new LinesMesh
  16911. * @param name defines the name
  16912. * @param scene defines the hosting scene
  16913. * @param parent defines the parent mesh if any
  16914. * @param source defines the optional source LinesMesh used to clone data from
  16915. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16916. * When false, achieved by calling a clone(), also passing False.
  16917. * This will make creation of children, recursive.
  16918. * @param useVertexColor defines if this LinesMesh supports vertex color
  16919. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16920. */
  16921. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16922. /**
  16923. * If vertex color should be applied to the mesh
  16924. */
  16925. useVertexColor?: boolean | undefined,
  16926. /**
  16927. * If vertex alpha should be applied to the mesh
  16928. */
  16929. useVertexAlpha?: boolean | undefined);
  16930. private _addClipPlaneDefine;
  16931. private _removeClipPlaneDefine;
  16932. isReady(): boolean;
  16933. /**
  16934. * Returns the string "LineMesh"
  16935. */
  16936. getClassName(): string;
  16937. /**
  16938. * @hidden
  16939. */
  16940. get material(): Material;
  16941. /**
  16942. * @hidden
  16943. */
  16944. set material(value: Material);
  16945. /**
  16946. * @hidden
  16947. */
  16948. get checkCollisions(): boolean;
  16949. /** @hidden */
  16950. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16951. /** @hidden */
  16952. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16953. /**
  16954. * Disposes of the line mesh
  16955. * @param doNotRecurse If children should be disposed
  16956. */
  16957. dispose(doNotRecurse?: boolean): void;
  16958. /**
  16959. * Returns a new LineMesh object cloned from the current one.
  16960. */
  16961. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16962. /**
  16963. * Creates a new InstancedLinesMesh object from the mesh model.
  16964. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16965. * @param name defines the name of the new instance
  16966. * @returns a new InstancedLinesMesh
  16967. */
  16968. createInstance(name: string): InstancedLinesMesh;
  16969. }
  16970. /**
  16971. * Creates an instance based on a source LinesMesh
  16972. */
  16973. export class InstancedLinesMesh extends InstancedMesh {
  16974. /**
  16975. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16976. * This margin is expressed in world space coordinates, so its value may vary.
  16977. * Initilized with the intersectionThreshold value of the source LinesMesh
  16978. */
  16979. intersectionThreshold: number;
  16980. constructor(name: string, source: LinesMesh);
  16981. /**
  16982. * Returns the string "InstancedLinesMesh".
  16983. */
  16984. getClassName(): string;
  16985. }
  16986. }
  16987. declare module BABYLON {
  16988. /** @hidden */
  16989. export var linePixelShader: {
  16990. name: string;
  16991. shader: string;
  16992. };
  16993. }
  16994. declare module BABYLON {
  16995. /** @hidden */
  16996. export var lineVertexShader: {
  16997. name: string;
  16998. shader: string;
  16999. };
  17000. }
  17001. declare module BABYLON {
  17002. interface Scene {
  17003. /** @hidden */
  17004. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17005. }
  17006. interface AbstractMesh {
  17007. /**
  17008. * Gets the edgesRenderer associated with the mesh
  17009. */
  17010. edgesRenderer: Nullable<EdgesRenderer>;
  17011. }
  17012. interface LinesMesh {
  17013. /**
  17014. * Enables the edge rendering mode on the mesh.
  17015. * This mode makes the mesh edges visible
  17016. * @param epsilon defines the maximal distance between two angles to detect a face
  17017. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17018. * @returns the currentAbstractMesh
  17019. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17020. */
  17021. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17022. }
  17023. interface InstancedLinesMesh {
  17024. /**
  17025. * Enables the edge rendering mode on the mesh.
  17026. * This mode makes the mesh edges visible
  17027. * @param epsilon defines the maximal distance between two angles to detect a face
  17028. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17029. * @returns the current InstancedLinesMesh
  17030. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17031. */
  17032. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17033. }
  17034. /**
  17035. * Defines the minimum contract an Edges renderer should follow.
  17036. */
  17037. export interface IEdgesRenderer extends IDisposable {
  17038. /**
  17039. * Gets or sets a boolean indicating if the edgesRenderer is active
  17040. */
  17041. isEnabled: boolean;
  17042. /**
  17043. * Renders the edges of the attached mesh,
  17044. */
  17045. render(): void;
  17046. /**
  17047. * Checks wether or not the edges renderer is ready to render.
  17048. * @return true if ready, otherwise false.
  17049. */
  17050. isReady(): boolean;
  17051. /**
  17052. * List of instances to render in case the source mesh has instances
  17053. */
  17054. customInstances: SmartArray<Matrix>;
  17055. }
  17056. /**
  17057. * Defines the additional options of the edges renderer
  17058. */
  17059. export interface IEdgesRendererOptions {
  17060. /**
  17061. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17062. * If not defined, the default value is true
  17063. */
  17064. useAlternateEdgeFinder?: boolean;
  17065. /**
  17066. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17067. * If not defined, the default value is true.
  17068. * 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)
  17069. * This option is used only if useAlternateEdgeFinder = true
  17070. */
  17071. useFastVertexMerger?: boolean;
  17072. /**
  17073. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17074. * The default value is 1e-6
  17075. * This option is used only if useAlternateEdgeFinder = true
  17076. */
  17077. epsilonVertexMerge?: number;
  17078. /**
  17079. * 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
  17080. * 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.
  17081. * This option is used only if useAlternateEdgeFinder = true
  17082. */
  17083. applyTessellation?: boolean;
  17084. /**
  17085. * 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
  17086. * The default value is 1e-6
  17087. * This option is used only if useAlternateEdgeFinder = true
  17088. */
  17089. epsilonVertexAligned?: number;
  17090. }
  17091. /**
  17092. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17093. */
  17094. export class EdgesRenderer implements IEdgesRenderer {
  17095. /**
  17096. * Define the size of the edges with an orthographic camera
  17097. */
  17098. edgesWidthScalerForOrthographic: number;
  17099. /**
  17100. * Define the size of the edges with a perspective camera
  17101. */
  17102. edgesWidthScalerForPerspective: number;
  17103. protected _source: AbstractMesh;
  17104. protected _linesPositions: number[];
  17105. protected _linesNormals: number[];
  17106. protected _linesIndices: number[];
  17107. protected _epsilon: number;
  17108. protected _indicesCount: number;
  17109. protected _lineShader: ShaderMaterial;
  17110. protected _ib: DataBuffer;
  17111. protected _buffers: {
  17112. [key: string]: Nullable<VertexBuffer>;
  17113. };
  17114. protected _buffersForInstances: {
  17115. [key: string]: Nullable<VertexBuffer>;
  17116. };
  17117. protected _checkVerticesInsteadOfIndices: boolean;
  17118. protected _options: Nullable<IEdgesRendererOptions>;
  17119. private _meshRebuildObserver;
  17120. private _meshDisposeObserver;
  17121. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17122. isEnabled: boolean;
  17123. /**
  17124. * List of instances to render in case the source mesh has instances
  17125. */
  17126. customInstances: SmartArray<Matrix>;
  17127. private static GetShader;
  17128. /**
  17129. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17130. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17131. * @param source Mesh used to create edges
  17132. * @param epsilon sum of angles in adjacency to check for edge
  17133. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17134. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17135. * @param options The options to apply when generating the edges
  17136. */
  17137. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17138. protected _prepareRessources(): void;
  17139. /** @hidden */
  17140. _rebuild(): void;
  17141. /**
  17142. * Releases the required resources for the edges renderer
  17143. */
  17144. dispose(): void;
  17145. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17146. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17147. /**
  17148. * Checks if the pair of p0 and p1 is en edge
  17149. * @param faceIndex
  17150. * @param edge
  17151. * @param faceNormals
  17152. * @param p0
  17153. * @param p1
  17154. * @private
  17155. */
  17156. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17157. /**
  17158. * push line into the position, normal and index buffer
  17159. * @protected
  17160. */
  17161. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17162. /**
  17163. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17164. */
  17165. private _tessellateTriangle;
  17166. private _generateEdgesLinesAlternate;
  17167. /**
  17168. * Generates lines edges from adjacencjes
  17169. * @private
  17170. */
  17171. _generateEdgesLines(): void;
  17172. /**
  17173. * Checks wether or not the edges renderer is ready to render.
  17174. * @return true if ready, otherwise false.
  17175. */
  17176. isReady(): boolean;
  17177. /**
  17178. * Renders the edges of the attached mesh,
  17179. */
  17180. render(): void;
  17181. }
  17182. /**
  17183. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17184. */
  17185. export class LineEdgesRenderer extends EdgesRenderer {
  17186. /**
  17187. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17188. * @param source LineMesh used to generate edges
  17189. * @param epsilon not important (specified angle for edge detection)
  17190. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17191. */
  17192. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17193. /**
  17194. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17195. */
  17196. _generateEdgesLines(): void;
  17197. }
  17198. }
  17199. declare module BABYLON {
  17200. /**
  17201. * This represents the object necessary to create a rendering group.
  17202. * This is exclusively used and created by the rendering manager.
  17203. * To modify the behavior, you use the available helpers in your scene or meshes.
  17204. * @hidden
  17205. */
  17206. export class RenderingGroup {
  17207. index: number;
  17208. private static _zeroVector;
  17209. private _scene;
  17210. private _opaqueSubMeshes;
  17211. private _transparentSubMeshes;
  17212. private _alphaTestSubMeshes;
  17213. private _depthOnlySubMeshes;
  17214. private _particleSystems;
  17215. private _spriteManagers;
  17216. private _opaqueSortCompareFn;
  17217. private _alphaTestSortCompareFn;
  17218. private _transparentSortCompareFn;
  17219. private _renderOpaque;
  17220. private _renderAlphaTest;
  17221. private _renderTransparent;
  17222. /** @hidden */
  17223. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17224. onBeforeTransparentRendering: () => void;
  17225. /**
  17226. * Set the opaque sort comparison function.
  17227. * If null the sub meshes will be render in the order they were created
  17228. */
  17229. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17230. /**
  17231. * Set the alpha test sort comparison function.
  17232. * If null the sub meshes will be render in the order they were created
  17233. */
  17234. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17235. /**
  17236. * Set the transparent sort comparison function.
  17237. * If null the sub meshes will be render in the order they were created
  17238. */
  17239. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17240. /**
  17241. * Creates a new rendering group.
  17242. * @param index The rendering group index
  17243. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17244. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17245. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17246. */
  17247. 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>);
  17248. /**
  17249. * Render all the sub meshes contained in the group.
  17250. * @param customRenderFunction Used to override the default render behaviour of the group.
  17251. * @returns true if rendered some submeshes.
  17252. */
  17253. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17254. /**
  17255. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17256. * @param subMeshes The submeshes to render
  17257. */
  17258. private renderOpaqueSorted;
  17259. /**
  17260. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17261. * @param subMeshes The submeshes to render
  17262. */
  17263. private renderAlphaTestSorted;
  17264. /**
  17265. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17266. * @param subMeshes The submeshes to render
  17267. */
  17268. private renderTransparentSorted;
  17269. /**
  17270. * Renders the submeshes in a specified order.
  17271. * @param subMeshes The submeshes to sort before render
  17272. * @param sortCompareFn The comparison function use to sort
  17273. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17274. * @param transparent Specifies to activate blending if true
  17275. */
  17276. private static renderSorted;
  17277. /**
  17278. * Renders the submeshes in the order they were dispatched (no sort applied).
  17279. * @param subMeshes The submeshes to render
  17280. */
  17281. private static renderUnsorted;
  17282. /**
  17283. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17284. * are rendered back to front if in the same alpha index.
  17285. *
  17286. * @param a The first submesh
  17287. * @param b The second submesh
  17288. * @returns The result of the comparison
  17289. */
  17290. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17291. /**
  17292. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17293. * are rendered back to front.
  17294. *
  17295. * @param a The first submesh
  17296. * @param b The second submesh
  17297. * @returns The result of the comparison
  17298. */
  17299. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17300. /**
  17301. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17302. * are rendered front to back (prevent overdraw).
  17303. *
  17304. * @param a The first submesh
  17305. * @param b The second submesh
  17306. * @returns The result of the comparison
  17307. */
  17308. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17309. /**
  17310. * Resets the different lists of submeshes to prepare a new frame.
  17311. */
  17312. prepare(): void;
  17313. dispose(): void;
  17314. /**
  17315. * Inserts the submesh in its correct queue depending on its material.
  17316. * @param subMesh The submesh to dispatch
  17317. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17318. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17319. */
  17320. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17321. dispatchSprites(spriteManager: ISpriteManager): void;
  17322. dispatchParticles(particleSystem: IParticleSystem): void;
  17323. private _renderParticles;
  17324. private _renderSprites;
  17325. }
  17326. }
  17327. declare module BABYLON {
  17328. /**
  17329. * Interface describing the different options available in the rendering manager
  17330. * regarding Auto Clear between groups.
  17331. */
  17332. export interface IRenderingManagerAutoClearSetup {
  17333. /**
  17334. * Defines whether or not autoclear is enable.
  17335. */
  17336. autoClear: boolean;
  17337. /**
  17338. * Defines whether or not to autoclear the depth buffer.
  17339. */
  17340. depth: boolean;
  17341. /**
  17342. * Defines whether or not to autoclear the stencil buffer.
  17343. */
  17344. stencil: boolean;
  17345. }
  17346. /**
  17347. * This class is used by the onRenderingGroupObservable
  17348. */
  17349. export class RenderingGroupInfo {
  17350. /**
  17351. * The Scene that being rendered
  17352. */
  17353. scene: Scene;
  17354. /**
  17355. * The camera currently used for the rendering pass
  17356. */
  17357. camera: Nullable<Camera>;
  17358. /**
  17359. * The ID of the renderingGroup being processed
  17360. */
  17361. renderingGroupId: number;
  17362. }
  17363. /**
  17364. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17365. * It is enable to manage the different groups as well as the different necessary sort functions.
  17366. * This should not be used directly aside of the few static configurations
  17367. */
  17368. export class RenderingManager {
  17369. /**
  17370. * The max id used for rendering groups (not included)
  17371. */
  17372. static MAX_RENDERINGGROUPS: number;
  17373. /**
  17374. * The min id used for rendering groups (included)
  17375. */
  17376. static MIN_RENDERINGGROUPS: number;
  17377. /**
  17378. * Used to globally prevent autoclearing scenes.
  17379. */
  17380. static AUTOCLEAR: boolean;
  17381. /**
  17382. * @hidden
  17383. */
  17384. _useSceneAutoClearSetup: boolean;
  17385. private _scene;
  17386. private _renderingGroups;
  17387. private _depthStencilBufferAlreadyCleaned;
  17388. private _autoClearDepthStencil;
  17389. private _customOpaqueSortCompareFn;
  17390. private _customAlphaTestSortCompareFn;
  17391. private _customTransparentSortCompareFn;
  17392. private _renderingGroupInfo;
  17393. /**
  17394. * Instantiates a new rendering group for a particular scene
  17395. * @param scene Defines the scene the groups belongs to
  17396. */
  17397. constructor(scene: Scene);
  17398. private _clearDepthStencilBuffer;
  17399. /**
  17400. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17401. * @hidden
  17402. */
  17403. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17404. /**
  17405. * Resets the different information of the group to prepare a new frame
  17406. * @hidden
  17407. */
  17408. reset(): void;
  17409. /**
  17410. * Dispose and release the group and its associated resources.
  17411. * @hidden
  17412. */
  17413. dispose(): void;
  17414. /**
  17415. * Clear the info related to rendering groups preventing retention points during dispose.
  17416. */
  17417. freeRenderingGroups(): void;
  17418. private _prepareRenderingGroup;
  17419. /**
  17420. * Add a sprite manager to the rendering manager in order to render it this frame.
  17421. * @param spriteManager Define the sprite manager to render
  17422. */
  17423. dispatchSprites(spriteManager: ISpriteManager): void;
  17424. /**
  17425. * Add a particle system to the rendering manager in order to render it this frame.
  17426. * @param particleSystem Define the particle system to render
  17427. */
  17428. dispatchParticles(particleSystem: IParticleSystem): void;
  17429. /**
  17430. * Add a submesh to the manager in order to render it this frame
  17431. * @param subMesh The submesh to dispatch
  17432. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17433. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17434. */
  17435. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17436. /**
  17437. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17438. * This allowed control for front to back rendering or reversly depending of the special needs.
  17439. *
  17440. * @param renderingGroupId The rendering group id corresponding to its index
  17441. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17442. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17443. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17444. */
  17445. 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;
  17446. /**
  17447. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17448. *
  17449. * @param renderingGroupId The rendering group id corresponding to its index
  17450. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17451. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17452. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17453. */
  17454. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17455. /**
  17456. * Gets the current auto clear configuration for one rendering group of the rendering
  17457. * manager.
  17458. * @param index the rendering group index to get the information for
  17459. * @returns The auto clear setup for the requested rendering group
  17460. */
  17461. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17462. }
  17463. }
  17464. declare module BABYLON {
  17465. /**
  17466. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17467. */
  17468. export interface ICustomShaderOptions {
  17469. /**
  17470. * Gets or sets the custom shader name to use
  17471. */
  17472. shaderName: string;
  17473. /**
  17474. * The list of attribute names used in the shader
  17475. */
  17476. attributes?: string[];
  17477. /**
  17478. * The list of unifrom names used in the shader
  17479. */
  17480. uniforms?: string[];
  17481. /**
  17482. * The list of sampler names used in the shader
  17483. */
  17484. samplers?: string[];
  17485. /**
  17486. * The list of defines used in the shader
  17487. */
  17488. defines?: string[];
  17489. }
  17490. /**
  17491. * Interface to implement to create a shadow generator compatible with BJS.
  17492. */
  17493. export interface IShadowGenerator {
  17494. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17495. id: string;
  17496. /**
  17497. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17498. * @returns The render target texture if present otherwise, null
  17499. */
  17500. getShadowMap(): Nullable<RenderTargetTexture>;
  17501. /**
  17502. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17503. * @param subMesh The submesh we want to render in the shadow map
  17504. * @param useInstances Defines wether will draw in the map using instances
  17505. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17506. * @returns true if ready otherwise, false
  17507. */
  17508. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17509. /**
  17510. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17511. * @param defines Defines of the material we want to update
  17512. * @param lightIndex Index of the light in the enabled light list of the material
  17513. */
  17514. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17515. /**
  17516. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17517. * defined in the generator but impacting the effect).
  17518. * It implies the unifroms available on the materials are the standard BJS ones.
  17519. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17520. * @param effect The effect we are binfing the information for
  17521. */
  17522. bindShadowLight(lightIndex: string, effect: Effect): void;
  17523. /**
  17524. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17525. * (eq to shadow prjection matrix * light transform matrix)
  17526. * @returns The transform matrix used to create the shadow map
  17527. */
  17528. getTransformMatrix(): Matrix;
  17529. /**
  17530. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17531. * Cube and 2D textures for instance.
  17532. */
  17533. recreateShadowMap(): void;
  17534. /**
  17535. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17536. * @param onCompiled Callback triggered at the and of the effects compilation
  17537. * @param options Sets of optional options forcing the compilation with different modes
  17538. */
  17539. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17540. useInstances: boolean;
  17541. }>): void;
  17542. /**
  17543. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17544. * @param options Sets of optional options forcing the compilation with different modes
  17545. * @returns A promise that resolves when the compilation completes
  17546. */
  17547. forceCompilationAsync(options?: Partial<{
  17548. useInstances: boolean;
  17549. }>): Promise<void>;
  17550. /**
  17551. * Serializes the shadow generator setup to a json object.
  17552. * @returns The serialized JSON object
  17553. */
  17554. serialize(): any;
  17555. /**
  17556. * Disposes the Shadow map and related Textures and effects.
  17557. */
  17558. dispose(): void;
  17559. }
  17560. /**
  17561. * Default implementation IShadowGenerator.
  17562. * This is the main object responsible of generating shadows in the framework.
  17563. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17564. */
  17565. export class ShadowGenerator implements IShadowGenerator {
  17566. /**
  17567. * Name of the shadow generator class
  17568. */
  17569. static CLASSNAME: string;
  17570. /**
  17571. * Shadow generator mode None: no filtering applied.
  17572. */
  17573. static readonly FILTER_NONE: number;
  17574. /**
  17575. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17576. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17577. */
  17578. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17579. /**
  17580. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17581. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17582. */
  17583. static readonly FILTER_POISSONSAMPLING: number;
  17584. /**
  17585. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17586. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17587. */
  17588. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17589. /**
  17590. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17591. * edge artifacts on steep falloff.
  17592. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17593. */
  17594. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17595. /**
  17596. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17597. * edge artifacts on steep falloff.
  17598. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17599. */
  17600. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17601. /**
  17602. * Shadow generator mode PCF: Percentage Closer Filtering
  17603. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17604. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17605. */
  17606. static readonly FILTER_PCF: number;
  17607. /**
  17608. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17609. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17610. * Contact Hardening
  17611. */
  17612. static readonly FILTER_PCSS: number;
  17613. /**
  17614. * Reserved for PCF and PCSS
  17615. * Highest Quality.
  17616. *
  17617. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17618. *
  17619. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17620. */
  17621. static readonly QUALITY_HIGH: number;
  17622. /**
  17623. * Reserved for PCF and PCSS
  17624. * Good tradeoff for quality/perf cross devices
  17625. *
  17626. * Execute PCF on a 3*3 kernel.
  17627. *
  17628. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17629. */
  17630. static readonly QUALITY_MEDIUM: number;
  17631. /**
  17632. * Reserved for PCF and PCSS
  17633. * The lowest quality but the fastest.
  17634. *
  17635. * Execute PCF on a 1*1 kernel.
  17636. *
  17637. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17638. */
  17639. static readonly QUALITY_LOW: number;
  17640. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17641. id: string;
  17642. /** Gets or sets the custom shader name to use */
  17643. customShaderOptions: ICustomShaderOptions;
  17644. /**
  17645. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17646. */
  17647. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17648. /**
  17649. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17650. */
  17651. onAfterShadowMapRenderObservable: Observable<Effect>;
  17652. /**
  17653. * Observable triggered before a mesh is rendered in the shadow map.
  17654. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17655. */
  17656. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17657. /**
  17658. * Observable triggered after a mesh is rendered in the shadow map.
  17659. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17660. */
  17661. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17662. protected _bias: number;
  17663. /**
  17664. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17665. */
  17666. get bias(): number;
  17667. /**
  17668. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17669. */
  17670. set bias(bias: number);
  17671. protected _normalBias: number;
  17672. /**
  17673. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17674. */
  17675. get normalBias(): number;
  17676. /**
  17677. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17678. */
  17679. set normalBias(normalBias: number);
  17680. protected _blurBoxOffset: number;
  17681. /**
  17682. * Gets the blur box offset: offset applied during the blur pass.
  17683. * Only useful if useKernelBlur = false
  17684. */
  17685. get blurBoxOffset(): number;
  17686. /**
  17687. * Sets the blur box offset: offset applied during the blur pass.
  17688. * Only useful if useKernelBlur = false
  17689. */
  17690. set blurBoxOffset(value: number);
  17691. protected _blurScale: number;
  17692. /**
  17693. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17694. * 2 means half of the size.
  17695. */
  17696. get blurScale(): number;
  17697. /**
  17698. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17699. * 2 means half of the size.
  17700. */
  17701. set blurScale(value: number);
  17702. protected _blurKernel: number;
  17703. /**
  17704. * Gets the blur kernel: kernel size of the blur pass.
  17705. * Only useful if useKernelBlur = true
  17706. */
  17707. get blurKernel(): number;
  17708. /**
  17709. * Sets the blur kernel: kernel size of the blur pass.
  17710. * Only useful if useKernelBlur = true
  17711. */
  17712. set blurKernel(value: number);
  17713. protected _useKernelBlur: boolean;
  17714. /**
  17715. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17716. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17717. */
  17718. get useKernelBlur(): boolean;
  17719. /**
  17720. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17721. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17722. */
  17723. set useKernelBlur(value: boolean);
  17724. protected _depthScale: number;
  17725. /**
  17726. * Gets the depth scale used in ESM mode.
  17727. */
  17728. get depthScale(): number;
  17729. /**
  17730. * Sets the depth scale used in ESM mode.
  17731. * This can override the scale stored on the light.
  17732. */
  17733. set depthScale(value: number);
  17734. protected _validateFilter(filter: number): number;
  17735. protected _filter: number;
  17736. /**
  17737. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17738. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17739. */
  17740. get filter(): number;
  17741. /**
  17742. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17743. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17744. */
  17745. set filter(value: number);
  17746. /**
  17747. * Gets if the current filter is set to Poisson Sampling.
  17748. */
  17749. get usePoissonSampling(): boolean;
  17750. /**
  17751. * Sets the current filter to Poisson Sampling.
  17752. */
  17753. set usePoissonSampling(value: boolean);
  17754. /**
  17755. * Gets if the current filter is set to ESM.
  17756. */
  17757. get useExponentialShadowMap(): boolean;
  17758. /**
  17759. * Sets the current filter is to ESM.
  17760. */
  17761. set useExponentialShadowMap(value: boolean);
  17762. /**
  17763. * Gets if the current filter is set to filtered ESM.
  17764. */
  17765. get useBlurExponentialShadowMap(): boolean;
  17766. /**
  17767. * Gets if the current filter is set to filtered ESM.
  17768. */
  17769. set useBlurExponentialShadowMap(value: boolean);
  17770. /**
  17771. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17772. * exponential to prevent steep falloff artifacts).
  17773. */
  17774. get useCloseExponentialShadowMap(): boolean;
  17775. /**
  17776. * Sets the current filter to "close ESM" (using the inverse of the
  17777. * exponential to prevent steep falloff artifacts).
  17778. */
  17779. set useCloseExponentialShadowMap(value: boolean);
  17780. /**
  17781. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17782. * exponential to prevent steep falloff artifacts).
  17783. */
  17784. get useBlurCloseExponentialShadowMap(): boolean;
  17785. /**
  17786. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17787. * exponential to prevent steep falloff artifacts).
  17788. */
  17789. set useBlurCloseExponentialShadowMap(value: boolean);
  17790. /**
  17791. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17792. */
  17793. get usePercentageCloserFiltering(): boolean;
  17794. /**
  17795. * Sets the current filter to "PCF" (percentage closer filtering).
  17796. */
  17797. set usePercentageCloserFiltering(value: boolean);
  17798. protected _filteringQuality: number;
  17799. /**
  17800. * Gets the PCF or PCSS Quality.
  17801. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17802. */
  17803. get filteringQuality(): number;
  17804. /**
  17805. * Sets the PCF or PCSS Quality.
  17806. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17807. */
  17808. set filteringQuality(filteringQuality: number);
  17809. /**
  17810. * Gets if the current filter is set to "PCSS" (contact hardening).
  17811. */
  17812. get useContactHardeningShadow(): boolean;
  17813. /**
  17814. * Sets the current filter to "PCSS" (contact hardening).
  17815. */
  17816. set useContactHardeningShadow(value: boolean);
  17817. protected _contactHardeningLightSizeUVRatio: number;
  17818. /**
  17819. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17820. * Using a ratio helps keeping shape stability independently of the map size.
  17821. *
  17822. * It does not account for the light projection as it was having too much
  17823. * instability during the light setup or during light position changes.
  17824. *
  17825. * Only valid if useContactHardeningShadow is true.
  17826. */
  17827. get contactHardeningLightSizeUVRatio(): number;
  17828. /**
  17829. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17830. * Using a ratio helps keeping shape stability independently of the map size.
  17831. *
  17832. * It does not account for the light projection as it was having too much
  17833. * instability during the light setup or during light position changes.
  17834. *
  17835. * Only valid if useContactHardeningShadow is true.
  17836. */
  17837. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17838. protected _darkness: number;
  17839. /** Gets or sets the actual darkness of a shadow */
  17840. get darkness(): number;
  17841. set darkness(value: number);
  17842. /**
  17843. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17844. * 0 means strongest and 1 would means no shadow.
  17845. * @returns the darkness.
  17846. */
  17847. getDarkness(): number;
  17848. /**
  17849. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17850. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17851. * @returns the shadow generator allowing fluent coding.
  17852. */
  17853. setDarkness(darkness: number): ShadowGenerator;
  17854. protected _transparencyShadow: boolean;
  17855. /** Gets or sets the ability to have transparent shadow */
  17856. get transparencyShadow(): boolean;
  17857. set transparencyShadow(value: boolean);
  17858. /**
  17859. * Sets the ability to have transparent shadow (boolean).
  17860. * @param transparent True if transparent else False
  17861. * @returns the shadow generator allowing fluent coding
  17862. */
  17863. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17864. /**
  17865. * Enables or disables shadows with varying strength based on the transparency
  17866. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17867. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17868. * mesh.visibility * alphaTexture.a
  17869. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17870. */
  17871. enableSoftTransparentShadow: boolean;
  17872. protected _shadowMap: Nullable<RenderTargetTexture>;
  17873. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17874. /**
  17875. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17876. * @returns The render target texture if present otherwise, null
  17877. */
  17878. getShadowMap(): Nullable<RenderTargetTexture>;
  17879. /**
  17880. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17881. * @returns The render target texture if the shadow map is present otherwise, null
  17882. */
  17883. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17884. /**
  17885. * Gets the class name of that object
  17886. * @returns "ShadowGenerator"
  17887. */
  17888. getClassName(): string;
  17889. /**
  17890. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17891. * @param mesh Mesh to add
  17892. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17893. * @returns the Shadow Generator itself
  17894. */
  17895. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17896. /**
  17897. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17898. * @param mesh Mesh to remove
  17899. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17900. * @returns the Shadow Generator itself
  17901. */
  17902. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17903. /**
  17904. * Controls the extent to which the shadows fade out at the edge of the frustum
  17905. */
  17906. frustumEdgeFalloff: number;
  17907. protected _light: IShadowLight;
  17908. /**
  17909. * Returns the associated light object.
  17910. * @returns the light generating the shadow
  17911. */
  17912. getLight(): IShadowLight;
  17913. /**
  17914. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17915. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17916. * It might on the other hand introduce peter panning.
  17917. */
  17918. forceBackFacesOnly: boolean;
  17919. protected _scene: Scene;
  17920. protected _lightDirection: Vector3;
  17921. protected _effect: Effect;
  17922. protected _viewMatrix: Matrix;
  17923. protected _projectionMatrix: Matrix;
  17924. protected _transformMatrix: Matrix;
  17925. protected _cachedPosition: Vector3;
  17926. protected _cachedDirection: Vector3;
  17927. protected _cachedDefines: string;
  17928. protected _currentRenderID: number;
  17929. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17930. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17931. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17932. protected _blurPostProcesses: PostProcess[];
  17933. protected _mapSize: number;
  17934. protected _currentFaceIndex: number;
  17935. protected _currentFaceIndexCache: number;
  17936. protected _textureType: number;
  17937. protected _defaultTextureMatrix: Matrix;
  17938. protected _storedUniqueId: Nullable<number>;
  17939. /** @hidden */
  17940. static _SceneComponentInitialization: (scene: Scene) => void;
  17941. /**
  17942. * Creates a ShadowGenerator object.
  17943. * A ShadowGenerator is the required tool to use the shadows.
  17944. * Each light casting shadows needs to use its own ShadowGenerator.
  17945. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17946. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17947. * @param light The light object generating the shadows.
  17948. * @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.
  17949. */
  17950. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17951. protected _initializeGenerator(): void;
  17952. protected _createTargetRenderTexture(): void;
  17953. protected _initializeShadowMap(): void;
  17954. protected _initializeBlurRTTAndPostProcesses(): void;
  17955. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17956. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17957. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17958. protected _applyFilterValues(): void;
  17959. /**
  17960. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17961. * @param onCompiled Callback triggered at the and of the effects compilation
  17962. * @param options Sets of optional options forcing the compilation with different modes
  17963. */
  17964. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17965. useInstances: boolean;
  17966. }>): void;
  17967. /**
  17968. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17969. * @param options Sets of optional options forcing the compilation with different modes
  17970. * @returns A promise that resolves when the compilation completes
  17971. */
  17972. forceCompilationAsync(options?: Partial<{
  17973. useInstances: boolean;
  17974. }>): Promise<void>;
  17975. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17976. private _prepareShadowDefines;
  17977. /**
  17978. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17979. * @param subMesh The submesh we want to render in the shadow map
  17980. * @param useInstances Defines wether will draw in the map using instances
  17981. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17982. * @returns true if ready otherwise, false
  17983. */
  17984. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17985. /**
  17986. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17987. * @param defines Defines of the material we want to update
  17988. * @param lightIndex Index of the light in the enabled light list of the material
  17989. */
  17990. prepareDefines(defines: any, lightIndex: number): void;
  17991. /**
  17992. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17993. * defined in the generator but impacting the effect).
  17994. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17995. * @param effect The effect we are binfing the information for
  17996. */
  17997. bindShadowLight(lightIndex: string, effect: Effect): void;
  17998. /**
  17999. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18000. * (eq to shadow prjection matrix * light transform matrix)
  18001. * @returns The transform matrix used to create the shadow map
  18002. */
  18003. getTransformMatrix(): Matrix;
  18004. /**
  18005. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18006. * Cube and 2D textures for instance.
  18007. */
  18008. recreateShadowMap(): void;
  18009. protected _disposeBlurPostProcesses(): void;
  18010. protected _disposeRTTandPostProcesses(): void;
  18011. /**
  18012. * Disposes the ShadowGenerator.
  18013. * Returns nothing.
  18014. */
  18015. dispose(): void;
  18016. /**
  18017. * Serializes the shadow generator setup to a json object.
  18018. * @returns The serialized JSON object
  18019. */
  18020. serialize(): any;
  18021. /**
  18022. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18023. * @param parsedShadowGenerator The JSON object to parse
  18024. * @param scene The scene to create the shadow map for
  18025. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18026. * @returns The parsed shadow generator
  18027. */
  18028. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18029. }
  18030. }
  18031. declare module BABYLON {
  18032. /**
  18033. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18034. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18035. * 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.
  18036. */
  18037. export abstract class Light extends Node {
  18038. /**
  18039. * Falloff Default: light is falling off following the material specification:
  18040. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18041. */
  18042. static readonly FALLOFF_DEFAULT: number;
  18043. /**
  18044. * Falloff Physical: light is falling off following the inverse squared distance law.
  18045. */
  18046. static readonly FALLOFF_PHYSICAL: number;
  18047. /**
  18048. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18049. * to enhance interoperability with other engines.
  18050. */
  18051. static readonly FALLOFF_GLTF: number;
  18052. /**
  18053. * Falloff Standard: light is falling off like in the standard material
  18054. * to enhance interoperability with other materials.
  18055. */
  18056. static readonly FALLOFF_STANDARD: number;
  18057. /**
  18058. * If every light affecting the material is in this lightmapMode,
  18059. * material.lightmapTexture adds or multiplies
  18060. * (depends on material.useLightmapAsShadowmap)
  18061. * after every other light calculations.
  18062. */
  18063. static readonly LIGHTMAP_DEFAULT: number;
  18064. /**
  18065. * material.lightmapTexture as only diffuse lighting from this light
  18066. * adds only specular lighting from this light
  18067. * adds dynamic shadows
  18068. */
  18069. static readonly LIGHTMAP_SPECULAR: number;
  18070. /**
  18071. * material.lightmapTexture as only lighting
  18072. * no light calculation from this light
  18073. * only adds dynamic shadows from this light
  18074. */
  18075. static readonly LIGHTMAP_SHADOWSONLY: number;
  18076. /**
  18077. * Each light type uses the default quantity according to its type:
  18078. * point/spot lights use luminous intensity
  18079. * directional lights use illuminance
  18080. */
  18081. static readonly INTENSITYMODE_AUTOMATIC: number;
  18082. /**
  18083. * lumen (lm)
  18084. */
  18085. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18086. /**
  18087. * candela (lm/sr)
  18088. */
  18089. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18090. /**
  18091. * lux (lm/m^2)
  18092. */
  18093. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18094. /**
  18095. * nit (cd/m^2)
  18096. */
  18097. static readonly INTENSITYMODE_LUMINANCE: number;
  18098. /**
  18099. * Light type const id of the point light.
  18100. */
  18101. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18102. /**
  18103. * Light type const id of the directional light.
  18104. */
  18105. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18106. /**
  18107. * Light type const id of the spot light.
  18108. */
  18109. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18110. /**
  18111. * Light type const id of the hemispheric light.
  18112. */
  18113. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18114. /**
  18115. * Diffuse gives the basic color to an object.
  18116. */
  18117. diffuse: Color3;
  18118. /**
  18119. * Specular produces a highlight color on an object.
  18120. * Note: This is note affecting PBR materials.
  18121. */
  18122. specular: Color3;
  18123. /**
  18124. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18125. * falling off base on range or angle.
  18126. * This can be set to any values in Light.FALLOFF_x.
  18127. *
  18128. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18129. * other types of materials.
  18130. */
  18131. falloffType: number;
  18132. /**
  18133. * Strength of the light.
  18134. * Note: By default it is define in the framework own unit.
  18135. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18136. */
  18137. intensity: number;
  18138. private _range;
  18139. protected _inverseSquaredRange: number;
  18140. /**
  18141. * Defines how far from the source the light is impacting in scene units.
  18142. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18143. */
  18144. get range(): number;
  18145. /**
  18146. * Defines how far from the source the light is impacting in scene units.
  18147. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18148. */
  18149. set range(value: number);
  18150. /**
  18151. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18152. * of light.
  18153. */
  18154. private _photometricScale;
  18155. private _intensityMode;
  18156. /**
  18157. * Gets the photometric scale used to interpret the intensity.
  18158. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18159. */
  18160. get intensityMode(): number;
  18161. /**
  18162. * Sets the photometric scale used to interpret the intensity.
  18163. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18164. */
  18165. set intensityMode(value: number);
  18166. private _radius;
  18167. /**
  18168. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18169. */
  18170. get radius(): number;
  18171. /**
  18172. * sets the light radius used by PBR Materials to simulate soft area lights.
  18173. */
  18174. set radius(value: number);
  18175. private _renderPriority;
  18176. /**
  18177. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18178. * exceeding the number allowed of the materials.
  18179. */
  18180. renderPriority: number;
  18181. private _shadowEnabled;
  18182. /**
  18183. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18184. * the current shadow generator.
  18185. */
  18186. get shadowEnabled(): boolean;
  18187. /**
  18188. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18189. * the current shadow generator.
  18190. */
  18191. set shadowEnabled(value: boolean);
  18192. private _includedOnlyMeshes;
  18193. /**
  18194. * Gets the only meshes impacted by this light.
  18195. */
  18196. get includedOnlyMeshes(): AbstractMesh[];
  18197. /**
  18198. * Sets the only meshes impacted by this light.
  18199. */
  18200. set includedOnlyMeshes(value: AbstractMesh[]);
  18201. private _excludedMeshes;
  18202. /**
  18203. * Gets the meshes not impacted by this light.
  18204. */
  18205. get excludedMeshes(): AbstractMesh[];
  18206. /**
  18207. * Sets the meshes not impacted by this light.
  18208. */
  18209. set excludedMeshes(value: AbstractMesh[]);
  18210. private _excludeWithLayerMask;
  18211. /**
  18212. * Gets the layer id use to find what meshes are not impacted by the light.
  18213. * Inactive if 0
  18214. */
  18215. get excludeWithLayerMask(): number;
  18216. /**
  18217. * Sets the layer id use to find what meshes are not impacted by the light.
  18218. * Inactive if 0
  18219. */
  18220. set excludeWithLayerMask(value: number);
  18221. private _includeOnlyWithLayerMask;
  18222. /**
  18223. * Gets the layer id use to find what meshes are impacted by the light.
  18224. * Inactive if 0
  18225. */
  18226. get includeOnlyWithLayerMask(): number;
  18227. /**
  18228. * Sets the layer id use to find what meshes are impacted by the light.
  18229. * Inactive if 0
  18230. */
  18231. set includeOnlyWithLayerMask(value: number);
  18232. private _lightmapMode;
  18233. /**
  18234. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18235. */
  18236. get lightmapMode(): number;
  18237. /**
  18238. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18239. */
  18240. set lightmapMode(value: number);
  18241. /**
  18242. * Shadow generator associted to the light.
  18243. * @hidden Internal use only.
  18244. */
  18245. _shadowGenerator: Nullable<IShadowGenerator>;
  18246. /**
  18247. * @hidden Internal use only.
  18248. */
  18249. _excludedMeshesIds: string[];
  18250. /**
  18251. * @hidden Internal use only.
  18252. */
  18253. _includedOnlyMeshesIds: string[];
  18254. /**
  18255. * The current light unifom buffer.
  18256. * @hidden Internal use only.
  18257. */
  18258. _uniformBuffer: UniformBuffer;
  18259. /** @hidden */
  18260. _renderId: number;
  18261. /**
  18262. * Creates a Light object in the scene.
  18263. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18264. * @param name The firendly name of the light
  18265. * @param scene The scene the light belongs too
  18266. */
  18267. constructor(name: string, scene: Scene);
  18268. protected abstract _buildUniformLayout(): void;
  18269. /**
  18270. * Sets the passed Effect "effect" with the Light information.
  18271. * @param effect The effect to update
  18272. * @param lightIndex The index of the light in the effect to update
  18273. * @returns The light
  18274. */
  18275. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18276. /**
  18277. * Sets the passed Effect "effect" with the Light textures.
  18278. * @param effect The effect to update
  18279. * @param lightIndex The index of the light in the effect to update
  18280. * @returns The light
  18281. */
  18282. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18283. /**
  18284. * Binds the lights information from the scene to the effect for the given mesh.
  18285. * @param lightIndex Light index
  18286. * @param scene The scene where the light belongs to
  18287. * @param effect The effect we are binding the data to
  18288. * @param useSpecular Defines if specular is supported
  18289. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18290. */
  18291. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18292. /**
  18293. * Sets the passed Effect "effect" with the Light information.
  18294. * @param effect The effect to update
  18295. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18296. * @returns The light
  18297. */
  18298. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18299. /**
  18300. * Returns the string "Light".
  18301. * @returns the class name
  18302. */
  18303. getClassName(): string;
  18304. /** @hidden */
  18305. readonly _isLight: boolean;
  18306. /**
  18307. * Converts the light information to a readable string for debug purpose.
  18308. * @param fullDetails Supports for multiple levels of logging within scene loading
  18309. * @returns the human readable light info
  18310. */
  18311. toString(fullDetails?: boolean): string;
  18312. /** @hidden */
  18313. protected _syncParentEnabledState(): void;
  18314. /**
  18315. * Set the enabled state of this node.
  18316. * @param value - the new enabled state
  18317. */
  18318. setEnabled(value: boolean): void;
  18319. /**
  18320. * Returns the Light associated shadow generator if any.
  18321. * @return the associated shadow generator.
  18322. */
  18323. getShadowGenerator(): Nullable<IShadowGenerator>;
  18324. /**
  18325. * Returns a Vector3, the absolute light position in the World.
  18326. * @returns the world space position of the light
  18327. */
  18328. getAbsolutePosition(): Vector3;
  18329. /**
  18330. * Specifies if the light will affect the passed mesh.
  18331. * @param mesh The mesh to test against the light
  18332. * @return true the mesh is affected otherwise, false.
  18333. */
  18334. canAffectMesh(mesh: AbstractMesh): boolean;
  18335. /**
  18336. * Sort function to order lights for rendering.
  18337. * @param a First Light object to compare to second.
  18338. * @param b Second Light object to compare first.
  18339. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18340. */
  18341. static CompareLightsPriority(a: Light, b: Light): number;
  18342. /**
  18343. * Releases resources associated with this node.
  18344. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18345. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18346. */
  18347. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18348. /**
  18349. * Returns the light type ID (integer).
  18350. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18351. */
  18352. getTypeID(): number;
  18353. /**
  18354. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18355. * @returns the scaled intensity in intensity mode unit
  18356. */
  18357. getScaledIntensity(): number;
  18358. /**
  18359. * Returns a new Light object, named "name", from the current one.
  18360. * @param name The name of the cloned light
  18361. * @param newParent The parent of this light, if it has one
  18362. * @returns the new created light
  18363. */
  18364. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18365. /**
  18366. * Serializes the current light into a Serialization object.
  18367. * @returns the serialized object.
  18368. */
  18369. serialize(): any;
  18370. /**
  18371. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18372. * This new light is named "name" and added to the passed scene.
  18373. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18374. * @param name The friendly name of the light
  18375. * @param scene The scene the new light will belong to
  18376. * @returns the constructor function
  18377. */
  18378. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18379. /**
  18380. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18381. * @param parsedLight The JSON representation of the light
  18382. * @param scene The scene to create the parsed light in
  18383. * @returns the created light after parsing
  18384. */
  18385. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18386. private _hookArrayForExcluded;
  18387. private _hookArrayForIncludedOnly;
  18388. private _resyncMeshes;
  18389. /**
  18390. * Forces the meshes to update their light related information in their rendering used effects
  18391. * @hidden Internal Use Only
  18392. */
  18393. _markMeshesAsLightDirty(): void;
  18394. /**
  18395. * Recomputes the cached photometric scale if needed.
  18396. */
  18397. private _computePhotometricScale;
  18398. /**
  18399. * Returns the Photometric Scale according to the light type and intensity mode.
  18400. */
  18401. private _getPhotometricScale;
  18402. /**
  18403. * Reorder the light in the scene according to their defined priority.
  18404. * @hidden Internal Use Only
  18405. */
  18406. _reorderLightsInScene(): void;
  18407. /**
  18408. * Prepares the list of defines specific to the light type.
  18409. * @param defines the list of defines
  18410. * @param lightIndex defines the index of the light for the effect
  18411. */
  18412. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18413. }
  18414. }
  18415. declare module BABYLON {
  18416. /**
  18417. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18418. * This is the base of the follow, arc rotate cameras and Free camera
  18419. * @see https://doc.babylonjs.com/features/cameras
  18420. */
  18421. export class TargetCamera extends Camera {
  18422. private static _RigCamTransformMatrix;
  18423. private static _TargetTransformMatrix;
  18424. private static _TargetFocalPoint;
  18425. private _tmpUpVector;
  18426. private _tmpTargetVector;
  18427. /**
  18428. * Define the current direction the camera is moving to
  18429. */
  18430. cameraDirection: Vector3;
  18431. /**
  18432. * Define the current rotation the camera is rotating to
  18433. */
  18434. cameraRotation: Vector2;
  18435. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18436. ignoreParentScaling: boolean;
  18437. /**
  18438. * When set, the up vector of the camera will be updated by the rotation of the camera
  18439. */
  18440. updateUpVectorFromRotation: boolean;
  18441. private _tmpQuaternion;
  18442. /**
  18443. * Define the current rotation of the camera
  18444. */
  18445. rotation: Vector3;
  18446. /**
  18447. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18448. */
  18449. rotationQuaternion: Quaternion;
  18450. /**
  18451. * Define the current speed of the camera
  18452. */
  18453. speed: number;
  18454. /**
  18455. * Add constraint to the camera to prevent it to move freely in all directions and
  18456. * around all axis.
  18457. */
  18458. noRotationConstraint: boolean;
  18459. /**
  18460. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18461. * panning
  18462. */
  18463. invertRotation: boolean;
  18464. /**
  18465. * Speed multiplier for inverse camera panning
  18466. */
  18467. inverseRotationSpeed: number;
  18468. /**
  18469. * Define the current target of the camera as an object or a position.
  18470. */
  18471. lockedTarget: any;
  18472. /** @hidden */
  18473. _currentTarget: Vector3;
  18474. /** @hidden */
  18475. _initialFocalDistance: number;
  18476. /** @hidden */
  18477. _viewMatrix: Matrix;
  18478. /** @hidden */
  18479. _camMatrix: Matrix;
  18480. /** @hidden */
  18481. _cameraTransformMatrix: Matrix;
  18482. /** @hidden */
  18483. _cameraRotationMatrix: Matrix;
  18484. /** @hidden */
  18485. _referencePoint: Vector3;
  18486. /** @hidden */
  18487. _transformedReferencePoint: Vector3;
  18488. /** @hidden */
  18489. _reset: () => void;
  18490. private _defaultUp;
  18491. /**
  18492. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18493. * This is the base of the follow, arc rotate cameras and Free camera
  18494. * @see https://doc.babylonjs.com/features/cameras
  18495. * @param name Defines the name of the camera in the scene
  18496. * @param position Defines the start position of the camera in the scene
  18497. * @param scene Defines the scene the camera belongs to
  18498. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18499. */
  18500. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18501. /**
  18502. * Gets the position in front of the camera at a given distance.
  18503. * @param distance The distance from the camera we want the position to be
  18504. * @returns the position
  18505. */
  18506. getFrontPosition(distance: number): Vector3;
  18507. /** @hidden */
  18508. _getLockedTargetPosition(): Nullable<Vector3>;
  18509. private _storedPosition;
  18510. private _storedRotation;
  18511. private _storedRotationQuaternion;
  18512. /**
  18513. * Store current camera state of the camera (fov, position, rotation, etc..)
  18514. * @returns the camera
  18515. */
  18516. storeState(): Camera;
  18517. /**
  18518. * Restored camera state. You must call storeState() first
  18519. * @returns whether it was successful or not
  18520. * @hidden
  18521. */
  18522. _restoreStateValues(): boolean;
  18523. /** @hidden */
  18524. _initCache(): void;
  18525. /** @hidden */
  18526. _updateCache(ignoreParentClass?: boolean): void;
  18527. /** @hidden */
  18528. _isSynchronizedViewMatrix(): boolean;
  18529. /** @hidden */
  18530. _computeLocalCameraSpeed(): number;
  18531. /**
  18532. * Defines the target the camera should look at.
  18533. * @param target Defines the new target as a Vector or a mesh
  18534. */
  18535. setTarget(target: Vector3): void;
  18536. /**
  18537. * Defines the target point of the camera.
  18538. * The camera looks towards it form the radius distance.
  18539. */
  18540. get target(): Vector3;
  18541. set target(value: Vector3);
  18542. /**
  18543. * Return the current target position of the camera. This value is expressed in local space.
  18544. * @returns the target position
  18545. */
  18546. getTarget(): Vector3;
  18547. /** @hidden */
  18548. _decideIfNeedsToMove(): boolean;
  18549. /** @hidden */
  18550. _updatePosition(): void;
  18551. /** @hidden */
  18552. _checkInputs(): void;
  18553. protected _updateCameraRotationMatrix(): void;
  18554. /**
  18555. * 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)
  18556. * @returns the current camera
  18557. */
  18558. private _rotateUpVectorWithCameraRotationMatrix;
  18559. private _cachedRotationZ;
  18560. private _cachedQuaternionRotationZ;
  18561. /** @hidden */
  18562. _getViewMatrix(): Matrix;
  18563. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18564. /**
  18565. * @hidden
  18566. */
  18567. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18568. /**
  18569. * @hidden
  18570. */
  18571. _updateRigCameras(): void;
  18572. private _getRigCamPositionAndTarget;
  18573. /**
  18574. * Gets the current object class name.
  18575. * @return the class name
  18576. */
  18577. getClassName(): string;
  18578. }
  18579. }
  18580. declare module BABYLON {
  18581. /**
  18582. * Gather the list of keyboard event types as constants.
  18583. */
  18584. export class KeyboardEventTypes {
  18585. /**
  18586. * The keydown event is fired when a key becomes active (pressed).
  18587. */
  18588. static readonly KEYDOWN: number;
  18589. /**
  18590. * The keyup event is fired when a key has been released.
  18591. */
  18592. static readonly KEYUP: number;
  18593. }
  18594. /**
  18595. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18596. */
  18597. export class KeyboardInfo {
  18598. /**
  18599. * Defines the type of event (KeyboardEventTypes)
  18600. */
  18601. type: number;
  18602. /**
  18603. * Defines the related dom event
  18604. */
  18605. event: KeyboardEvent;
  18606. /**
  18607. * Instantiates a new keyboard info.
  18608. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18609. * @param type Defines the type of event (KeyboardEventTypes)
  18610. * @param event Defines the related dom event
  18611. */
  18612. constructor(
  18613. /**
  18614. * Defines the type of event (KeyboardEventTypes)
  18615. */
  18616. type: number,
  18617. /**
  18618. * Defines the related dom event
  18619. */
  18620. event: KeyboardEvent);
  18621. }
  18622. /**
  18623. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18624. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18625. */
  18626. export class KeyboardInfoPre extends KeyboardInfo {
  18627. /**
  18628. * Defines the type of event (KeyboardEventTypes)
  18629. */
  18630. type: number;
  18631. /**
  18632. * Defines the related dom event
  18633. */
  18634. event: KeyboardEvent;
  18635. /**
  18636. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18637. */
  18638. skipOnPointerObservable: boolean;
  18639. /**
  18640. * Instantiates a new keyboard pre info.
  18641. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18642. * @param type Defines the type of event (KeyboardEventTypes)
  18643. * @param event Defines the related dom event
  18644. */
  18645. constructor(
  18646. /**
  18647. * Defines the type of event (KeyboardEventTypes)
  18648. */
  18649. type: number,
  18650. /**
  18651. * Defines the related dom event
  18652. */
  18653. event: KeyboardEvent);
  18654. }
  18655. }
  18656. declare module BABYLON {
  18657. /**
  18658. * Manage the keyboard inputs to control the movement of a free camera.
  18659. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18660. */
  18661. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18662. /**
  18663. * Defines the camera the input is attached to.
  18664. */
  18665. camera: FreeCamera;
  18666. /**
  18667. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18668. */
  18669. keysUp: number[];
  18670. /**
  18671. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18672. */
  18673. keysUpward: number[];
  18674. /**
  18675. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18676. */
  18677. keysDown: number[];
  18678. /**
  18679. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18680. */
  18681. keysDownward: number[];
  18682. /**
  18683. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18684. */
  18685. keysLeft: number[];
  18686. /**
  18687. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18688. */
  18689. keysRight: number[];
  18690. private _keys;
  18691. private _onCanvasBlurObserver;
  18692. private _onKeyboardObserver;
  18693. private _engine;
  18694. private _scene;
  18695. /**
  18696. * Attach the input controls to a specific dom element to get the input from.
  18697. * @param element Defines the element the controls should be listened from
  18698. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18699. */
  18700. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18701. /**
  18702. * Detach the current controls from the specified dom element.
  18703. * @param element Defines the element to stop listening the inputs from
  18704. */
  18705. detachControl(element: Nullable<HTMLElement>): void;
  18706. /**
  18707. * Update the current camera state depending on the inputs that have been used this frame.
  18708. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18709. */
  18710. checkInputs(): void;
  18711. /**
  18712. * Gets the class name of the current intput.
  18713. * @returns the class name
  18714. */
  18715. getClassName(): string;
  18716. /** @hidden */
  18717. _onLostFocus(): void;
  18718. /**
  18719. * Get the friendly name associated with the input class.
  18720. * @returns the input friendly name
  18721. */
  18722. getSimpleName(): string;
  18723. }
  18724. }
  18725. declare module BABYLON {
  18726. /**
  18727. * Gather the list of pointer event types as constants.
  18728. */
  18729. export class PointerEventTypes {
  18730. /**
  18731. * 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.
  18732. */
  18733. static readonly POINTERDOWN: number;
  18734. /**
  18735. * The pointerup event is fired when a pointer is no longer active.
  18736. */
  18737. static readonly POINTERUP: number;
  18738. /**
  18739. * The pointermove event is fired when a pointer changes coordinates.
  18740. */
  18741. static readonly POINTERMOVE: number;
  18742. /**
  18743. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18744. */
  18745. static readonly POINTERWHEEL: number;
  18746. /**
  18747. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18748. */
  18749. static readonly POINTERPICK: number;
  18750. /**
  18751. * The pointertap event is fired when a the object has been touched and released without drag.
  18752. */
  18753. static readonly POINTERTAP: number;
  18754. /**
  18755. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18756. */
  18757. static readonly POINTERDOUBLETAP: number;
  18758. }
  18759. /**
  18760. * Base class of pointer info types.
  18761. */
  18762. export class PointerInfoBase {
  18763. /**
  18764. * Defines the type of event (PointerEventTypes)
  18765. */
  18766. type: number;
  18767. /**
  18768. * Defines the related dom event
  18769. */
  18770. event: PointerEvent | MouseWheelEvent;
  18771. /**
  18772. * Instantiates the base class of pointers info.
  18773. * @param type Defines the type of event (PointerEventTypes)
  18774. * @param event Defines the related dom event
  18775. */
  18776. constructor(
  18777. /**
  18778. * Defines the type of event (PointerEventTypes)
  18779. */
  18780. type: number,
  18781. /**
  18782. * Defines the related dom event
  18783. */
  18784. event: PointerEvent | MouseWheelEvent);
  18785. }
  18786. /**
  18787. * This class is used to store pointer related info for the onPrePointerObservable event.
  18788. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18789. */
  18790. export class PointerInfoPre extends PointerInfoBase {
  18791. /**
  18792. * Ray from a pointer if availible (eg. 6dof controller)
  18793. */
  18794. ray: Nullable<Ray>;
  18795. /**
  18796. * Defines the local position of the pointer on the canvas.
  18797. */
  18798. localPosition: Vector2;
  18799. /**
  18800. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18801. */
  18802. skipOnPointerObservable: boolean;
  18803. /**
  18804. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18805. * @param type Defines the type of event (PointerEventTypes)
  18806. * @param event Defines the related dom event
  18807. * @param localX Defines the local x coordinates of the pointer when the event occured
  18808. * @param localY Defines the local y coordinates of the pointer when the event occured
  18809. */
  18810. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18811. }
  18812. /**
  18813. * This type contains all the data related to a pointer event in Babylon.js.
  18814. * 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.
  18815. */
  18816. export class PointerInfo extends PointerInfoBase {
  18817. /**
  18818. * Defines the picking info associated to the info (if any)\
  18819. */
  18820. pickInfo: Nullable<PickingInfo>;
  18821. /**
  18822. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18823. * @param type Defines the type of event (PointerEventTypes)
  18824. * @param event Defines the related dom event
  18825. * @param pickInfo Defines the picking info associated to the info (if any)\
  18826. */
  18827. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18828. /**
  18829. * Defines the picking info associated to the info (if any)\
  18830. */
  18831. pickInfo: Nullable<PickingInfo>);
  18832. }
  18833. /**
  18834. * Data relating to a touch event on the screen.
  18835. */
  18836. export interface PointerTouch {
  18837. /**
  18838. * X coordinate of touch.
  18839. */
  18840. x: number;
  18841. /**
  18842. * Y coordinate of touch.
  18843. */
  18844. y: number;
  18845. /**
  18846. * Id of touch. Unique for each finger.
  18847. */
  18848. pointerId: number;
  18849. /**
  18850. * Event type passed from DOM.
  18851. */
  18852. type: any;
  18853. }
  18854. }
  18855. declare module BABYLON {
  18856. /**
  18857. * Manage the mouse inputs to control the movement of a free camera.
  18858. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18859. */
  18860. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18861. /**
  18862. * Define if touch is enabled in the mouse input
  18863. */
  18864. touchEnabled: boolean;
  18865. /**
  18866. * Defines the camera the input is attached to.
  18867. */
  18868. camera: FreeCamera;
  18869. /**
  18870. * Defines the buttons associated with the input to handle camera move.
  18871. */
  18872. buttons: number[];
  18873. /**
  18874. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18875. */
  18876. angularSensibility: number;
  18877. private _pointerInput;
  18878. private _onMouseMove;
  18879. private _observer;
  18880. private previousPosition;
  18881. /**
  18882. * Observable for when a pointer move event occurs containing the move offset
  18883. */
  18884. onPointerMovedObservable: Observable<{
  18885. offsetX: number;
  18886. offsetY: number;
  18887. }>;
  18888. /**
  18889. * @hidden
  18890. * If the camera should be rotated automatically based on pointer movement
  18891. */
  18892. _allowCameraRotation: boolean;
  18893. /**
  18894. * Manage the mouse inputs to control the movement of a free camera.
  18895. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18896. * @param touchEnabled Defines if touch is enabled or not
  18897. */
  18898. constructor(
  18899. /**
  18900. * Define if touch is enabled in the mouse input
  18901. */
  18902. touchEnabled?: boolean);
  18903. /**
  18904. * Attach the input controls to a specific dom element to get the input from.
  18905. * @param element Defines the element the controls should be listened from
  18906. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18907. */
  18908. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18909. /**
  18910. * Called on JS contextmenu event.
  18911. * Override this method to provide functionality.
  18912. */
  18913. protected onContextMenu(evt: PointerEvent): void;
  18914. /**
  18915. * Detach the current controls from the specified dom element.
  18916. * @param element Defines the element to stop listening the inputs from
  18917. */
  18918. detachControl(element: Nullable<HTMLElement>): void;
  18919. /**
  18920. * Gets the class name of the current intput.
  18921. * @returns the class name
  18922. */
  18923. getClassName(): string;
  18924. /**
  18925. * Get the friendly name associated with the input class.
  18926. * @returns the input friendly name
  18927. */
  18928. getSimpleName(): string;
  18929. }
  18930. }
  18931. declare module BABYLON {
  18932. /**
  18933. * Manage the touch inputs to control the movement of a free camera.
  18934. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18935. */
  18936. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18937. /**
  18938. * Define if mouse events can be treated as touch events
  18939. */
  18940. allowMouse: boolean;
  18941. /**
  18942. * Defines the camera the input is attached to.
  18943. */
  18944. camera: FreeCamera;
  18945. /**
  18946. * Defines the touch sensibility for rotation.
  18947. * The higher the faster.
  18948. */
  18949. touchAngularSensibility: number;
  18950. /**
  18951. * Defines the touch sensibility for move.
  18952. * The higher the faster.
  18953. */
  18954. touchMoveSensibility: number;
  18955. private _offsetX;
  18956. private _offsetY;
  18957. private _pointerPressed;
  18958. private _pointerInput;
  18959. private _observer;
  18960. private _onLostFocus;
  18961. /**
  18962. * Manage the touch inputs to control the movement of a free camera.
  18963. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18964. * @param allowMouse Defines if mouse events can be treated as touch events
  18965. */
  18966. constructor(
  18967. /**
  18968. * Define if mouse events can be treated as touch events
  18969. */
  18970. allowMouse?: boolean);
  18971. /**
  18972. * Attach the input controls to a specific dom element to get the input from.
  18973. * @param element Defines the element the controls should be listened from
  18974. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18975. */
  18976. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18977. /**
  18978. * Detach the current controls from the specified dom element.
  18979. * @param element Defines the element to stop listening the inputs from
  18980. */
  18981. detachControl(element: Nullable<HTMLElement>): void;
  18982. /**
  18983. * Update the current camera state depending on the inputs that have been used this frame.
  18984. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18985. */
  18986. checkInputs(): void;
  18987. /**
  18988. * Gets the class name of the current intput.
  18989. * @returns the class name
  18990. */
  18991. getClassName(): string;
  18992. /**
  18993. * Get the friendly name associated with the input class.
  18994. * @returns the input friendly name
  18995. */
  18996. getSimpleName(): string;
  18997. }
  18998. }
  18999. declare module BABYLON {
  19000. /**
  19001. * Default Inputs manager for the FreeCamera.
  19002. * It groups all the default supported inputs for ease of use.
  19003. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19004. */
  19005. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19006. /**
  19007. * @hidden
  19008. */
  19009. _mouseInput: Nullable<FreeCameraMouseInput>;
  19010. /**
  19011. * Instantiates a new FreeCameraInputsManager.
  19012. * @param camera Defines the camera the inputs belong to
  19013. */
  19014. constructor(camera: FreeCamera);
  19015. /**
  19016. * Add keyboard input support to the input manager.
  19017. * @returns the current input manager
  19018. */
  19019. addKeyboard(): FreeCameraInputsManager;
  19020. /**
  19021. * Add mouse input support to the input manager.
  19022. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19023. * @returns the current input manager
  19024. */
  19025. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19026. /**
  19027. * Removes the mouse input support from the manager
  19028. * @returns the current input manager
  19029. */
  19030. removeMouse(): FreeCameraInputsManager;
  19031. /**
  19032. * Add touch input support to the input manager.
  19033. * @returns the current input manager
  19034. */
  19035. addTouch(): FreeCameraInputsManager;
  19036. /**
  19037. * Remove all attached input methods from a camera
  19038. */
  19039. clear(): void;
  19040. }
  19041. }
  19042. declare module BABYLON {
  19043. /**
  19044. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19045. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19046. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19047. */
  19048. export class FreeCamera extends TargetCamera {
  19049. /**
  19050. * Define the collision ellipsoid of the camera.
  19051. * This is helpful to simulate a camera body like the player body around the camera
  19052. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19053. */
  19054. ellipsoid: Vector3;
  19055. /**
  19056. * Define an offset for the position of the ellipsoid around the camera.
  19057. * This can be helpful to determine the center of the body near the gravity center of the body
  19058. * instead of its head.
  19059. */
  19060. ellipsoidOffset: Vector3;
  19061. /**
  19062. * Enable or disable collisions of the camera with the rest of the scene objects.
  19063. */
  19064. checkCollisions: boolean;
  19065. /**
  19066. * Enable or disable gravity on the camera.
  19067. */
  19068. applyGravity: boolean;
  19069. /**
  19070. * Define the input manager associated to the camera.
  19071. */
  19072. inputs: FreeCameraInputsManager;
  19073. /**
  19074. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19075. * Higher values reduce sensitivity.
  19076. */
  19077. get angularSensibility(): number;
  19078. /**
  19079. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19080. * Higher values reduce sensitivity.
  19081. */
  19082. set angularSensibility(value: number);
  19083. /**
  19084. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19085. */
  19086. get keysUp(): number[];
  19087. set keysUp(value: number[]);
  19088. /**
  19089. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19090. */
  19091. get keysUpward(): number[];
  19092. set keysUpward(value: number[]);
  19093. /**
  19094. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19095. */
  19096. get keysDown(): number[];
  19097. set keysDown(value: number[]);
  19098. /**
  19099. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19100. */
  19101. get keysDownward(): number[];
  19102. set keysDownward(value: number[]);
  19103. /**
  19104. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19105. */
  19106. get keysLeft(): number[];
  19107. set keysLeft(value: number[]);
  19108. /**
  19109. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19110. */
  19111. get keysRight(): number[];
  19112. set keysRight(value: number[]);
  19113. /**
  19114. * Event raised when the camera collide with a mesh in the scene.
  19115. */
  19116. onCollide: (collidedMesh: AbstractMesh) => void;
  19117. private _collider;
  19118. private _needMoveForGravity;
  19119. private _oldPosition;
  19120. private _diffPosition;
  19121. private _newPosition;
  19122. /** @hidden */
  19123. _localDirection: Vector3;
  19124. /** @hidden */
  19125. _transformedDirection: Vector3;
  19126. /**
  19127. * Instantiates a Free Camera.
  19128. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19129. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19130. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19131. * @param name Define the name of the camera in the scene
  19132. * @param position Define the start position of the camera in the scene
  19133. * @param scene Define the scene the camera belongs to
  19134. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19135. */
  19136. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19137. /**
  19138. * Attached controls to the current camera.
  19139. * @param element Defines the element the controls should be listened from
  19140. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19141. */
  19142. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19143. /**
  19144. * Detach the current controls from the camera.
  19145. * The camera will stop reacting to inputs.
  19146. * @param element Defines the element to stop listening the inputs from
  19147. */
  19148. detachControl(element: HTMLElement): void;
  19149. private _collisionMask;
  19150. /**
  19151. * Define a collision mask to limit the list of object the camera can collide with
  19152. */
  19153. get collisionMask(): number;
  19154. set collisionMask(mask: number);
  19155. /** @hidden */
  19156. _collideWithWorld(displacement: Vector3): void;
  19157. private _onCollisionPositionChange;
  19158. /** @hidden */
  19159. _checkInputs(): void;
  19160. /** @hidden */
  19161. _decideIfNeedsToMove(): boolean;
  19162. /** @hidden */
  19163. _updatePosition(): void;
  19164. /**
  19165. * Destroy the camera and release the current resources hold by it.
  19166. */
  19167. dispose(): void;
  19168. /**
  19169. * Gets the current object class name.
  19170. * @return the class name
  19171. */
  19172. getClassName(): string;
  19173. }
  19174. }
  19175. declare module BABYLON {
  19176. /**
  19177. * Represents a gamepad control stick position
  19178. */
  19179. export class StickValues {
  19180. /**
  19181. * The x component of the control stick
  19182. */
  19183. x: number;
  19184. /**
  19185. * The y component of the control stick
  19186. */
  19187. y: number;
  19188. /**
  19189. * Initializes the gamepad x and y control stick values
  19190. * @param x The x component of the gamepad control stick value
  19191. * @param y The y component of the gamepad control stick value
  19192. */
  19193. constructor(
  19194. /**
  19195. * The x component of the control stick
  19196. */
  19197. x: number,
  19198. /**
  19199. * The y component of the control stick
  19200. */
  19201. y: number);
  19202. }
  19203. /**
  19204. * An interface which manages callbacks for gamepad button changes
  19205. */
  19206. export interface GamepadButtonChanges {
  19207. /**
  19208. * Called when a gamepad has been changed
  19209. */
  19210. changed: boolean;
  19211. /**
  19212. * Called when a gamepad press event has been triggered
  19213. */
  19214. pressChanged: boolean;
  19215. /**
  19216. * Called when a touch event has been triggered
  19217. */
  19218. touchChanged: boolean;
  19219. /**
  19220. * Called when a value has changed
  19221. */
  19222. valueChanged: boolean;
  19223. }
  19224. /**
  19225. * Represents a gamepad
  19226. */
  19227. export class Gamepad {
  19228. /**
  19229. * The id of the gamepad
  19230. */
  19231. id: string;
  19232. /**
  19233. * The index of the gamepad
  19234. */
  19235. index: number;
  19236. /**
  19237. * The browser gamepad
  19238. */
  19239. browserGamepad: any;
  19240. /**
  19241. * Specifies what type of gamepad this represents
  19242. */
  19243. type: number;
  19244. private _leftStick;
  19245. private _rightStick;
  19246. /** @hidden */
  19247. _isConnected: boolean;
  19248. private _leftStickAxisX;
  19249. private _leftStickAxisY;
  19250. private _rightStickAxisX;
  19251. private _rightStickAxisY;
  19252. /**
  19253. * Triggered when the left control stick has been changed
  19254. */
  19255. private _onleftstickchanged;
  19256. /**
  19257. * Triggered when the right control stick has been changed
  19258. */
  19259. private _onrightstickchanged;
  19260. /**
  19261. * Represents a gamepad controller
  19262. */
  19263. static GAMEPAD: number;
  19264. /**
  19265. * Represents a generic controller
  19266. */
  19267. static GENERIC: number;
  19268. /**
  19269. * Represents an XBox controller
  19270. */
  19271. static XBOX: number;
  19272. /**
  19273. * Represents a pose-enabled controller
  19274. */
  19275. static POSE_ENABLED: number;
  19276. /**
  19277. * Represents an Dual Shock controller
  19278. */
  19279. static DUALSHOCK: number;
  19280. /**
  19281. * Specifies whether the left control stick should be Y-inverted
  19282. */
  19283. protected _invertLeftStickY: boolean;
  19284. /**
  19285. * Specifies if the gamepad has been connected
  19286. */
  19287. get isConnected(): boolean;
  19288. /**
  19289. * Initializes the gamepad
  19290. * @param id The id of the gamepad
  19291. * @param index The index of the gamepad
  19292. * @param browserGamepad The browser gamepad
  19293. * @param leftStickX The x component of the left joystick
  19294. * @param leftStickY The y component of the left joystick
  19295. * @param rightStickX The x component of the right joystick
  19296. * @param rightStickY The y component of the right joystick
  19297. */
  19298. constructor(
  19299. /**
  19300. * The id of the gamepad
  19301. */
  19302. id: string,
  19303. /**
  19304. * The index of the gamepad
  19305. */
  19306. index: number,
  19307. /**
  19308. * The browser gamepad
  19309. */
  19310. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19311. /**
  19312. * Callback triggered when the left joystick has changed
  19313. * @param callback
  19314. */
  19315. onleftstickchanged(callback: (values: StickValues) => void): void;
  19316. /**
  19317. * Callback triggered when the right joystick has changed
  19318. * @param callback
  19319. */
  19320. onrightstickchanged(callback: (values: StickValues) => void): void;
  19321. /**
  19322. * Gets the left joystick
  19323. */
  19324. get leftStick(): StickValues;
  19325. /**
  19326. * Sets the left joystick values
  19327. */
  19328. set leftStick(newValues: StickValues);
  19329. /**
  19330. * Gets the right joystick
  19331. */
  19332. get rightStick(): StickValues;
  19333. /**
  19334. * Sets the right joystick value
  19335. */
  19336. set rightStick(newValues: StickValues);
  19337. /**
  19338. * Updates the gamepad joystick positions
  19339. */
  19340. update(): void;
  19341. /**
  19342. * Disposes the gamepad
  19343. */
  19344. dispose(): void;
  19345. }
  19346. /**
  19347. * Represents a generic gamepad
  19348. */
  19349. export class GenericPad extends Gamepad {
  19350. private _buttons;
  19351. private _onbuttondown;
  19352. private _onbuttonup;
  19353. /**
  19354. * Observable triggered when a button has been pressed
  19355. */
  19356. onButtonDownObservable: Observable<number>;
  19357. /**
  19358. * Observable triggered when a button has been released
  19359. */
  19360. onButtonUpObservable: Observable<number>;
  19361. /**
  19362. * Callback triggered when a button has been pressed
  19363. * @param callback Called when a button has been pressed
  19364. */
  19365. onbuttondown(callback: (buttonPressed: number) => void): void;
  19366. /**
  19367. * Callback triggered when a button has been released
  19368. * @param callback Called when a button has been released
  19369. */
  19370. onbuttonup(callback: (buttonReleased: number) => void): void;
  19371. /**
  19372. * Initializes the generic gamepad
  19373. * @param id The id of the generic gamepad
  19374. * @param index The index of the generic gamepad
  19375. * @param browserGamepad The browser gamepad
  19376. */
  19377. constructor(id: string, index: number, browserGamepad: any);
  19378. private _setButtonValue;
  19379. /**
  19380. * Updates the generic gamepad
  19381. */
  19382. update(): void;
  19383. /**
  19384. * Disposes the generic gamepad
  19385. */
  19386. dispose(): void;
  19387. }
  19388. }
  19389. declare module BABYLON {
  19390. /**
  19391. * Defines the types of pose enabled controllers that are supported
  19392. */
  19393. export enum PoseEnabledControllerType {
  19394. /**
  19395. * HTC Vive
  19396. */
  19397. VIVE = 0,
  19398. /**
  19399. * Oculus Rift
  19400. */
  19401. OCULUS = 1,
  19402. /**
  19403. * Windows mixed reality
  19404. */
  19405. WINDOWS = 2,
  19406. /**
  19407. * Samsung gear VR
  19408. */
  19409. GEAR_VR = 3,
  19410. /**
  19411. * Google Daydream
  19412. */
  19413. DAYDREAM = 4,
  19414. /**
  19415. * Generic
  19416. */
  19417. GENERIC = 5
  19418. }
  19419. /**
  19420. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19421. */
  19422. export interface MutableGamepadButton {
  19423. /**
  19424. * Value of the button/trigger
  19425. */
  19426. value: number;
  19427. /**
  19428. * If the button/trigger is currently touched
  19429. */
  19430. touched: boolean;
  19431. /**
  19432. * If the button/trigger is currently pressed
  19433. */
  19434. pressed: boolean;
  19435. }
  19436. /**
  19437. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19438. * @hidden
  19439. */
  19440. export interface ExtendedGamepadButton extends GamepadButton {
  19441. /**
  19442. * If the button/trigger is currently pressed
  19443. */
  19444. readonly pressed: boolean;
  19445. /**
  19446. * If the button/trigger is currently touched
  19447. */
  19448. readonly touched: boolean;
  19449. /**
  19450. * Value of the button/trigger
  19451. */
  19452. readonly value: number;
  19453. }
  19454. /** @hidden */
  19455. export interface _GamePadFactory {
  19456. /**
  19457. * Returns whether or not the current gamepad can be created for this type of controller.
  19458. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19459. * @returns true if it can be created, otherwise false
  19460. */
  19461. canCreate(gamepadInfo: any): boolean;
  19462. /**
  19463. * Creates a new instance of the Gamepad.
  19464. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19465. * @returns the new gamepad instance
  19466. */
  19467. create(gamepadInfo: any): Gamepad;
  19468. }
  19469. /**
  19470. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19471. */
  19472. export class PoseEnabledControllerHelper {
  19473. /** @hidden */
  19474. static _ControllerFactories: _GamePadFactory[];
  19475. /** @hidden */
  19476. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19477. /**
  19478. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19479. * @param vrGamepad the gamepad to initialized
  19480. * @returns a vr controller of the type the gamepad identified as
  19481. */
  19482. static InitiateController(vrGamepad: any): Gamepad;
  19483. }
  19484. /**
  19485. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19486. */
  19487. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19488. /**
  19489. * If the controller is used in a webXR session
  19490. */
  19491. isXR: boolean;
  19492. private _deviceRoomPosition;
  19493. private _deviceRoomRotationQuaternion;
  19494. /**
  19495. * The device position in babylon space
  19496. */
  19497. devicePosition: Vector3;
  19498. /**
  19499. * The device rotation in babylon space
  19500. */
  19501. deviceRotationQuaternion: Quaternion;
  19502. /**
  19503. * The scale factor of the device in babylon space
  19504. */
  19505. deviceScaleFactor: number;
  19506. /**
  19507. * (Likely devicePosition should be used instead) The device position in its room space
  19508. */
  19509. position: Vector3;
  19510. /**
  19511. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19512. */
  19513. rotationQuaternion: Quaternion;
  19514. /**
  19515. * The type of controller (Eg. Windows mixed reality)
  19516. */
  19517. controllerType: PoseEnabledControllerType;
  19518. protected _calculatedPosition: Vector3;
  19519. private _calculatedRotation;
  19520. /**
  19521. * The raw pose from the device
  19522. */
  19523. rawPose: DevicePose;
  19524. private _trackPosition;
  19525. private _maxRotationDistFromHeadset;
  19526. private _draggedRoomRotation;
  19527. /**
  19528. * @hidden
  19529. */
  19530. _disableTrackPosition(fixedPosition: Vector3): void;
  19531. /**
  19532. * Internal, the mesh attached to the controller
  19533. * @hidden
  19534. */
  19535. _mesh: Nullable<AbstractMesh>;
  19536. private _poseControlledCamera;
  19537. private _leftHandSystemQuaternion;
  19538. /**
  19539. * Internal, matrix used to convert room space to babylon space
  19540. * @hidden
  19541. */
  19542. _deviceToWorld: Matrix;
  19543. /**
  19544. * Node to be used when casting a ray from the controller
  19545. * @hidden
  19546. */
  19547. _pointingPoseNode: Nullable<TransformNode>;
  19548. /**
  19549. * Name of the child mesh that can be used to cast a ray from the controller
  19550. */
  19551. static readonly POINTING_POSE: string;
  19552. /**
  19553. * Creates a new PoseEnabledController from a gamepad
  19554. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19555. */
  19556. constructor(browserGamepad: any);
  19557. private _workingMatrix;
  19558. /**
  19559. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19560. */
  19561. update(): void;
  19562. /**
  19563. * Updates only the pose device and mesh without doing any button event checking
  19564. */
  19565. protected _updatePoseAndMesh(): void;
  19566. /**
  19567. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19568. * @param poseData raw pose fromthe device
  19569. */
  19570. updateFromDevice(poseData: DevicePose): void;
  19571. /**
  19572. * @hidden
  19573. */
  19574. _meshAttachedObservable: Observable<AbstractMesh>;
  19575. /**
  19576. * Attaches a mesh to the controller
  19577. * @param mesh the mesh to be attached
  19578. */
  19579. attachToMesh(mesh: AbstractMesh): void;
  19580. /**
  19581. * Attaches the controllers mesh to a camera
  19582. * @param camera the camera the mesh should be attached to
  19583. */
  19584. attachToPoseControlledCamera(camera: TargetCamera): void;
  19585. /**
  19586. * Disposes of the controller
  19587. */
  19588. dispose(): void;
  19589. /**
  19590. * The mesh that is attached to the controller
  19591. */
  19592. get mesh(): Nullable<AbstractMesh>;
  19593. /**
  19594. * Gets the ray of the controller in the direction the controller is pointing
  19595. * @param length the length the resulting ray should be
  19596. * @returns a ray in the direction the controller is pointing
  19597. */
  19598. getForwardRay(length?: number): Ray;
  19599. }
  19600. }
  19601. declare module BABYLON {
  19602. /**
  19603. * Defines the WebVRController object that represents controllers tracked in 3D space
  19604. */
  19605. export abstract class WebVRController extends PoseEnabledController {
  19606. /**
  19607. * Internal, the default controller model for the controller
  19608. */
  19609. protected _defaultModel: Nullable<AbstractMesh>;
  19610. /**
  19611. * Fired when the trigger state has changed
  19612. */
  19613. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19614. /**
  19615. * Fired when the main button state has changed
  19616. */
  19617. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19618. /**
  19619. * Fired when the secondary button state has changed
  19620. */
  19621. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19622. /**
  19623. * Fired when the pad state has changed
  19624. */
  19625. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19626. /**
  19627. * Fired when controllers stick values have changed
  19628. */
  19629. onPadValuesChangedObservable: Observable<StickValues>;
  19630. /**
  19631. * Array of button availible on the controller
  19632. */
  19633. protected _buttons: Array<MutableGamepadButton>;
  19634. private _onButtonStateChange;
  19635. /**
  19636. * Fired when a controller button's state has changed
  19637. * @param callback the callback containing the button that was modified
  19638. */
  19639. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19640. /**
  19641. * X and Y axis corresponding to the controllers joystick
  19642. */
  19643. pad: StickValues;
  19644. /**
  19645. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19646. */
  19647. hand: string;
  19648. /**
  19649. * The default controller model for the controller
  19650. */
  19651. get defaultModel(): Nullable<AbstractMesh>;
  19652. /**
  19653. * Creates a new WebVRController from a gamepad
  19654. * @param vrGamepad the gamepad that the WebVRController should be created from
  19655. */
  19656. constructor(vrGamepad: any);
  19657. /**
  19658. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19659. */
  19660. update(): void;
  19661. /**
  19662. * Function to be called when a button is modified
  19663. */
  19664. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19665. /**
  19666. * Loads a mesh and attaches it to the controller
  19667. * @param scene the scene the mesh should be added to
  19668. * @param meshLoaded callback for when the mesh has been loaded
  19669. */
  19670. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19671. private _setButtonValue;
  19672. private _changes;
  19673. private _checkChanges;
  19674. /**
  19675. * Disposes of th webVRCOntroller
  19676. */
  19677. dispose(): void;
  19678. }
  19679. }
  19680. declare module BABYLON {
  19681. /**
  19682. * The HemisphericLight simulates the ambient environment light,
  19683. * so the passed direction is the light reflection direction, not the incoming direction.
  19684. */
  19685. export class HemisphericLight extends Light {
  19686. /**
  19687. * The groundColor is the light in the opposite direction to the one specified during creation.
  19688. * 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.
  19689. */
  19690. groundColor: Color3;
  19691. /**
  19692. * The light reflection direction, not the incoming direction.
  19693. */
  19694. direction: Vector3;
  19695. /**
  19696. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19697. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19698. * The HemisphericLight can't cast shadows.
  19699. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19700. * @param name The friendly name of the light
  19701. * @param direction The direction of the light reflection
  19702. * @param scene The scene the light belongs to
  19703. */
  19704. constructor(name: string, direction: Vector3, scene: Scene);
  19705. protected _buildUniformLayout(): void;
  19706. /**
  19707. * Returns the string "HemisphericLight".
  19708. * @return The class name
  19709. */
  19710. getClassName(): string;
  19711. /**
  19712. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19713. * Returns the updated direction.
  19714. * @param target The target the direction should point to
  19715. * @return The computed direction
  19716. */
  19717. setDirectionToTarget(target: Vector3): Vector3;
  19718. /**
  19719. * Returns the shadow generator associated to the light.
  19720. * @returns Always null for hemispheric lights because it does not support shadows.
  19721. */
  19722. getShadowGenerator(): Nullable<IShadowGenerator>;
  19723. /**
  19724. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19725. * @param effect The effect to update
  19726. * @param lightIndex The index of the light in the effect to update
  19727. * @returns The hemispheric light
  19728. */
  19729. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19730. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19731. /**
  19732. * Computes the world matrix of the node
  19733. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19734. * @param useWasUpdatedFlag defines a reserved property
  19735. * @returns the world matrix
  19736. */
  19737. computeWorldMatrix(): Matrix;
  19738. /**
  19739. * Returns the integer 3.
  19740. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19741. */
  19742. getTypeID(): number;
  19743. /**
  19744. * Prepares the list of defines specific to the light type.
  19745. * @param defines the list of defines
  19746. * @param lightIndex defines the index of the light for the effect
  19747. */
  19748. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19749. }
  19750. }
  19751. declare module BABYLON {
  19752. /** @hidden */
  19753. export var vrMultiviewToSingleviewPixelShader: {
  19754. name: string;
  19755. shader: string;
  19756. };
  19757. }
  19758. declare module BABYLON {
  19759. /**
  19760. * Renders to multiple views with a single draw call
  19761. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19762. */
  19763. export class MultiviewRenderTarget extends RenderTargetTexture {
  19764. /**
  19765. * Creates a multiview render target
  19766. * @param scene scene used with the render target
  19767. * @param size the size of the render target (used for each view)
  19768. */
  19769. constructor(scene: Scene, size?: number | {
  19770. width: number;
  19771. height: number;
  19772. } | {
  19773. ratio: number;
  19774. });
  19775. /**
  19776. * @hidden
  19777. * @param faceIndex the face index, if its a cube texture
  19778. */
  19779. _bindFrameBuffer(faceIndex?: number): void;
  19780. /**
  19781. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19782. * @returns the view count
  19783. */
  19784. getViewCount(): number;
  19785. }
  19786. }
  19787. declare module BABYLON {
  19788. interface Engine {
  19789. /**
  19790. * Creates a new multiview render target
  19791. * @param width defines the width of the texture
  19792. * @param height defines the height of the texture
  19793. * @returns the created multiview texture
  19794. */
  19795. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19796. /**
  19797. * Binds a multiview framebuffer to be drawn to
  19798. * @param multiviewTexture texture to bind
  19799. */
  19800. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19801. }
  19802. interface Camera {
  19803. /**
  19804. * @hidden
  19805. * 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)
  19806. */
  19807. _useMultiviewToSingleView: boolean;
  19808. /**
  19809. * @hidden
  19810. * 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)
  19811. */
  19812. _multiviewTexture: Nullable<RenderTargetTexture>;
  19813. /**
  19814. * @hidden
  19815. * ensures the multiview texture of the camera exists and has the specified width/height
  19816. * @param width height to set on the multiview texture
  19817. * @param height width to set on the multiview texture
  19818. */
  19819. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19820. }
  19821. interface Scene {
  19822. /** @hidden */
  19823. _transformMatrixR: Matrix;
  19824. /** @hidden */
  19825. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19826. /** @hidden */
  19827. _createMultiviewUbo(): void;
  19828. /** @hidden */
  19829. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19830. /** @hidden */
  19831. _renderMultiviewToSingleView(camera: Camera): void;
  19832. }
  19833. }
  19834. declare module BABYLON {
  19835. /**
  19836. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19837. * This will not be used for webXR as it supports displaying texture arrays directly
  19838. */
  19839. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19840. /**
  19841. * Gets a string identifying the name of the class
  19842. * @returns "VRMultiviewToSingleviewPostProcess" string
  19843. */
  19844. getClassName(): string;
  19845. /**
  19846. * Initializes a VRMultiviewToSingleview
  19847. * @param name name of the post process
  19848. * @param camera camera to be applied to
  19849. * @param scaleFactor scaling factor to the size of the output texture
  19850. */
  19851. constructor(name: string, camera: Camera, scaleFactor: number);
  19852. }
  19853. }
  19854. declare module BABYLON {
  19855. /**
  19856. * Interface used to define additional presentation attributes
  19857. */
  19858. export interface IVRPresentationAttributes {
  19859. /**
  19860. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19861. */
  19862. highRefreshRate: boolean;
  19863. /**
  19864. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19865. */
  19866. foveationLevel: number;
  19867. }
  19868. interface Engine {
  19869. /** @hidden */
  19870. _vrDisplay: any;
  19871. /** @hidden */
  19872. _vrSupported: boolean;
  19873. /** @hidden */
  19874. _oldSize: Size;
  19875. /** @hidden */
  19876. _oldHardwareScaleFactor: number;
  19877. /** @hidden */
  19878. _vrExclusivePointerMode: boolean;
  19879. /** @hidden */
  19880. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19881. /** @hidden */
  19882. _onVRDisplayPointerRestricted: () => void;
  19883. /** @hidden */
  19884. _onVRDisplayPointerUnrestricted: () => void;
  19885. /** @hidden */
  19886. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19887. /** @hidden */
  19888. _onVrDisplayDisconnect: Nullable<() => void>;
  19889. /** @hidden */
  19890. _onVrDisplayPresentChange: Nullable<() => void>;
  19891. /**
  19892. * Observable signaled when VR display mode changes
  19893. */
  19894. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19895. /**
  19896. * Observable signaled when VR request present is complete
  19897. */
  19898. onVRRequestPresentComplete: Observable<boolean>;
  19899. /**
  19900. * Observable signaled when VR request present starts
  19901. */
  19902. onVRRequestPresentStart: Observable<Engine>;
  19903. /**
  19904. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19905. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19906. */
  19907. isInVRExclusivePointerMode: boolean;
  19908. /**
  19909. * Gets a boolean indicating if a webVR device was detected
  19910. * @returns true if a webVR device was detected
  19911. */
  19912. isVRDevicePresent(): boolean;
  19913. /**
  19914. * Gets the current webVR device
  19915. * @returns the current webVR device (or null)
  19916. */
  19917. getVRDevice(): any;
  19918. /**
  19919. * Initializes a webVR display and starts listening to display change events
  19920. * The onVRDisplayChangedObservable will be notified upon these changes
  19921. * @returns A promise containing a VRDisplay and if vr is supported
  19922. */
  19923. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19924. /** @hidden */
  19925. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19926. /**
  19927. * Gets or sets the presentation attributes used to configure VR rendering
  19928. */
  19929. vrPresentationAttributes?: IVRPresentationAttributes;
  19930. /**
  19931. * Call this function to switch to webVR mode
  19932. * Will do nothing if webVR is not supported or if there is no webVR device
  19933. * @param options the webvr options provided to the camera. mainly used for multiview
  19934. * @see https://doc.babylonjs.com/how_to/webvr_camera
  19935. */
  19936. enableVR(options: WebVROptions): void;
  19937. /** @hidden */
  19938. _onVRFullScreenTriggered(): void;
  19939. }
  19940. }
  19941. declare module BABYLON {
  19942. /**
  19943. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19944. * IMPORTANT!! The data is right-hand data.
  19945. * @export
  19946. * @interface DevicePose
  19947. */
  19948. export interface DevicePose {
  19949. /**
  19950. * The position of the device, values in array are [x,y,z].
  19951. */
  19952. readonly position: Nullable<Float32Array>;
  19953. /**
  19954. * The linearVelocity of the device, values in array are [x,y,z].
  19955. */
  19956. readonly linearVelocity: Nullable<Float32Array>;
  19957. /**
  19958. * The linearAcceleration of the device, values in array are [x,y,z].
  19959. */
  19960. readonly linearAcceleration: Nullable<Float32Array>;
  19961. /**
  19962. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19963. */
  19964. readonly orientation: Nullable<Float32Array>;
  19965. /**
  19966. * The angularVelocity of the device, values in array are [x,y,z].
  19967. */
  19968. readonly angularVelocity: Nullable<Float32Array>;
  19969. /**
  19970. * The angularAcceleration of the device, values in array are [x,y,z].
  19971. */
  19972. readonly angularAcceleration: Nullable<Float32Array>;
  19973. }
  19974. /**
  19975. * Interface representing a pose controlled object in Babylon.
  19976. * A pose controlled object has both regular pose values as well as pose values
  19977. * from an external device such as a VR head mounted display
  19978. */
  19979. export interface PoseControlled {
  19980. /**
  19981. * The position of the object in babylon space.
  19982. */
  19983. position: Vector3;
  19984. /**
  19985. * The rotation quaternion of the object in babylon space.
  19986. */
  19987. rotationQuaternion: Quaternion;
  19988. /**
  19989. * The position of the device in babylon space.
  19990. */
  19991. devicePosition?: Vector3;
  19992. /**
  19993. * The rotation quaternion of the device in babylon space.
  19994. */
  19995. deviceRotationQuaternion: Quaternion;
  19996. /**
  19997. * The raw pose coming from the device.
  19998. */
  19999. rawPose: Nullable<DevicePose>;
  20000. /**
  20001. * The scale of the device to be used when translating from device space to babylon space.
  20002. */
  20003. deviceScaleFactor: number;
  20004. /**
  20005. * Updates the poseControlled values based on the input device pose.
  20006. * @param poseData the pose data to update the object with
  20007. */
  20008. updateFromDevice(poseData: DevicePose): void;
  20009. }
  20010. /**
  20011. * Set of options to customize the webVRCamera
  20012. */
  20013. export interface WebVROptions {
  20014. /**
  20015. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20016. */
  20017. trackPosition?: boolean;
  20018. /**
  20019. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20020. */
  20021. positionScale?: number;
  20022. /**
  20023. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20024. */
  20025. displayName?: string;
  20026. /**
  20027. * Should the native controller meshes be initialized. (default: true)
  20028. */
  20029. controllerMeshes?: boolean;
  20030. /**
  20031. * Creating a default HemiLight only on controllers. (default: true)
  20032. */
  20033. defaultLightingOnControllers?: boolean;
  20034. /**
  20035. * If you don't want to use the default VR button of the helper. (default: false)
  20036. */
  20037. useCustomVRButton?: boolean;
  20038. /**
  20039. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20040. */
  20041. customVRButton?: HTMLButtonElement;
  20042. /**
  20043. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20044. */
  20045. rayLength?: number;
  20046. /**
  20047. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20048. */
  20049. defaultHeight?: number;
  20050. /**
  20051. * If multiview should be used if availible (default: false)
  20052. */
  20053. useMultiview?: boolean;
  20054. }
  20055. /**
  20056. * This represents a WebVR camera.
  20057. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20058. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20059. */
  20060. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20061. private webVROptions;
  20062. /**
  20063. * @hidden
  20064. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20065. */
  20066. _vrDevice: any;
  20067. /**
  20068. * The rawPose of the vrDevice.
  20069. */
  20070. rawPose: Nullable<DevicePose>;
  20071. private _onVREnabled;
  20072. private _specsVersion;
  20073. private _attached;
  20074. private _frameData;
  20075. protected _descendants: Array<Node>;
  20076. private _deviceRoomPosition;
  20077. /** @hidden */
  20078. _deviceRoomRotationQuaternion: Quaternion;
  20079. private _standingMatrix;
  20080. /**
  20081. * Represents device position in babylon space.
  20082. */
  20083. devicePosition: Vector3;
  20084. /**
  20085. * Represents device rotation in babylon space.
  20086. */
  20087. deviceRotationQuaternion: Quaternion;
  20088. /**
  20089. * The scale of the device to be used when translating from device space to babylon space.
  20090. */
  20091. deviceScaleFactor: number;
  20092. private _deviceToWorld;
  20093. private _worldToDevice;
  20094. /**
  20095. * References to the webVR controllers for the vrDevice.
  20096. */
  20097. controllers: Array<WebVRController>;
  20098. /**
  20099. * Emits an event when a controller is attached.
  20100. */
  20101. onControllersAttachedObservable: Observable<WebVRController[]>;
  20102. /**
  20103. * Emits an event when a controller's mesh has been loaded;
  20104. */
  20105. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20106. /**
  20107. * Emits an event when the HMD's pose has been updated.
  20108. */
  20109. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20110. private _poseSet;
  20111. /**
  20112. * If the rig cameras be used as parent instead of this camera.
  20113. */
  20114. rigParenting: boolean;
  20115. private _lightOnControllers;
  20116. private _defaultHeight?;
  20117. /**
  20118. * Instantiates a WebVRFreeCamera.
  20119. * @param name The name of the WebVRFreeCamera
  20120. * @param position The starting anchor position for the camera
  20121. * @param scene The scene the camera belongs to
  20122. * @param webVROptions a set of customizable options for the webVRCamera
  20123. */
  20124. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20125. /**
  20126. * Gets the device distance from the ground in meters.
  20127. * @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.
  20128. */
  20129. deviceDistanceToRoomGround(): number;
  20130. /**
  20131. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20132. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20133. */
  20134. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20135. /**
  20136. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20137. * @returns A promise with a boolean set to if the standing matrix is supported.
  20138. */
  20139. useStandingMatrixAsync(): Promise<boolean>;
  20140. /**
  20141. * Disposes the camera
  20142. */
  20143. dispose(): void;
  20144. /**
  20145. * Gets a vrController by name.
  20146. * @param name The name of the controller to retreive
  20147. * @returns the controller matching the name specified or null if not found
  20148. */
  20149. getControllerByName(name: string): Nullable<WebVRController>;
  20150. private _leftController;
  20151. /**
  20152. * The controller corresponding to the users left hand.
  20153. */
  20154. get leftController(): Nullable<WebVRController>;
  20155. private _rightController;
  20156. /**
  20157. * The controller corresponding to the users right hand.
  20158. */
  20159. get rightController(): Nullable<WebVRController>;
  20160. /**
  20161. * Casts a ray forward from the vrCamera's gaze.
  20162. * @param length Length of the ray (default: 100)
  20163. * @returns the ray corresponding to the gaze
  20164. */
  20165. getForwardRay(length?: number): Ray;
  20166. /**
  20167. * @hidden
  20168. * Updates the camera based on device's frame data
  20169. */
  20170. _checkInputs(): void;
  20171. /**
  20172. * Updates the poseControlled values based on the input device pose.
  20173. * @param poseData Pose coming from the device
  20174. */
  20175. updateFromDevice(poseData: DevicePose): void;
  20176. private _htmlElementAttached;
  20177. private _detachIfAttached;
  20178. /**
  20179. * WebVR's attach control will start broadcasting frames to the device.
  20180. * Note that in certain browsers (chrome for example) this function must be called
  20181. * within a user-interaction callback. Example:
  20182. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20183. *
  20184. * @param element html element to attach the vrDevice to
  20185. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20186. */
  20187. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20188. /**
  20189. * Detaches the camera from the html element and disables VR
  20190. *
  20191. * @param element html element to detach from
  20192. */
  20193. detachControl(element: HTMLElement): void;
  20194. /**
  20195. * @returns the name of this class
  20196. */
  20197. getClassName(): string;
  20198. /**
  20199. * Calls resetPose on the vrDisplay
  20200. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20201. */
  20202. resetToCurrentRotation(): void;
  20203. /**
  20204. * @hidden
  20205. * Updates the rig cameras (left and right eye)
  20206. */
  20207. _updateRigCameras(): void;
  20208. private _workingVector;
  20209. private _oneVector;
  20210. private _workingMatrix;
  20211. private updateCacheCalled;
  20212. private _correctPositionIfNotTrackPosition;
  20213. /**
  20214. * @hidden
  20215. * Updates the cached values of the camera
  20216. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20217. */
  20218. _updateCache(ignoreParentClass?: boolean): void;
  20219. /**
  20220. * @hidden
  20221. * Get current device position in babylon world
  20222. */
  20223. _computeDevicePosition(): void;
  20224. /**
  20225. * Updates the current device position and rotation in the babylon world
  20226. */
  20227. update(): void;
  20228. /**
  20229. * @hidden
  20230. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20231. * @returns an identity matrix
  20232. */
  20233. _getViewMatrix(): Matrix;
  20234. private _tmpMatrix;
  20235. /**
  20236. * This function is called by the two RIG cameras.
  20237. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20238. * @hidden
  20239. */
  20240. _getWebVRViewMatrix(): Matrix;
  20241. /** @hidden */
  20242. _getWebVRProjectionMatrix(): Matrix;
  20243. private _onGamepadConnectedObserver;
  20244. private _onGamepadDisconnectedObserver;
  20245. private _updateCacheWhenTrackingDisabledObserver;
  20246. /**
  20247. * Initializes the controllers and their meshes
  20248. */
  20249. initControllers(): void;
  20250. }
  20251. }
  20252. declare module BABYLON {
  20253. /**
  20254. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20255. *
  20256. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20257. *
  20258. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20259. */
  20260. export class MaterialHelper {
  20261. /**
  20262. * Bind the current view position to an effect.
  20263. * @param effect The effect to be bound
  20264. * @param scene The scene the eyes position is used from
  20265. * @param variableName name of the shader variable that will hold the eye position
  20266. */
  20267. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20268. /**
  20269. * Helps preparing the defines values about the UVs in used in the effect.
  20270. * UVs are shared as much as we can accross channels in the shaders.
  20271. * @param texture The texture we are preparing the UVs for
  20272. * @param defines The defines to update
  20273. * @param key The channel key "diffuse", "specular"... used in the shader
  20274. */
  20275. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20276. /**
  20277. * Binds a texture matrix value to its corrsponding uniform
  20278. * @param texture The texture to bind the matrix for
  20279. * @param uniformBuffer The uniform buffer receivin the data
  20280. * @param key The channel key "diffuse", "specular"... used in the shader
  20281. */
  20282. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20283. /**
  20284. * Gets the current status of the fog (should it be enabled?)
  20285. * @param mesh defines the mesh to evaluate for fog support
  20286. * @param scene defines the hosting scene
  20287. * @returns true if fog must be enabled
  20288. */
  20289. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20290. /**
  20291. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20292. * @param mesh defines the current mesh
  20293. * @param scene defines the current scene
  20294. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20295. * @param pointsCloud defines if point cloud rendering has to be turned on
  20296. * @param fogEnabled defines if fog has to be turned on
  20297. * @param alphaTest defines if alpha testing has to be turned on
  20298. * @param defines defines the current list of defines
  20299. */
  20300. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20301. /**
  20302. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20303. * @param scene defines the current scene
  20304. * @param engine defines the current engine
  20305. * @param defines specifies the list of active defines
  20306. * @param useInstances defines if instances have to be turned on
  20307. * @param useClipPlane defines if clip plane have to be turned on
  20308. * @param useInstances defines if instances have to be turned on
  20309. * @param useThinInstances defines if thin instances have to be turned on
  20310. */
  20311. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20312. /**
  20313. * Prepares the defines for bones
  20314. * @param mesh The mesh containing the geometry data we will draw
  20315. * @param defines The defines to update
  20316. */
  20317. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20318. /**
  20319. * Prepares the defines for morph targets
  20320. * @param mesh The mesh containing the geometry data we will draw
  20321. * @param defines The defines to update
  20322. */
  20323. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20324. /**
  20325. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20326. * @param mesh The mesh containing the geometry data we will draw
  20327. * @param defines The defines to update
  20328. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20329. * @param useBones Precise whether bones should be used or not (override mesh info)
  20330. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20331. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20332. * @returns false if defines are considered not dirty and have not been checked
  20333. */
  20334. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20335. /**
  20336. * Prepares the defines related to multiview
  20337. * @param scene The scene we are intending to draw
  20338. * @param defines The defines to update
  20339. */
  20340. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20341. /**
  20342. * Prepares the defines related to the prepass
  20343. * @param scene The scene we are intending to draw
  20344. * @param defines The defines to update
  20345. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20346. */
  20347. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20348. /**
  20349. * Prepares the defines related to the light information passed in parameter
  20350. * @param scene The scene we are intending to draw
  20351. * @param mesh The mesh the effect is compiling for
  20352. * @param light The light the effect is compiling for
  20353. * @param lightIndex The index of the light
  20354. * @param defines The defines to update
  20355. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20356. * @param state Defines the current state regarding what is needed (normals, etc...)
  20357. */
  20358. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20359. needNormals: boolean;
  20360. needRebuild: boolean;
  20361. shadowEnabled: boolean;
  20362. specularEnabled: boolean;
  20363. lightmapMode: boolean;
  20364. }): void;
  20365. /**
  20366. * Prepares the defines related to the light information passed in parameter
  20367. * @param scene The scene we are intending to draw
  20368. * @param mesh The mesh the effect is compiling for
  20369. * @param defines The defines to update
  20370. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20371. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20372. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20373. * @returns true if normals will be required for the rest of the effect
  20374. */
  20375. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20376. /**
  20377. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20378. * @param lightIndex defines the light index
  20379. * @param uniformsList The uniform list
  20380. * @param samplersList The sampler list
  20381. * @param projectedLightTexture defines if projected texture must be used
  20382. * @param uniformBuffersList defines an optional list of uniform buffers
  20383. */
  20384. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20385. /**
  20386. * Prepares the uniforms and samplers list to be used in the effect
  20387. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20388. * @param samplersList The sampler list
  20389. * @param defines The defines helping in the list generation
  20390. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20391. */
  20392. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20393. /**
  20394. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20395. * @param defines The defines to update while falling back
  20396. * @param fallbacks The authorized effect fallbacks
  20397. * @param maxSimultaneousLights The maximum number of lights allowed
  20398. * @param rank the current rank of the Effect
  20399. * @returns The newly affected rank
  20400. */
  20401. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20402. private static _TmpMorphInfluencers;
  20403. /**
  20404. * Prepares the list of attributes required for morph targets according to the effect defines.
  20405. * @param attribs The current list of supported attribs
  20406. * @param mesh The mesh to prepare the morph targets attributes for
  20407. * @param influencers The number of influencers
  20408. */
  20409. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20410. /**
  20411. * Prepares the list of attributes required for morph targets according to the effect defines.
  20412. * @param attribs The current list of supported attribs
  20413. * @param mesh The mesh to prepare the morph targets attributes for
  20414. * @param defines The current Defines of the effect
  20415. */
  20416. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20417. /**
  20418. * Prepares the list of attributes required for bones according to the effect defines.
  20419. * @param attribs The current list of supported attribs
  20420. * @param mesh The mesh to prepare the bones attributes for
  20421. * @param defines The current Defines of the effect
  20422. * @param fallbacks The current efffect fallback strategy
  20423. */
  20424. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20425. /**
  20426. * Check and prepare the list of attributes required for instances according to the effect defines.
  20427. * @param attribs The current list of supported attribs
  20428. * @param defines The current MaterialDefines of the effect
  20429. */
  20430. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20431. /**
  20432. * Add the list of attributes required for instances to the attribs array.
  20433. * @param attribs The current list of supported attribs
  20434. */
  20435. static PushAttributesForInstances(attribs: string[]): void;
  20436. /**
  20437. * Binds the light information to the effect.
  20438. * @param light The light containing the generator
  20439. * @param effect The effect we are binding the data to
  20440. * @param lightIndex The light index in the effect used to render
  20441. */
  20442. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20443. /**
  20444. * Binds the lights information from the scene to the effect for the given mesh.
  20445. * @param light Light to bind
  20446. * @param lightIndex Light index
  20447. * @param scene The scene where the light belongs to
  20448. * @param effect The effect we are binding the data to
  20449. * @param useSpecular Defines if specular is supported
  20450. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20451. */
  20452. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20453. /**
  20454. * Binds the lights information from the scene to the effect for the given mesh.
  20455. * @param scene The scene the lights belongs to
  20456. * @param mesh The mesh we are binding the information to render
  20457. * @param effect The effect we are binding the data to
  20458. * @param defines The generated defines for the effect
  20459. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20460. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20461. */
  20462. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20463. private static _tempFogColor;
  20464. /**
  20465. * Binds the fog information from the scene to the effect for the given mesh.
  20466. * @param scene The scene the lights belongs to
  20467. * @param mesh The mesh we are binding the information to render
  20468. * @param effect The effect we are binding the data to
  20469. * @param linearSpace Defines if the fog effect is applied in linear space
  20470. */
  20471. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20472. /**
  20473. * Binds the bones information from the mesh to the effect.
  20474. * @param mesh The mesh we are binding the information to render
  20475. * @param effect The effect we are binding the data to
  20476. */
  20477. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20478. /**
  20479. * Binds the morph targets information from the mesh to the effect.
  20480. * @param abstractMesh The mesh we are binding the information to render
  20481. * @param effect The effect we are binding the data to
  20482. */
  20483. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20484. /**
  20485. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20486. * @param defines The generated defines used in the effect
  20487. * @param effect The effect we are binding the data to
  20488. * @param scene The scene we are willing to render with logarithmic scale for
  20489. */
  20490. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20491. /**
  20492. * Binds the clip plane information from the scene to the effect.
  20493. * @param scene The scene the clip plane information are extracted from
  20494. * @param effect The effect we are binding the data to
  20495. */
  20496. static BindClipPlane(effect: Effect, scene: Scene): void;
  20497. }
  20498. }
  20499. declare module BABYLON {
  20500. /**
  20501. * Block used to expose an input value
  20502. */
  20503. export class InputBlock extends NodeMaterialBlock {
  20504. private _mode;
  20505. private _associatedVariableName;
  20506. private _storedValue;
  20507. private _valueCallback;
  20508. private _type;
  20509. private _animationType;
  20510. /** Gets or set a value used to limit the range of float values */
  20511. min: number;
  20512. /** Gets or set a value used to limit the range of float values */
  20513. max: number;
  20514. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20515. isBoolean: boolean;
  20516. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20517. matrixMode: number;
  20518. /** @hidden */
  20519. _systemValue: Nullable<NodeMaterialSystemValues>;
  20520. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20521. isConstant: boolean;
  20522. /** Gets or sets the group to use to display this block in the Inspector */
  20523. groupInInspector: string;
  20524. /** Gets an observable raised when the value is changed */
  20525. onValueChangedObservable: Observable<InputBlock>;
  20526. /**
  20527. * Gets or sets the connection point type (default is float)
  20528. */
  20529. get type(): NodeMaterialBlockConnectionPointTypes;
  20530. /**
  20531. * Creates a new InputBlock
  20532. * @param name defines the block name
  20533. * @param target defines the target of that block (Vertex by default)
  20534. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20535. */
  20536. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20537. /**
  20538. * Validates if a name is a reserve word.
  20539. * @param newName the new name to be given to the node.
  20540. * @returns false if the name is a reserve word, else true.
  20541. */
  20542. validateBlockName(newName: string): boolean;
  20543. /**
  20544. * Gets the output component
  20545. */
  20546. get output(): NodeMaterialConnectionPoint;
  20547. /**
  20548. * Set the source of this connection point to a vertex attribute
  20549. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20550. * @returns the current connection point
  20551. */
  20552. setAsAttribute(attributeName?: string): InputBlock;
  20553. /**
  20554. * Set the source of this connection point to a system value
  20555. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20556. * @returns the current connection point
  20557. */
  20558. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20559. /**
  20560. * Gets or sets the value of that point.
  20561. * Please note that this value will be ignored if valueCallback is defined
  20562. */
  20563. get value(): any;
  20564. set value(value: any);
  20565. /**
  20566. * Gets or sets a callback used to get the value of that point.
  20567. * Please note that setting this value will force the connection point to ignore the value property
  20568. */
  20569. get valueCallback(): () => any;
  20570. set valueCallback(value: () => any);
  20571. /**
  20572. * Gets or sets the associated variable name in the shader
  20573. */
  20574. get associatedVariableName(): string;
  20575. set associatedVariableName(value: string);
  20576. /** Gets or sets the type of animation applied to the input */
  20577. get animationType(): AnimatedInputBlockTypes;
  20578. set animationType(value: AnimatedInputBlockTypes);
  20579. /**
  20580. * Gets a boolean indicating that this connection point not defined yet
  20581. */
  20582. get isUndefined(): boolean;
  20583. /**
  20584. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20585. * In this case the connection point name must be the name of the uniform to use.
  20586. * Can only be set on inputs
  20587. */
  20588. get isUniform(): boolean;
  20589. set isUniform(value: boolean);
  20590. /**
  20591. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20592. * In this case the connection point name must be the name of the attribute to use
  20593. * Can only be set on inputs
  20594. */
  20595. get isAttribute(): boolean;
  20596. set isAttribute(value: boolean);
  20597. /**
  20598. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20599. * Can only be set on exit points
  20600. */
  20601. get isVarying(): boolean;
  20602. set isVarying(value: boolean);
  20603. /**
  20604. * Gets a boolean indicating that the current connection point is a system value
  20605. */
  20606. get isSystemValue(): boolean;
  20607. /**
  20608. * Gets or sets the current well known value or null if not defined as a system value
  20609. */
  20610. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20611. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20612. /**
  20613. * Gets the current class name
  20614. * @returns the class name
  20615. */
  20616. getClassName(): string;
  20617. /**
  20618. * Animate the input if animationType !== None
  20619. * @param scene defines the rendering scene
  20620. */
  20621. animate(scene: Scene): void;
  20622. private _emitDefine;
  20623. initialize(state: NodeMaterialBuildState): void;
  20624. /**
  20625. * Set the input block to its default value (based on its type)
  20626. */
  20627. setDefaultValue(): void;
  20628. private _emitConstant;
  20629. /** @hidden */
  20630. get _noContextSwitch(): boolean;
  20631. private _emit;
  20632. /** @hidden */
  20633. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20634. /** @hidden */
  20635. _transmit(effect: Effect, scene: Scene): void;
  20636. protected _buildBlock(state: NodeMaterialBuildState): void;
  20637. protected _dumpPropertiesCode(): string;
  20638. dispose(): void;
  20639. serialize(): any;
  20640. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20641. }
  20642. }
  20643. declare module BABYLON {
  20644. /**
  20645. * Enum used to define the compatibility state between two connection points
  20646. */
  20647. export enum NodeMaterialConnectionPointCompatibilityStates {
  20648. /** Points are compatibles */
  20649. Compatible = 0,
  20650. /** Points are incompatible because of their types */
  20651. TypeIncompatible = 1,
  20652. /** Points are incompatible because of their targets (vertex vs fragment) */
  20653. TargetIncompatible = 2
  20654. }
  20655. /**
  20656. * Defines the direction of a connection point
  20657. */
  20658. export enum NodeMaterialConnectionPointDirection {
  20659. /** Input */
  20660. Input = 0,
  20661. /** Output */
  20662. Output = 1
  20663. }
  20664. /**
  20665. * Defines a connection point for a block
  20666. */
  20667. export class NodeMaterialConnectionPoint {
  20668. /** @hidden */
  20669. _ownerBlock: NodeMaterialBlock;
  20670. /** @hidden */
  20671. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20672. private _endpoints;
  20673. private _associatedVariableName;
  20674. private _direction;
  20675. /** @hidden */
  20676. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20677. /** @hidden */
  20678. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20679. private _type;
  20680. /** @hidden */
  20681. _enforceAssociatedVariableName: boolean;
  20682. /** Gets the direction of the point */
  20683. get direction(): NodeMaterialConnectionPointDirection;
  20684. /** Indicates that this connection point needs dual validation before being connected to another point */
  20685. needDualDirectionValidation: boolean;
  20686. /**
  20687. * Gets or sets the additional types supported by this connection point
  20688. */
  20689. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20690. /**
  20691. * Gets or sets the additional types excluded by this connection point
  20692. */
  20693. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20694. /**
  20695. * Observable triggered when this point is connected
  20696. */
  20697. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20698. /**
  20699. * Gets or sets the associated variable name in the shader
  20700. */
  20701. get associatedVariableName(): string;
  20702. set associatedVariableName(value: string);
  20703. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20704. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20705. /**
  20706. * Gets or sets the connection point type (default is float)
  20707. */
  20708. get type(): NodeMaterialBlockConnectionPointTypes;
  20709. set type(value: NodeMaterialBlockConnectionPointTypes);
  20710. /**
  20711. * Gets or sets the connection point name
  20712. */
  20713. name: string;
  20714. /**
  20715. * Gets or sets the connection point name
  20716. */
  20717. displayName: string;
  20718. /**
  20719. * Gets or sets a boolean indicating that this connection point can be omitted
  20720. */
  20721. isOptional: boolean;
  20722. /**
  20723. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20724. */
  20725. isExposedOnFrame: boolean;
  20726. /**
  20727. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20728. */
  20729. define: string;
  20730. /** @hidden */
  20731. _prioritizeVertex: boolean;
  20732. private _target;
  20733. /** Gets or sets the target of that connection point */
  20734. get target(): NodeMaterialBlockTargets;
  20735. set target(value: NodeMaterialBlockTargets);
  20736. /**
  20737. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20738. */
  20739. get isConnected(): boolean;
  20740. /**
  20741. * Gets a boolean indicating that the current point is connected to an input block
  20742. */
  20743. get isConnectedToInputBlock(): boolean;
  20744. /**
  20745. * Gets a the connected input block (if any)
  20746. */
  20747. get connectInputBlock(): Nullable<InputBlock>;
  20748. /** Get the other side of the connection (if any) */
  20749. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20750. /** Get the block that owns this connection point */
  20751. get ownerBlock(): NodeMaterialBlock;
  20752. /** Get the block connected on the other side of this connection (if any) */
  20753. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20754. /** Get the block connected on the endpoints of this connection (if any) */
  20755. get connectedBlocks(): Array<NodeMaterialBlock>;
  20756. /** Gets the list of connected endpoints */
  20757. get endpoints(): NodeMaterialConnectionPoint[];
  20758. /** Gets a boolean indicating if that output point is connected to at least one input */
  20759. get hasEndpoints(): boolean;
  20760. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20761. get isConnectedInVertexShader(): boolean;
  20762. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20763. get isConnectedInFragmentShader(): boolean;
  20764. /**
  20765. * Creates a block suitable to be used as an input for this input point.
  20766. * If null is returned, a block based on the point type will be created.
  20767. * @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
  20768. */
  20769. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20770. /**
  20771. * Creates a new connection point
  20772. * @param name defines the connection point name
  20773. * @param ownerBlock defines the block hosting this connection point
  20774. * @param direction defines the direction of the connection point
  20775. */
  20776. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20777. /**
  20778. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20779. * @returns the class name
  20780. */
  20781. getClassName(): string;
  20782. /**
  20783. * Gets a boolean indicating if the current point can be connected to another point
  20784. * @param connectionPoint defines the other connection point
  20785. * @returns a boolean
  20786. */
  20787. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20788. /**
  20789. * Gets a number indicating if the current point can be connected to another point
  20790. * @param connectionPoint defines the other connection point
  20791. * @returns a number defining the compatibility state
  20792. */
  20793. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20794. /**
  20795. * Connect this point to another connection point
  20796. * @param connectionPoint defines the other connection point
  20797. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20798. * @returns the current connection point
  20799. */
  20800. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20801. /**
  20802. * Disconnect this point from one of his endpoint
  20803. * @param endpoint defines the other connection point
  20804. * @returns the current connection point
  20805. */
  20806. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20807. /**
  20808. * Serializes this point in a JSON representation
  20809. * @param isInput defines if the connection point is an input (default is true)
  20810. * @returns the serialized point object
  20811. */
  20812. serialize(isInput?: boolean): any;
  20813. /**
  20814. * Release resources
  20815. */
  20816. dispose(): void;
  20817. }
  20818. }
  20819. declare module BABYLON {
  20820. /**
  20821. * Enum used to define the material modes
  20822. */
  20823. export enum NodeMaterialModes {
  20824. /** Regular material */
  20825. Material = 0,
  20826. /** For post process */
  20827. PostProcess = 1,
  20828. /** For particle system */
  20829. Particle = 2,
  20830. /** For procedural texture */
  20831. ProceduralTexture = 3
  20832. }
  20833. }
  20834. declare module BABYLON {
  20835. /**
  20836. * Block used to read a texture from a sampler
  20837. */
  20838. export class TextureBlock extends NodeMaterialBlock {
  20839. private _defineName;
  20840. private _linearDefineName;
  20841. private _gammaDefineName;
  20842. private _tempTextureRead;
  20843. private _samplerName;
  20844. private _transformedUVName;
  20845. private _textureTransformName;
  20846. private _textureInfoName;
  20847. private _mainUVName;
  20848. private _mainUVDefineName;
  20849. private _fragmentOnly;
  20850. /**
  20851. * Gets or sets the texture associated with the node
  20852. */
  20853. texture: Nullable<Texture>;
  20854. /**
  20855. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20856. */
  20857. convertToGammaSpace: boolean;
  20858. /**
  20859. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20860. */
  20861. convertToLinearSpace: boolean;
  20862. /**
  20863. * Create a new TextureBlock
  20864. * @param name defines the block name
  20865. */
  20866. constructor(name: string, fragmentOnly?: boolean);
  20867. /**
  20868. * Gets the current class name
  20869. * @returns the class name
  20870. */
  20871. getClassName(): string;
  20872. /**
  20873. * Gets the uv input component
  20874. */
  20875. get uv(): NodeMaterialConnectionPoint;
  20876. /**
  20877. * Gets the rgba output component
  20878. */
  20879. get rgba(): NodeMaterialConnectionPoint;
  20880. /**
  20881. * Gets the rgb output component
  20882. */
  20883. get rgb(): NodeMaterialConnectionPoint;
  20884. /**
  20885. * Gets the r output component
  20886. */
  20887. get r(): NodeMaterialConnectionPoint;
  20888. /**
  20889. * Gets the g output component
  20890. */
  20891. get g(): NodeMaterialConnectionPoint;
  20892. /**
  20893. * Gets the b output component
  20894. */
  20895. get b(): NodeMaterialConnectionPoint;
  20896. /**
  20897. * Gets the a output component
  20898. */
  20899. get a(): NodeMaterialConnectionPoint;
  20900. get target(): NodeMaterialBlockTargets;
  20901. autoConfigure(material: NodeMaterial): void;
  20902. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20903. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20904. isReady(): boolean;
  20905. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20906. private get _isMixed();
  20907. private _injectVertexCode;
  20908. private _writeTextureRead;
  20909. private _writeOutput;
  20910. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20911. protected _dumpPropertiesCode(): string;
  20912. serialize(): any;
  20913. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20914. }
  20915. }
  20916. declare module BABYLON {
  20917. /** @hidden */
  20918. export var reflectionFunction: {
  20919. name: string;
  20920. shader: string;
  20921. };
  20922. }
  20923. declare module BABYLON {
  20924. /**
  20925. * Base block used to read a reflection texture from a sampler
  20926. */
  20927. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20928. /** @hidden */
  20929. _define3DName: string;
  20930. /** @hidden */
  20931. _defineCubicName: string;
  20932. /** @hidden */
  20933. _defineExplicitName: string;
  20934. /** @hidden */
  20935. _defineProjectionName: string;
  20936. /** @hidden */
  20937. _defineLocalCubicName: string;
  20938. /** @hidden */
  20939. _defineSphericalName: string;
  20940. /** @hidden */
  20941. _definePlanarName: string;
  20942. /** @hidden */
  20943. _defineEquirectangularName: string;
  20944. /** @hidden */
  20945. _defineMirroredEquirectangularFixedName: string;
  20946. /** @hidden */
  20947. _defineEquirectangularFixedName: string;
  20948. /** @hidden */
  20949. _defineSkyboxName: string;
  20950. /** @hidden */
  20951. _defineOppositeZ: string;
  20952. /** @hidden */
  20953. _cubeSamplerName: string;
  20954. /** @hidden */
  20955. _2DSamplerName: string;
  20956. protected _positionUVWName: string;
  20957. protected _directionWName: string;
  20958. protected _reflectionVectorName: string;
  20959. /** @hidden */
  20960. _reflectionCoordsName: string;
  20961. /** @hidden */
  20962. _reflectionMatrixName: string;
  20963. protected _reflectionColorName: string;
  20964. /**
  20965. * Gets or sets the texture associated with the node
  20966. */
  20967. texture: Nullable<BaseTexture>;
  20968. /**
  20969. * Create a new ReflectionTextureBaseBlock
  20970. * @param name defines the block name
  20971. */
  20972. constructor(name: string);
  20973. /**
  20974. * Gets the current class name
  20975. * @returns the class name
  20976. */
  20977. getClassName(): string;
  20978. /**
  20979. * Gets the world position input component
  20980. */
  20981. abstract get position(): NodeMaterialConnectionPoint;
  20982. /**
  20983. * Gets the world position input component
  20984. */
  20985. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20986. /**
  20987. * Gets the world normal input component
  20988. */
  20989. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20990. /**
  20991. * Gets the world input component
  20992. */
  20993. abstract get world(): NodeMaterialConnectionPoint;
  20994. /**
  20995. * Gets the camera (or eye) position component
  20996. */
  20997. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20998. /**
  20999. * Gets the view input component
  21000. */
  21001. abstract get view(): NodeMaterialConnectionPoint;
  21002. protected _getTexture(): Nullable<BaseTexture>;
  21003. autoConfigure(material: NodeMaterial): void;
  21004. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21005. isReady(): boolean;
  21006. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21007. /**
  21008. * Gets the code to inject in the vertex shader
  21009. * @param state current state of the node material building
  21010. * @returns the shader code
  21011. */
  21012. handleVertexSide(state: NodeMaterialBuildState): string;
  21013. /**
  21014. * Handles the inits for the fragment code path
  21015. * @param state node material build state
  21016. */
  21017. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21018. /**
  21019. * Generates the reflection coords code for the fragment code path
  21020. * @param worldNormalVarName name of the world normal variable
  21021. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21022. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21023. * @returns the shader code
  21024. */
  21025. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21026. /**
  21027. * Generates the reflection color code for the fragment code path
  21028. * @param lodVarName name of the lod variable
  21029. * @param swizzleLookupTexture swizzle to use for the final color variable
  21030. * @returns the shader code
  21031. */
  21032. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21033. /**
  21034. * Generates the code corresponding to the connected output points
  21035. * @param state node material build state
  21036. * @param varName name of the variable to output
  21037. * @returns the shader code
  21038. */
  21039. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21040. protected _buildBlock(state: NodeMaterialBuildState): this;
  21041. protected _dumpPropertiesCode(): string;
  21042. serialize(): any;
  21043. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21044. }
  21045. }
  21046. declare module BABYLON {
  21047. /**
  21048. * Defines a connection point to be used for points with a custom object type
  21049. */
  21050. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21051. private _blockType;
  21052. private _blockName;
  21053. private _nameForCheking?;
  21054. /**
  21055. * Creates a new connection point
  21056. * @param name defines the connection point name
  21057. * @param ownerBlock defines the block hosting this connection point
  21058. * @param direction defines the direction of the connection point
  21059. */
  21060. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21061. /**
  21062. * Gets a number indicating if the current point can be connected to another point
  21063. * @param connectionPoint defines the other connection point
  21064. * @returns a number defining the compatibility state
  21065. */
  21066. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21067. /**
  21068. * Creates a block suitable to be used as an input for this input point.
  21069. * If null is returned, a block based on the point type will be created.
  21070. * @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
  21071. */
  21072. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21073. }
  21074. }
  21075. declare module BABYLON {
  21076. /**
  21077. * Enum defining the type of properties that can be edited in the property pages in the NME
  21078. */
  21079. export enum PropertyTypeForEdition {
  21080. /** property is a boolean */
  21081. Boolean = 0,
  21082. /** property is a float */
  21083. Float = 1,
  21084. /** property is a Vector2 */
  21085. Vector2 = 2,
  21086. /** property is a list of values */
  21087. List = 3
  21088. }
  21089. /**
  21090. * Interface that defines an option in a variable of type list
  21091. */
  21092. export interface IEditablePropertyListOption {
  21093. /** label of the option */
  21094. "label": string;
  21095. /** value of the option */
  21096. "value": number;
  21097. }
  21098. /**
  21099. * Interface that defines the options available for an editable property
  21100. */
  21101. export interface IEditablePropertyOption {
  21102. /** min value */
  21103. "min"?: number;
  21104. /** max value */
  21105. "max"?: number;
  21106. /** notifiers: indicates which actions to take when the property is changed */
  21107. "notifiers"?: {
  21108. /** the material should be rebuilt */
  21109. "rebuild"?: boolean;
  21110. /** the preview should be updated */
  21111. "update"?: boolean;
  21112. };
  21113. /** list of the options for a variable of type list */
  21114. "options"?: IEditablePropertyListOption[];
  21115. }
  21116. /**
  21117. * Interface that describes an editable property
  21118. */
  21119. export interface IPropertyDescriptionForEdition {
  21120. /** name of the property */
  21121. "propertyName": string;
  21122. /** display name of the property */
  21123. "displayName": string;
  21124. /** type of the property */
  21125. "type": PropertyTypeForEdition;
  21126. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21127. "groupName": string;
  21128. /** options for the property */
  21129. "options": IEditablePropertyOption;
  21130. }
  21131. /**
  21132. * Decorator that flags a property in a node material block as being editable
  21133. */
  21134. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21135. }
  21136. declare module BABYLON {
  21137. /**
  21138. * Block used to implement the refraction part of the sub surface module of the PBR material
  21139. */
  21140. export class RefractionBlock extends NodeMaterialBlock {
  21141. /** @hidden */
  21142. _define3DName: string;
  21143. /** @hidden */
  21144. _refractionMatrixName: string;
  21145. /** @hidden */
  21146. _defineLODRefractionAlpha: string;
  21147. /** @hidden */
  21148. _defineLinearSpecularRefraction: string;
  21149. /** @hidden */
  21150. _defineOppositeZ: string;
  21151. /** @hidden */
  21152. _cubeSamplerName: string;
  21153. /** @hidden */
  21154. _2DSamplerName: string;
  21155. /** @hidden */
  21156. _vRefractionMicrosurfaceInfosName: string;
  21157. /** @hidden */
  21158. _vRefractionInfosName: string;
  21159. private _scene;
  21160. /**
  21161. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21162. * Materials half opaque for instance using refraction could benefit from this control.
  21163. */
  21164. linkRefractionWithTransparency: boolean;
  21165. /**
  21166. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21167. */
  21168. invertRefractionY: boolean;
  21169. /**
  21170. * Gets or sets the texture associated with the node
  21171. */
  21172. texture: Nullable<BaseTexture>;
  21173. /**
  21174. * Create a new RefractionBlock
  21175. * @param name defines the block name
  21176. */
  21177. constructor(name: string);
  21178. /**
  21179. * Gets the current class name
  21180. * @returns the class name
  21181. */
  21182. getClassName(): string;
  21183. /**
  21184. * Gets the intensity input component
  21185. */
  21186. get intensity(): NodeMaterialConnectionPoint;
  21187. /**
  21188. * Gets the index of refraction input component
  21189. */
  21190. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21191. /**
  21192. * Gets the tint at distance input component
  21193. */
  21194. get tintAtDistance(): NodeMaterialConnectionPoint;
  21195. /**
  21196. * Gets the view input component
  21197. */
  21198. get view(): NodeMaterialConnectionPoint;
  21199. /**
  21200. * Gets the refraction object output component
  21201. */
  21202. get refraction(): NodeMaterialConnectionPoint;
  21203. /**
  21204. * Returns true if the block has a texture
  21205. */
  21206. get hasTexture(): boolean;
  21207. protected _getTexture(): Nullable<BaseTexture>;
  21208. autoConfigure(material: NodeMaterial): void;
  21209. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21210. isReady(): boolean;
  21211. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21212. /**
  21213. * Gets the main code of the block (fragment side)
  21214. * @param state current state of the node material building
  21215. * @returns the shader code
  21216. */
  21217. getCode(state: NodeMaterialBuildState): string;
  21218. protected _buildBlock(state: NodeMaterialBuildState): this;
  21219. protected _dumpPropertiesCode(): string;
  21220. serialize(): any;
  21221. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21222. }
  21223. }
  21224. declare module BABYLON {
  21225. /**
  21226. * Base block used as input for post process
  21227. */
  21228. export class CurrentScreenBlock extends NodeMaterialBlock {
  21229. private _samplerName;
  21230. private _linearDefineName;
  21231. private _gammaDefineName;
  21232. private _mainUVName;
  21233. private _tempTextureRead;
  21234. /**
  21235. * Gets or sets the texture associated with the node
  21236. */
  21237. texture: Nullable<BaseTexture>;
  21238. /**
  21239. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21240. */
  21241. convertToGammaSpace: boolean;
  21242. /**
  21243. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21244. */
  21245. convertToLinearSpace: boolean;
  21246. /**
  21247. * Create a new CurrentScreenBlock
  21248. * @param name defines the block name
  21249. */
  21250. constructor(name: string);
  21251. /**
  21252. * Gets the current class name
  21253. * @returns the class name
  21254. */
  21255. getClassName(): string;
  21256. /**
  21257. * Gets the uv input component
  21258. */
  21259. get uv(): NodeMaterialConnectionPoint;
  21260. /**
  21261. * Gets the rgba output component
  21262. */
  21263. get rgba(): NodeMaterialConnectionPoint;
  21264. /**
  21265. * Gets the rgb output component
  21266. */
  21267. get rgb(): NodeMaterialConnectionPoint;
  21268. /**
  21269. * Gets the r output component
  21270. */
  21271. get r(): NodeMaterialConnectionPoint;
  21272. /**
  21273. * Gets the g output component
  21274. */
  21275. get g(): NodeMaterialConnectionPoint;
  21276. /**
  21277. * Gets the b output component
  21278. */
  21279. get b(): NodeMaterialConnectionPoint;
  21280. /**
  21281. * Gets the a output component
  21282. */
  21283. get a(): NodeMaterialConnectionPoint;
  21284. /**
  21285. * Initialize the block and prepare the context for build
  21286. * @param state defines the state that will be used for the build
  21287. */
  21288. initialize(state: NodeMaterialBuildState): void;
  21289. get target(): NodeMaterialBlockTargets;
  21290. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21291. isReady(): boolean;
  21292. private _injectVertexCode;
  21293. private _writeTextureRead;
  21294. private _writeOutput;
  21295. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21296. serialize(): any;
  21297. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21298. }
  21299. }
  21300. declare module BABYLON {
  21301. /**
  21302. * Base block used for the particle texture
  21303. */
  21304. export class ParticleTextureBlock extends NodeMaterialBlock {
  21305. private _samplerName;
  21306. private _linearDefineName;
  21307. private _gammaDefineName;
  21308. private _tempTextureRead;
  21309. /**
  21310. * Gets or sets the texture associated with the node
  21311. */
  21312. texture: Nullable<BaseTexture>;
  21313. /**
  21314. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21315. */
  21316. convertToGammaSpace: boolean;
  21317. /**
  21318. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21319. */
  21320. convertToLinearSpace: boolean;
  21321. /**
  21322. * Create a new ParticleTextureBlock
  21323. * @param name defines the block name
  21324. */
  21325. constructor(name: string);
  21326. /**
  21327. * Gets the current class name
  21328. * @returns the class name
  21329. */
  21330. getClassName(): string;
  21331. /**
  21332. * Gets the uv input component
  21333. */
  21334. get uv(): NodeMaterialConnectionPoint;
  21335. /**
  21336. * Gets the rgba output component
  21337. */
  21338. get rgba(): NodeMaterialConnectionPoint;
  21339. /**
  21340. * Gets the rgb output component
  21341. */
  21342. get rgb(): NodeMaterialConnectionPoint;
  21343. /**
  21344. * Gets the r output component
  21345. */
  21346. get r(): NodeMaterialConnectionPoint;
  21347. /**
  21348. * Gets the g output component
  21349. */
  21350. get g(): NodeMaterialConnectionPoint;
  21351. /**
  21352. * Gets the b output component
  21353. */
  21354. get b(): NodeMaterialConnectionPoint;
  21355. /**
  21356. * Gets the a output component
  21357. */
  21358. get a(): NodeMaterialConnectionPoint;
  21359. /**
  21360. * Initialize the block and prepare the context for build
  21361. * @param state defines the state that will be used for the build
  21362. */
  21363. initialize(state: NodeMaterialBuildState): void;
  21364. autoConfigure(material: NodeMaterial): void;
  21365. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21366. isReady(): boolean;
  21367. private _writeOutput;
  21368. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21369. serialize(): any;
  21370. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21371. }
  21372. }
  21373. declare module BABYLON {
  21374. /**
  21375. * Class used to store shared data between 2 NodeMaterialBuildState
  21376. */
  21377. export class NodeMaterialBuildStateSharedData {
  21378. /**
  21379. * Gets the list of emitted varyings
  21380. */
  21381. temps: string[];
  21382. /**
  21383. * Gets the list of emitted varyings
  21384. */
  21385. varyings: string[];
  21386. /**
  21387. * Gets the varying declaration string
  21388. */
  21389. varyingDeclaration: string;
  21390. /**
  21391. * Input blocks
  21392. */
  21393. inputBlocks: InputBlock[];
  21394. /**
  21395. * Input blocks
  21396. */
  21397. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21398. /**
  21399. * Bindable blocks (Blocks that need to set data to the effect)
  21400. */
  21401. bindableBlocks: NodeMaterialBlock[];
  21402. /**
  21403. * List of blocks that can provide a compilation fallback
  21404. */
  21405. blocksWithFallbacks: NodeMaterialBlock[];
  21406. /**
  21407. * List of blocks that can provide a define update
  21408. */
  21409. blocksWithDefines: NodeMaterialBlock[];
  21410. /**
  21411. * List of blocks that can provide a repeatable content
  21412. */
  21413. repeatableContentBlocks: NodeMaterialBlock[];
  21414. /**
  21415. * List of blocks that can provide a dynamic list of uniforms
  21416. */
  21417. dynamicUniformBlocks: NodeMaterialBlock[];
  21418. /**
  21419. * List of blocks that can block the isReady function for the material
  21420. */
  21421. blockingBlocks: NodeMaterialBlock[];
  21422. /**
  21423. * Gets the list of animated inputs
  21424. */
  21425. animatedInputs: InputBlock[];
  21426. /**
  21427. * Build Id used to avoid multiple recompilations
  21428. */
  21429. buildId: number;
  21430. /** List of emitted variables */
  21431. variableNames: {
  21432. [key: string]: number;
  21433. };
  21434. /** List of emitted defines */
  21435. defineNames: {
  21436. [key: string]: number;
  21437. };
  21438. /** Should emit comments? */
  21439. emitComments: boolean;
  21440. /** Emit build activity */
  21441. verbose: boolean;
  21442. /** Gets or sets the hosting scene */
  21443. scene: Scene;
  21444. /**
  21445. * Gets the compilation hints emitted at compilation time
  21446. */
  21447. hints: {
  21448. needWorldViewMatrix: boolean;
  21449. needWorldViewProjectionMatrix: boolean;
  21450. needAlphaBlending: boolean;
  21451. needAlphaTesting: boolean;
  21452. };
  21453. /**
  21454. * List of compilation checks
  21455. */
  21456. checks: {
  21457. emitVertex: boolean;
  21458. emitFragment: boolean;
  21459. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21460. };
  21461. /**
  21462. * Is vertex program allowed to be empty?
  21463. */
  21464. allowEmptyVertexProgram: boolean;
  21465. /** Creates a new shared data */
  21466. constructor();
  21467. /**
  21468. * Emits console errors and exceptions if there is a failing check
  21469. */
  21470. emitErrors(): void;
  21471. }
  21472. }
  21473. declare module BABYLON {
  21474. /**
  21475. * Class used to store node based material build state
  21476. */
  21477. export class NodeMaterialBuildState {
  21478. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21479. supportUniformBuffers: boolean;
  21480. /**
  21481. * Gets the list of emitted attributes
  21482. */
  21483. attributes: string[];
  21484. /**
  21485. * Gets the list of emitted uniforms
  21486. */
  21487. uniforms: string[];
  21488. /**
  21489. * Gets the list of emitted constants
  21490. */
  21491. constants: string[];
  21492. /**
  21493. * Gets the list of emitted samplers
  21494. */
  21495. samplers: string[];
  21496. /**
  21497. * Gets the list of emitted functions
  21498. */
  21499. functions: {
  21500. [key: string]: string;
  21501. };
  21502. /**
  21503. * Gets the list of emitted extensions
  21504. */
  21505. extensions: {
  21506. [key: string]: string;
  21507. };
  21508. /**
  21509. * Gets the target of the compilation state
  21510. */
  21511. target: NodeMaterialBlockTargets;
  21512. /**
  21513. * Gets the list of emitted counters
  21514. */
  21515. counters: {
  21516. [key: string]: number;
  21517. };
  21518. /**
  21519. * Shared data between multiple NodeMaterialBuildState instances
  21520. */
  21521. sharedData: NodeMaterialBuildStateSharedData;
  21522. /** @hidden */
  21523. _vertexState: NodeMaterialBuildState;
  21524. /** @hidden */
  21525. _attributeDeclaration: string;
  21526. /** @hidden */
  21527. _uniformDeclaration: string;
  21528. /** @hidden */
  21529. _constantDeclaration: string;
  21530. /** @hidden */
  21531. _samplerDeclaration: string;
  21532. /** @hidden */
  21533. _varyingTransfer: string;
  21534. /** @hidden */
  21535. _injectAtEnd: string;
  21536. private _repeatableContentAnchorIndex;
  21537. /** @hidden */
  21538. _builtCompilationString: string;
  21539. /**
  21540. * Gets the emitted compilation strings
  21541. */
  21542. compilationString: string;
  21543. /**
  21544. * Finalize the compilation strings
  21545. * @param state defines the current compilation state
  21546. */
  21547. finalize(state: NodeMaterialBuildState): void;
  21548. /** @hidden */
  21549. get _repeatableContentAnchor(): string;
  21550. /** @hidden */
  21551. _getFreeVariableName(prefix: string): string;
  21552. /** @hidden */
  21553. _getFreeDefineName(prefix: string): string;
  21554. /** @hidden */
  21555. _excludeVariableName(name: string): void;
  21556. /** @hidden */
  21557. _emit2DSampler(name: string): void;
  21558. /** @hidden */
  21559. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21560. /** @hidden */
  21561. _emitExtension(name: string, extension: string, define?: string): void;
  21562. /** @hidden */
  21563. _emitFunction(name: string, code: string, comments: string): void;
  21564. /** @hidden */
  21565. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21566. replaceStrings?: {
  21567. search: RegExp;
  21568. replace: string;
  21569. }[];
  21570. repeatKey?: string;
  21571. }): string;
  21572. /** @hidden */
  21573. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21574. repeatKey?: string;
  21575. removeAttributes?: boolean;
  21576. removeUniforms?: boolean;
  21577. removeVaryings?: boolean;
  21578. removeIfDef?: boolean;
  21579. replaceStrings?: {
  21580. search: RegExp;
  21581. replace: string;
  21582. }[];
  21583. }, storeKey?: string): void;
  21584. /** @hidden */
  21585. _registerTempVariable(name: string): boolean;
  21586. /** @hidden */
  21587. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21588. /** @hidden */
  21589. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21590. /** @hidden */
  21591. _emitFloat(value: number): string;
  21592. }
  21593. }
  21594. declare module BABYLON {
  21595. /**
  21596. * Helper class used to generate session unique ID
  21597. */
  21598. export class UniqueIdGenerator {
  21599. private static _UniqueIdCounter;
  21600. /**
  21601. * Gets an unique (relatively to the current scene) Id
  21602. */
  21603. static get UniqueId(): number;
  21604. }
  21605. }
  21606. declare module BABYLON {
  21607. /**
  21608. * Defines a block that can be used inside a node based material
  21609. */
  21610. export class NodeMaterialBlock {
  21611. private _buildId;
  21612. private _buildTarget;
  21613. private _target;
  21614. private _isFinalMerger;
  21615. private _isInput;
  21616. private _name;
  21617. protected _isUnique: boolean;
  21618. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21619. inputsAreExclusive: boolean;
  21620. /** @hidden */
  21621. _codeVariableName: string;
  21622. /** @hidden */
  21623. _inputs: NodeMaterialConnectionPoint[];
  21624. /** @hidden */
  21625. _outputs: NodeMaterialConnectionPoint[];
  21626. /** @hidden */
  21627. _preparationId: number;
  21628. /**
  21629. * Gets the name of the block
  21630. */
  21631. get name(): string;
  21632. /**
  21633. * Sets the name of the block. Will check if the name is valid.
  21634. */
  21635. set name(newName: string);
  21636. /**
  21637. * Gets or sets the unique id of the node
  21638. */
  21639. uniqueId: number;
  21640. /**
  21641. * Gets or sets the comments associated with this block
  21642. */
  21643. comments: string;
  21644. /**
  21645. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21646. */
  21647. get isUnique(): boolean;
  21648. /**
  21649. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21650. */
  21651. get isFinalMerger(): boolean;
  21652. /**
  21653. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21654. */
  21655. get isInput(): boolean;
  21656. /**
  21657. * Gets or sets the build Id
  21658. */
  21659. get buildId(): number;
  21660. set buildId(value: number);
  21661. /**
  21662. * Gets or sets the target of the block
  21663. */
  21664. get target(): NodeMaterialBlockTargets;
  21665. set target(value: NodeMaterialBlockTargets);
  21666. /**
  21667. * Gets the list of input points
  21668. */
  21669. get inputs(): NodeMaterialConnectionPoint[];
  21670. /** Gets the list of output points */
  21671. get outputs(): NodeMaterialConnectionPoint[];
  21672. /**
  21673. * Find an input by its name
  21674. * @param name defines the name of the input to look for
  21675. * @returns the input or null if not found
  21676. */
  21677. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21678. /**
  21679. * Find an output by its name
  21680. * @param name defines the name of the outputto look for
  21681. * @returns the output or null if not found
  21682. */
  21683. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21684. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  21685. visibleInInspector: boolean;
  21686. /**
  21687. * Creates a new NodeMaterialBlock
  21688. * @param name defines the block name
  21689. * @param target defines the target of that block (Vertex by default)
  21690. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21691. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21692. */
  21693. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21694. /**
  21695. * Initialize the block and prepare the context for build
  21696. * @param state defines the state that will be used for the build
  21697. */
  21698. initialize(state: NodeMaterialBuildState): void;
  21699. /**
  21700. * Bind data to effect. Will only be called for blocks with isBindable === true
  21701. * @param effect defines the effect to bind data to
  21702. * @param nodeMaterial defines the hosting NodeMaterial
  21703. * @param mesh defines the mesh that will be rendered
  21704. * @param subMesh defines the submesh that will be rendered
  21705. */
  21706. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21707. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21708. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21709. protected _writeFloat(value: number): string;
  21710. /**
  21711. * Gets the current class name e.g. "NodeMaterialBlock"
  21712. * @returns the class name
  21713. */
  21714. getClassName(): string;
  21715. /**
  21716. * Register a new input. Must be called inside a block constructor
  21717. * @param name defines the connection point name
  21718. * @param type defines the connection point type
  21719. * @param isOptional defines a boolean indicating that this input can be omitted
  21720. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21721. * @param point an already created connection point. If not provided, create a new one
  21722. * @returns the current block
  21723. */
  21724. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21725. /**
  21726. * Register a new output. Must be called inside a block constructor
  21727. * @param name defines the connection point name
  21728. * @param type defines the connection point type
  21729. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21730. * @param point an already created connection point. If not provided, create a new one
  21731. * @returns the current block
  21732. */
  21733. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21734. /**
  21735. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21736. * @param forOutput defines an optional connection point to check compatibility with
  21737. * @returns the first available input or null
  21738. */
  21739. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21740. /**
  21741. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21742. * @param forBlock defines an optional block to check compatibility with
  21743. * @returns the first available input or null
  21744. */
  21745. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21746. /**
  21747. * Gets the sibling of the given output
  21748. * @param current defines the current output
  21749. * @returns the next output in the list or null
  21750. */
  21751. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21752. /**
  21753. * Connect current block with another block
  21754. * @param other defines the block to connect with
  21755. * @param options define the various options to help pick the right connections
  21756. * @returns the current block
  21757. */
  21758. connectTo(other: NodeMaterialBlock, options?: {
  21759. input?: string;
  21760. output?: string;
  21761. outputSwizzle?: string;
  21762. }): this | undefined;
  21763. protected _buildBlock(state: NodeMaterialBuildState): void;
  21764. /**
  21765. * Add uniforms, samplers and uniform buffers at compilation time
  21766. * @param state defines the state to update
  21767. * @param nodeMaterial defines the node material requesting the update
  21768. * @param defines defines the material defines to update
  21769. * @param uniformBuffers defines the list of uniform buffer names
  21770. */
  21771. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21772. /**
  21773. * Add potential fallbacks if shader compilation fails
  21774. * @param mesh defines the mesh to be rendered
  21775. * @param fallbacks defines the current prioritized list of fallbacks
  21776. */
  21777. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21778. /**
  21779. * Initialize defines for shader compilation
  21780. * @param mesh defines the mesh to be rendered
  21781. * @param nodeMaterial defines the node material requesting the update
  21782. * @param defines defines the material defines to update
  21783. * @param useInstances specifies that instances should be used
  21784. */
  21785. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21786. /**
  21787. * Update defines for shader compilation
  21788. * @param mesh defines the mesh to be rendered
  21789. * @param nodeMaterial defines the node material requesting the update
  21790. * @param defines defines the material defines to update
  21791. * @param useInstances specifies that instances should be used
  21792. * @param subMesh defines which submesh to render
  21793. */
  21794. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21795. /**
  21796. * Lets the block try to connect some inputs automatically
  21797. * @param material defines the hosting NodeMaterial
  21798. */
  21799. autoConfigure(material: NodeMaterial): void;
  21800. /**
  21801. * Function called when a block is declared as repeatable content generator
  21802. * @param vertexShaderState defines the current compilation state for the vertex shader
  21803. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21804. * @param mesh defines the mesh to be rendered
  21805. * @param defines defines the material defines to update
  21806. */
  21807. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21808. /**
  21809. * Checks if the block is ready
  21810. * @param mesh defines the mesh to be rendered
  21811. * @param nodeMaterial defines the node material requesting the update
  21812. * @param defines defines the material defines to update
  21813. * @param useInstances specifies that instances should be used
  21814. * @returns true if the block is ready
  21815. */
  21816. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21817. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21818. private _processBuild;
  21819. /**
  21820. * Validates the new name for the block node.
  21821. * @param newName the new name to be given to the node.
  21822. * @returns false if the name is a reserve word, else true.
  21823. */
  21824. validateBlockName(newName: string): boolean;
  21825. /**
  21826. * Compile the current node and generate the shader code
  21827. * @param state defines the current compilation state (uniforms, samplers, current string)
  21828. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21829. * @returns true if already built
  21830. */
  21831. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21832. protected _inputRename(name: string): string;
  21833. protected _outputRename(name: string): string;
  21834. protected _dumpPropertiesCode(): string;
  21835. /** @hidden */
  21836. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21837. /** @hidden */
  21838. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21839. /**
  21840. * Clone the current block to a new identical block
  21841. * @param scene defines the hosting scene
  21842. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21843. * @returns a copy of the current block
  21844. */
  21845. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21846. /**
  21847. * Serializes this block in a JSON representation
  21848. * @returns the serialized block object
  21849. */
  21850. serialize(): any;
  21851. /** @hidden */
  21852. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21853. private _deserializePortDisplayNamesAndExposedOnFrame;
  21854. /**
  21855. * Release resources
  21856. */
  21857. dispose(): void;
  21858. }
  21859. }
  21860. declare module BABYLON {
  21861. /**
  21862. * Base class of materials working in push mode in babylon JS
  21863. * @hidden
  21864. */
  21865. export class PushMaterial extends Material {
  21866. protected _activeEffect: Effect;
  21867. protected _normalMatrix: Matrix;
  21868. constructor(name: string, scene: Scene);
  21869. getEffect(): Effect;
  21870. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21871. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21872. /**
  21873. * Binds the given world matrix to the active effect
  21874. *
  21875. * @param world the matrix to bind
  21876. */
  21877. bindOnlyWorldMatrix(world: Matrix): void;
  21878. /**
  21879. * Binds the given normal matrix to the active effect
  21880. *
  21881. * @param normalMatrix the matrix to bind
  21882. */
  21883. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21884. bind(world: Matrix, mesh?: Mesh): void;
  21885. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21886. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21887. }
  21888. }
  21889. declare module BABYLON {
  21890. /**
  21891. * Root class for all node material optimizers
  21892. */
  21893. export class NodeMaterialOptimizer {
  21894. /**
  21895. * Function used to optimize a NodeMaterial graph
  21896. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21897. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21898. */
  21899. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21900. }
  21901. }
  21902. declare module BABYLON {
  21903. /**
  21904. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21905. */
  21906. export class TransformBlock extends NodeMaterialBlock {
  21907. /**
  21908. * Defines the value to use to complement W value to transform it to a Vector4
  21909. */
  21910. complementW: number;
  21911. /**
  21912. * Defines the value to use to complement z value to transform it to a Vector4
  21913. */
  21914. complementZ: number;
  21915. /**
  21916. * Creates a new TransformBlock
  21917. * @param name defines the block name
  21918. */
  21919. constructor(name: string);
  21920. /**
  21921. * Gets the current class name
  21922. * @returns the class name
  21923. */
  21924. getClassName(): string;
  21925. /**
  21926. * Gets the vector input
  21927. */
  21928. get vector(): NodeMaterialConnectionPoint;
  21929. /**
  21930. * Gets the output component
  21931. */
  21932. get output(): NodeMaterialConnectionPoint;
  21933. /**
  21934. * Gets the xyz output component
  21935. */
  21936. get xyz(): NodeMaterialConnectionPoint;
  21937. /**
  21938. * Gets the matrix transform input
  21939. */
  21940. get transform(): NodeMaterialConnectionPoint;
  21941. protected _buildBlock(state: NodeMaterialBuildState): this;
  21942. /**
  21943. * Update defines for shader compilation
  21944. * @param mesh defines the mesh to be rendered
  21945. * @param nodeMaterial defines the node material requesting the update
  21946. * @param defines defines the material defines to update
  21947. * @param useInstances specifies that instances should be used
  21948. * @param subMesh defines which submesh to render
  21949. */
  21950. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21951. serialize(): any;
  21952. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21953. protected _dumpPropertiesCode(): string;
  21954. }
  21955. }
  21956. declare module BABYLON {
  21957. /**
  21958. * Block used to output the vertex position
  21959. */
  21960. export class VertexOutputBlock extends NodeMaterialBlock {
  21961. /**
  21962. * Creates a new VertexOutputBlock
  21963. * @param name defines the block name
  21964. */
  21965. constructor(name: string);
  21966. /**
  21967. * Gets the current class name
  21968. * @returns the class name
  21969. */
  21970. getClassName(): string;
  21971. /**
  21972. * Gets the vector input component
  21973. */
  21974. get vector(): NodeMaterialConnectionPoint;
  21975. protected _buildBlock(state: NodeMaterialBuildState): this;
  21976. }
  21977. }
  21978. declare module BABYLON {
  21979. /**
  21980. * Block used to output the final color
  21981. */
  21982. export class FragmentOutputBlock extends NodeMaterialBlock {
  21983. /**
  21984. * Create a new FragmentOutputBlock
  21985. * @param name defines the block name
  21986. */
  21987. constructor(name: string);
  21988. /**
  21989. * Gets the current class name
  21990. * @returns the class name
  21991. */
  21992. getClassName(): string;
  21993. /**
  21994. * Gets the rgba input component
  21995. */
  21996. get rgba(): NodeMaterialConnectionPoint;
  21997. /**
  21998. * Gets the rgb input component
  21999. */
  22000. get rgb(): NodeMaterialConnectionPoint;
  22001. /**
  22002. * Gets the a input component
  22003. */
  22004. get a(): NodeMaterialConnectionPoint;
  22005. protected _buildBlock(state: NodeMaterialBuildState): this;
  22006. }
  22007. }
  22008. declare module BABYLON {
  22009. /**
  22010. * Block used for the particle ramp gradient section
  22011. */
  22012. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22013. /**
  22014. * Create a new ParticleRampGradientBlock
  22015. * @param name defines the block name
  22016. */
  22017. constructor(name: string);
  22018. /**
  22019. * Gets the current class name
  22020. * @returns the class name
  22021. */
  22022. getClassName(): string;
  22023. /**
  22024. * Gets the color input component
  22025. */
  22026. get color(): NodeMaterialConnectionPoint;
  22027. /**
  22028. * Gets the rampColor output component
  22029. */
  22030. get rampColor(): NodeMaterialConnectionPoint;
  22031. /**
  22032. * Initialize the block and prepare the context for build
  22033. * @param state defines the state that will be used for the build
  22034. */
  22035. initialize(state: NodeMaterialBuildState): void;
  22036. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22037. }
  22038. }
  22039. declare module BABYLON {
  22040. /**
  22041. * Block used for the particle blend multiply section
  22042. */
  22043. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22044. /**
  22045. * Create a new ParticleBlendMultiplyBlock
  22046. * @param name defines the block name
  22047. */
  22048. constructor(name: string);
  22049. /**
  22050. * Gets the current class name
  22051. * @returns the class name
  22052. */
  22053. getClassName(): string;
  22054. /**
  22055. * Gets the color input component
  22056. */
  22057. get color(): NodeMaterialConnectionPoint;
  22058. /**
  22059. * Gets the alphaTexture input component
  22060. */
  22061. get alphaTexture(): NodeMaterialConnectionPoint;
  22062. /**
  22063. * Gets the alphaColor input component
  22064. */
  22065. get alphaColor(): NodeMaterialConnectionPoint;
  22066. /**
  22067. * Gets the blendColor output component
  22068. */
  22069. get blendColor(): NodeMaterialConnectionPoint;
  22070. /**
  22071. * Initialize the block and prepare the context for build
  22072. * @param state defines the state that will be used for the build
  22073. */
  22074. initialize(state: NodeMaterialBuildState): void;
  22075. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22076. }
  22077. }
  22078. declare module BABYLON {
  22079. /**
  22080. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22081. */
  22082. export class VectorMergerBlock extends NodeMaterialBlock {
  22083. /**
  22084. * Create a new VectorMergerBlock
  22085. * @param name defines the block name
  22086. */
  22087. constructor(name: string);
  22088. /**
  22089. * Gets the current class name
  22090. * @returns the class name
  22091. */
  22092. getClassName(): string;
  22093. /**
  22094. * Gets the xyz component (input)
  22095. */
  22096. get xyzIn(): NodeMaterialConnectionPoint;
  22097. /**
  22098. * Gets the xy component (input)
  22099. */
  22100. get xyIn(): NodeMaterialConnectionPoint;
  22101. /**
  22102. * Gets the x component (input)
  22103. */
  22104. get x(): NodeMaterialConnectionPoint;
  22105. /**
  22106. * Gets the y component (input)
  22107. */
  22108. get y(): NodeMaterialConnectionPoint;
  22109. /**
  22110. * Gets the z component (input)
  22111. */
  22112. get z(): NodeMaterialConnectionPoint;
  22113. /**
  22114. * Gets the w component (input)
  22115. */
  22116. get w(): NodeMaterialConnectionPoint;
  22117. /**
  22118. * Gets the xyzw component (output)
  22119. */
  22120. get xyzw(): NodeMaterialConnectionPoint;
  22121. /**
  22122. * Gets the xyz component (output)
  22123. */
  22124. get xyzOut(): NodeMaterialConnectionPoint;
  22125. /**
  22126. * Gets the xy component (output)
  22127. */
  22128. get xyOut(): NodeMaterialConnectionPoint;
  22129. /**
  22130. * Gets the xy component (output)
  22131. * @deprecated Please use xyOut instead.
  22132. */
  22133. get xy(): NodeMaterialConnectionPoint;
  22134. /**
  22135. * Gets the xyz component (output)
  22136. * @deprecated Please use xyzOut instead.
  22137. */
  22138. get xyz(): NodeMaterialConnectionPoint;
  22139. protected _buildBlock(state: NodeMaterialBuildState): this;
  22140. }
  22141. }
  22142. declare module BABYLON {
  22143. /**
  22144. * Block used to remap a float from a range to a new one
  22145. */
  22146. export class RemapBlock extends NodeMaterialBlock {
  22147. /**
  22148. * Gets or sets the source range
  22149. */
  22150. sourceRange: Vector2;
  22151. /**
  22152. * Gets or sets the target range
  22153. */
  22154. targetRange: Vector2;
  22155. /**
  22156. * Creates a new RemapBlock
  22157. * @param name defines the block name
  22158. */
  22159. constructor(name: string);
  22160. /**
  22161. * Gets the current class name
  22162. * @returns the class name
  22163. */
  22164. getClassName(): string;
  22165. /**
  22166. * Gets the input component
  22167. */
  22168. get input(): NodeMaterialConnectionPoint;
  22169. /**
  22170. * Gets the source min input component
  22171. */
  22172. get sourceMin(): NodeMaterialConnectionPoint;
  22173. /**
  22174. * Gets the source max input component
  22175. */
  22176. get sourceMax(): NodeMaterialConnectionPoint;
  22177. /**
  22178. * Gets the target min input component
  22179. */
  22180. get targetMin(): NodeMaterialConnectionPoint;
  22181. /**
  22182. * Gets the target max input component
  22183. */
  22184. get targetMax(): NodeMaterialConnectionPoint;
  22185. /**
  22186. * Gets the output component
  22187. */
  22188. get output(): NodeMaterialConnectionPoint;
  22189. protected _buildBlock(state: NodeMaterialBuildState): this;
  22190. protected _dumpPropertiesCode(): string;
  22191. serialize(): any;
  22192. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22193. }
  22194. }
  22195. declare module BABYLON {
  22196. /**
  22197. * Block used to multiply 2 values
  22198. */
  22199. export class MultiplyBlock extends NodeMaterialBlock {
  22200. /**
  22201. * Creates a new MultiplyBlock
  22202. * @param name defines the block name
  22203. */
  22204. constructor(name: string);
  22205. /**
  22206. * Gets the current class name
  22207. * @returns the class name
  22208. */
  22209. getClassName(): string;
  22210. /**
  22211. * Gets the left operand input component
  22212. */
  22213. get left(): NodeMaterialConnectionPoint;
  22214. /**
  22215. * Gets the right operand input component
  22216. */
  22217. get right(): NodeMaterialConnectionPoint;
  22218. /**
  22219. * Gets the output component
  22220. */
  22221. get output(): NodeMaterialConnectionPoint;
  22222. protected _buildBlock(state: NodeMaterialBuildState): this;
  22223. }
  22224. }
  22225. declare module BABYLON {
  22226. /**
  22227. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22228. */
  22229. export class ColorSplitterBlock extends NodeMaterialBlock {
  22230. /**
  22231. * Create a new ColorSplitterBlock
  22232. * @param name defines the block name
  22233. */
  22234. constructor(name: string);
  22235. /**
  22236. * Gets the current class name
  22237. * @returns the class name
  22238. */
  22239. getClassName(): string;
  22240. /**
  22241. * Gets the rgba component (input)
  22242. */
  22243. get rgba(): NodeMaterialConnectionPoint;
  22244. /**
  22245. * Gets the rgb component (input)
  22246. */
  22247. get rgbIn(): NodeMaterialConnectionPoint;
  22248. /**
  22249. * Gets the rgb component (output)
  22250. */
  22251. get rgbOut(): NodeMaterialConnectionPoint;
  22252. /**
  22253. * Gets the r component (output)
  22254. */
  22255. get r(): NodeMaterialConnectionPoint;
  22256. /**
  22257. * Gets the g component (output)
  22258. */
  22259. get g(): NodeMaterialConnectionPoint;
  22260. /**
  22261. * Gets the b component (output)
  22262. */
  22263. get b(): NodeMaterialConnectionPoint;
  22264. /**
  22265. * Gets the a component (output)
  22266. */
  22267. get a(): NodeMaterialConnectionPoint;
  22268. protected _inputRename(name: string): string;
  22269. protected _outputRename(name: string): string;
  22270. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22271. }
  22272. }
  22273. declare module BABYLON {
  22274. /**
  22275. * Operations supported by the Trigonometry block
  22276. */
  22277. export enum TrigonometryBlockOperations {
  22278. /** Cos */
  22279. Cos = 0,
  22280. /** Sin */
  22281. Sin = 1,
  22282. /** Abs */
  22283. Abs = 2,
  22284. /** Exp */
  22285. Exp = 3,
  22286. /** Exp2 */
  22287. Exp2 = 4,
  22288. /** Round */
  22289. Round = 5,
  22290. /** Floor */
  22291. Floor = 6,
  22292. /** Ceiling */
  22293. Ceiling = 7,
  22294. /** Square root */
  22295. Sqrt = 8,
  22296. /** Log */
  22297. Log = 9,
  22298. /** Tangent */
  22299. Tan = 10,
  22300. /** Arc tangent */
  22301. ArcTan = 11,
  22302. /** Arc cosinus */
  22303. ArcCos = 12,
  22304. /** Arc sinus */
  22305. ArcSin = 13,
  22306. /** Fraction */
  22307. Fract = 14,
  22308. /** Sign */
  22309. Sign = 15,
  22310. /** To radians (from degrees) */
  22311. Radians = 16,
  22312. /** To degrees (from radians) */
  22313. Degrees = 17
  22314. }
  22315. /**
  22316. * Block used to apply trigonometry operation to floats
  22317. */
  22318. export class TrigonometryBlock extends NodeMaterialBlock {
  22319. /**
  22320. * Gets or sets the operation applied by the block
  22321. */
  22322. operation: TrigonometryBlockOperations;
  22323. /**
  22324. * Creates a new TrigonometryBlock
  22325. * @param name defines the block name
  22326. */
  22327. constructor(name: string);
  22328. /**
  22329. * Gets the current class name
  22330. * @returns the class name
  22331. */
  22332. getClassName(): string;
  22333. /**
  22334. * Gets the input component
  22335. */
  22336. get input(): NodeMaterialConnectionPoint;
  22337. /**
  22338. * Gets the output component
  22339. */
  22340. get output(): NodeMaterialConnectionPoint;
  22341. protected _buildBlock(state: NodeMaterialBuildState): this;
  22342. serialize(): any;
  22343. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22344. protected _dumpPropertiesCode(): string;
  22345. }
  22346. }
  22347. declare module BABYLON {
  22348. /**
  22349. * Interface used to configure the node material editor
  22350. */
  22351. export interface INodeMaterialEditorOptions {
  22352. /** Define the URl to load node editor script */
  22353. editorURL?: string;
  22354. }
  22355. /** @hidden */
  22356. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22357. NORMAL: boolean;
  22358. TANGENT: boolean;
  22359. UV1: boolean;
  22360. /** BONES */
  22361. NUM_BONE_INFLUENCERS: number;
  22362. BonesPerMesh: number;
  22363. BONETEXTURE: boolean;
  22364. /** MORPH TARGETS */
  22365. MORPHTARGETS: boolean;
  22366. MORPHTARGETS_NORMAL: boolean;
  22367. MORPHTARGETS_TANGENT: boolean;
  22368. MORPHTARGETS_UV: boolean;
  22369. NUM_MORPH_INFLUENCERS: number;
  22370. /** IMAGE PROCESSING */
  22371. IMAGEPROCESSING: boolean;
  22372. VIGNETTE: boolean;
  22373. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22374. VIGNETTEBLENDMODEOPAQUE: boolean;
  22375. TONEMAPPING: boolean;
  22376. TONEMAPPING_ACES: boolean;
  22377. CONTRAST: boolean;
  22378. EXPOSURE: boolean;
  22379. COLORCURVES: boolean;
  22380. COLORGRADING: boolean;
  22381. COLORGRADING3D: boolean;
  22382. SAMPLER3DGREENDEPTH: boolean;
  22383. SAMPLER3DBGRMAP: boolean;
  22384. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22385. /** MISC. */
  22386. BUMPDIRECTUV: number;
  22387. constructor();
  22388. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22389. }
  22390. /**
  22391. * Class used to configure NodeMaterial
  22392. */
  22393. export interface INodeMaterialOptions {
  22394. /**
  22395. * Defines if blocks should emit comments
  22396. */
  22397. emitComments: boolean;
  22398. }
  22399. /**
  22400. * Class used to create a node based material built by assembling shader blocks
  22401. */
  22402. export class NodeMaterial extends PushMaterial {
  22403. private static _BuildIdGenerator;
  22404. private _options;
  22405. private _vertexCompilationState;
  22406. private _fragmentCompilationState;
  22407. private _sharedData;
  22408. private _buildId;
  22409. private _buildWasSuccessful;
  22410. private _cachedWorldViewMatrix;
  22411. private _cachedWorldViewProjectionMatrix;
  22412. private _optimizers;
  22413. private _animationFrame;
  22414. /** Define the Url to load node editor script */
  22415. static EditorURL: string;
  22416. /** Define the Url to load snippets */
  22417. static SnippetUrl: string;
  22418. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22419. static IgnoreTexturesAtLoadTime: boolean;
  22420. private BJSNODEMATERIALEDITOR;
  22421. /** Get the inspector from bundle or global */
  22422. private _getGlobalNodeMaterialEditor;
  22423. /**
  22424. * Snippet ID if the material was created from the snippet server
  22425. */
  22426. snippetId: string;
  22427. /**
  22428. * Gets or sets data used by visual editor
  22429. * @see https://nme.babylonjs.com
  22430. */
  22431. editorData: any;
  22432. /**
  22433. * 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)
  22434. */
  22435. ignoreAlpha: boolean;
  22436. /**
  22437. * Defines the maximum number of lights that can be used in the material
  22438. */
  22439. maxSimultaneousLights: number;
  22440. /**
  22441. * Observable raised when the material is built
  22442. */
  22443. onBuildObservable: Observable<NodeMaterial>;
  22444. /**
  22445. * Gets or sets the root nodes of the material vertex shader
  22446. */
  22447. _vertexOutputNodes: NodeMaterialBlock[];
  22448. /**
  22449. * Gets or sets the root nodes of the material fragment (pixel) shader
  22450. */
  22451. _fragmentOutputNodes: NodeMaterialBlock[];
  22452. /** Gets or sets options to control the node material overall behavior */
  22453. get options(): INodeMaterialOptions;
  22454. set options(options: INodeMaterialOptions);
  22455. /**
  22456. * Default configuration related to image processing available in the standard Material.
  22457. */
  22458. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22459. /**
  22460. * Gets the image processing configuration used either in this material.
  22461. */
  22462. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22463. /**
  22464. * Sets the Default image processing configuration used either in the this material.
  22465. *
  22466. * If sets to null, the scene one is in use.
  22467. */
  22468. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22469. /**
  22470. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22471. */
  22472. attachedBlocks: NodeMaterialBlock[];
  22473. /**
  22474. * Specifies the mode of the node material
  22475. * @hidden
  22476. */
  22477. _mode: NodeMaterialModes;
  22478. /**
  22479. * Gets the mode property
  22480. */
  22481. get mode(): NodeMaterialModes;
  22482. /**
  22483. * Create a new node based material
  22484. * @param name defines the material name
  22485. * @param scene defines the hosting scene
  22486. * @param options defines creation option
  22487. */
  22488. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22489. /**
  22490. * Gets the current class name of the material e.g. "NodeMaterial"
  22491. * @returns the class name
  22492. */
  22493. getClassName(): string;
  22494. /**
  22495. * Keep track of the image processing observer to allow dispose and replace.
  22496. */
  22497. private _imageProcessingObserver;
  22498. /**
  22499. * Attaches a new image processing configuration to the Standard Material.
  22500. * @param configuration
  22501. */
  22502. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22503. /**
  22504. * Get a block by its name
  22505. * @param name defines the name of the block to retrieve
  22506. * @returns the required block or null if not found
  22507. */
  22508. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22509. /**
  22510. * Get a block by its name
  22511. * @param predicate defines the predicate used to find the good candidate
  22512. * @returns the required block or null if not found
  22513. */
  22514. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22515. /**
  22516. * Get an input block by its name
  22517. * @param predicate defines the predicate used to find the good candidate
  22518. * @returns the required input block or null if not found
  22519. */
  22520. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22521. /**
  22522. * Gets the list of input blocks attached to this material
  22523. * @returns an array of InputBlocks
  22524. */
  22525. getInputBlocks(): InputBlock[];
  22526. /**
  22527. * Adds a new optimizer to the list of optimizers
  22528. * @param optimizer defines the optimizers to add
  22529. * @returns the current material
  22530. */
  22531. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22532. /**
  22533. * Remove an optimizer from the list of optimizers
  22534. * @param optimizer defines the optimizers to remove
  22535. * @returns the current material
  22536. */
  22537. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22538. /**
  22539. * Add a new block to the list of output nodes
  22540. * @param node defines the node to add
  22541. * @returns the current material
  22542. */
  22543. addOutputNode(node: NodeMaterialBlock): this;
  22544. /**
  22545. * Remove a block from the list of root nodes
  22546. * @param node defines the node to remove
  22547. * @returns the current material
  22548. */
  22549. removeOutputNode(node: NodeMaterialBlock): this;
  22550. private _addVertexOutputNode;
  22551. private _removeVertexOutputNode;
  22552. private _addFragmentOutputNode;
  22553. private _removeFragmentOutputNode;
  22554. /**
  22555. * Specifies if the material will require alpha blending
  22556. * @returns a boolean specifying if alpha blending is needed
  22557. */
  22558. needAlphaBlending(): boolean;
  22559. /**
  22560. * Specifies if this material should be rendered in alpha test mode
  22561. * @returns a boolean specifying if an alpha test is needed.
  22562. */
  22563. needAlphaTesting(): boolean;
  22564. private _initializeBlock;
  22565. private _resetDualBlocks;
  22566. /**
  22567. * Remove a block from the current node material
  22568. * @param block defines the block to remove
  22569. */
  22570. removeBlock(block: NodeMaterialBlock): void;
  22571. /**
  22572. * Build the material and generates the inner effect
  22573. * @param verbose defines if the build should log activity
  22574. */
  22575. build(verbose?: boolean): void;
  22576. /**
  22577. * Runs an otpimization phase to try to improve the shader code
  22578. */
  22579. optimize(): void;
  22580. private _prepareDefinesForAttributes;
  22581. /**
  22582. * Create a post process from the material
  22583. * @param camera The camera to apply the render pass to.
  22584. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22585. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22586. * @param engine The engine which the post process will be applied. (default: current engine)
  22587. * @param reusable If the post process can be reused on the same frame. (default: false)
  22588. * @param textureType Type of textures used when performing the post process. (default: 0)
  22589. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22590. * @returns the post process created
  22591. */
  22592. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  22593. /**
  22594. * Create the post process effect from the material
  22595. * @param postProcess The post process to create the effect for
  22596. */
  22597. createEffectForPostProcess(postProcess: PostProcess): void;
  22598. private _createEffectForPostProcess;
  22599. /**
  22600. * Create a new procedural texture based on this node material
  22601. * @param size defines the size of the texture
  22602. * @param scene defines the hosting scene
  22603. * @returns the new procedural texture attached to this node material
  22604. */
  22605. createProceduralTexture(size: number | {
  22606. width: number;
  22607. height: number;
  22608. layers?: number;
  22609. }, scene: Scene): Nullable<ProceduralTexture>;
  22610. private _createEffectForParticles;
  22611. private _checkInternals;
  22612. /**
  22613. * Create the effect to be used as the custom effect for a particle system
  22614. * @param particleSystem Particle system to create the effect for
  22615. * @param onCompiled defines a function to call when the effect creation is successful
  22616. * @param onError defines a function to call when the effect creation has failed
  22617. */
  22618. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22619. private _processDefines;
  22620. /**
  22621. * Get if the submesh is ready to be used and all its information available.
  22622. * Child classes can use it to update shaders
  22623. * @param mesh defines the mesh to check
  22624. * @param subMesh defines which submesh to check
  22625. * @param useInstances specifies that instances should be used
  22626. * @returns a boolean indicating that the submesh is ready or not
  22627. */
  22628. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22629. /**
  22630. * Get a string representing the shaders built by the current node graph
  22631. */
  22632. get compiledShaders(): string;
  22633. /**
  22634. * Binds the world matrix to the material
  22635. * @param world defines the world transformation matrix
  22636. */
  22637. bindOnlyWorldMatrix(world: Matrix): void;
  22638. /**
  22639. * Binds the submesh to this material by preparing the effect and shader to draw
  22640. * @param world defines the world transformation matrix
  22641. * @param mesh defines the mesh containing the submesh
  22642. * @param subMesh defines the submesh to bind the material to
  22643. */
  22644. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22645. /**
  22646. * Gets the active textures from the material
  22647. * @returns an array of textures
  22648. */
  22649. getActiveTextures(): BaseTexture[];
  22650. /**
  22651. * Gets the list of texture blocks
  22652. * @returns an array of texture blocks
  22653. */
  22654. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22655. /**
  22656. * Specifies if the material uses a texture
  22657. * @param texture defines the texture to check against the material
  22658. * @returns a boolean specifying if the material uses the texture
  22659. */
  22660. hasTexture(texture: BaseTexture): boolean;
  22661. /**
  22662. * Disposes the material
  22663. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22664. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22665. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22666. */
  22667. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22668. /** Creates the node editor window. */
  22669. private _createNodeEditor;
  22670. /**
  22671. * Launch the node material editor
  22672. * @param config Define the configuration of the editor
  22673. * @return a promise fulfilled when the node editor is visible
  22674. */
  22675. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22676. /**
  22677. * Clear the current material
  22678. */
  22679. clear(): void;
  22680. /**
  22681. * Clear the current material and set it to a default state
  22682. */
  22683. setToDefault(): void;
  22684. /**
  22685. * Clear the current material and set it to a default state for post process
  22686. */
  22687. setToDefaultPostProcess(): void;
  22688. /**
  22689. * Clear the current material and set it to a default state for procedural texture
  22690. */
  22691. setToDefaultProceduralTexture(): void;
  22692. /**
  22693. * Clear the current material and set it to a default state for particle
  22694. */
  22695. setToDefaultParticle(): void;
  22696. /**
  22697. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22698. * @param url defines the url to load from
  22699. * @returns a promise that will fullfil when the material is fully loaded
  22700. */
  22701. loadAsync(url: string): Promise<void>;
  22702. private _gatherBlocks;
  22703. /**
  22704. * Generate a string containing the code declaration required to create an equivalent of this material
  22705. * @returns a string
  22706. */
  22707. generateCode(): string;
  22708. /**
  22709. * Serializes this material in a JSON representation
  22710. * @returns the serialized material object
  22711. */
  22712. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22713. private _restoreConnections;
  22714. /**
  22715. * Clear the current graph and load a new one from a serialization object
  22716. * @param source defines the JSON representation of the material
  22717. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22718. * @param merge defines whether or not the source must be merged or replace the current content
  22719. */
  22720. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22721. /**
  22722. * Makes a duplicate of the current material.
  22723. * @param name - name to use for the new material.
  22724. */
  22725. clone(name: string): NodeMaterial;
  22726. /**
  22727. * Creates a node material from parsed material data
  22728. * @param source defines the JSON representation of the material
  22729. * @param scene defines the hosting scene
  22730. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22731. * @returns a new node material
  22732. */
  22733. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22734. /**
  22735. * Creates a node material from a snippet saved in a remote file
  22736. * @param name defines the name of the material to create
  22737. * @param url defines the url to load from
  22738. * @param scene defines the hosting scene
  22739. * @returns a promise that will resolve to the new node material
  22740. */
  22741. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22742. /**
  22743. * Creates a node material from a snippet saved by the node material editor
  22744. * @param snippetId defines the snippet to load
  22745. * @param scene defines the hosting scene
  22746. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22747. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22748. * @returns a promise that will resolve to the new node material
  22749. */
  22750. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22751. /**
  22752. * Creates a new node material set to default basic configuration
  22753. * @param name defines the name of the material
  22754. * @param scene defines the hosting scene
  22755. * @returns a new NodeMaterial
  22756. */
  22757. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22758. }
  22759. }
  22760. declare module BABYLON {
  22761. /**
  22762. * Size options for a post process
  22763. */
  22764. export type PostProcessOptions = {
  22765. width: number;
  22766. height: number;
  22767. };
  22768. /**
  22769. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22770. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22771. */
  22772. export class PostProcess {
  22773. /**
  22774. * Gets or sets the unique id of the post process
  22775. */
  22776. uniqueId: number;
  22777. /** Name of the PostProcess. */
  22778. name: string;
  22779. /**
  22780. * Width of the texture to apply the post process on
  22781. */
  22782. width: number;
  22783. /**
  22784. * Height of the texture to apply the post process on
  22785. */
  22786. height: number;
  22787. /**
  22788. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22789. */
  22790. nodeMaterialSource: Nullable<NodeMaterial>;
  22791. /**
  22792. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22793. * @hidden
  22794. */
  22795. _outputTexture: Nullable<InternalTexture>;
  22796. /**
  22797. * Sampling mode used by the shader
  22798. * See https://doc.babylonjs.com/classes/3.1/texture
  22799. */
  22800. renderTargetSamplingMode: number;
  22801. /**
  22802. * Clear color to use when screen clearing
  22803. */
  22804. clearColor: Color4;
  22805. /**
  22806. * If the buffer needs to be cleared before applying the post process. (default: true)
  22807. * Should be set to false if shader will overwrite all previous pixels.
  22808. */
  22809. autoClear: boolean;
  22810. /**
  22811. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22812. */
  22813. alphaMode: number;
  22814. /**
  22815. * Sets the setAlphaBlendConstants of the babylon engine
  22816. */
  22817. alphaConstants: Color4;
  22818. /**
  22819. * Animations to be used for the post processing
  22820. */
  22821. animations: Animation[];
  22822. /**
  22823. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22824. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22825. */
  22826. enablePixelPerfectMode: boolean;
  22827. /**
  22828. * Force the postprocess to be applied without taking in account viewport
  22829. */
  22830. forceFullscreenViewport: boolean;
  22831. /**
  22832. * List of inspectable custom properties (used by the Inspector)
  22833. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22834. */
  22835. inspectableCustomProperties: IInspectable[];
  22836. /**
  22837. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22838. *
  22839. * | Value | Type | Description |
  22840. * | ----- | ----------------------------------- | ----------- |
  22841. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22842. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22843. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22844. *
  22845. */
  22846. scaleMode: number;
  22847. /**
  22848. * Force textures to be a power of two (default: false)
  22849. */
  22850. alwaysForcePOT: boolean;
  22851. private _samples;
  22852. /**
  22853. * Number of sample textures (default: 1)
  22854. */
  22855. get samples(): number;
  22856. set samples(n: number);
  22857. /**
  22858. * Modify the scale of the post process to be the same as the viewport (default: false)
  22859. */
  22860. adaptScaleToCurrentViewport: boolean;
  22861. private _camera;
  22862. protected _scene: Scene;
  22863. private _engine;
  22864. private _options;
  22865. private _reusable;
  22866. private _textureType;
  22867. private _textureFormat;
  22868. /**
  22869. * Smart array of input and output textures for the post process.
  22870. * @hidden
  22871. */
  22872. _textures: SmartArray<InternalTexture>;
  22873. /**
  22874. * The index in _textures that corresponds to the output texture.
  22875. * @hidden
  22876. */
  22877. _currentRenderTextureInd: number;
  22878. private _effect;
  22879. private _samplers;
  22880. private _fragmentUrl;
  22881. private _vertexUrl;
  22882. private _parameters;
  22883. private _scaleRatio;
  22884. protected _indexParameters: any;
  22885. private _shareOutputWithPostProcess;
  22886. private _texelSize;
  22887. private _forcedOutputTexture;
  22888. /**
  22889. * Returns the fragment url or shader name used in the post process.
  22890. * @returns the fragment url or name in the shader store.
  22891. */
  22892. getEffectName(): string;
  22893. /**
  22894. * An event triggered when the postprocess is activated.
  22895. */
  22896. onActivateObservable: Observable<Camera>;
  22897. private _onActivateObserver;
  22898. /**
  22899. * A function that is added to the onActivateObservable
  22900. */
  22901. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22902. /**
  22903. * An event triggered when the postprocess changes its size.
  22904. */
  22905. onSizeChangedObservable: Observable<PostProcess>;
  22906. private _onSizeChangedObserver;
  22907. /**
  22908. * A function that is added to the onSizeChangedObservable
  22909. */
  22910. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22911. /**
  22912. * An event triggered when the postprocess applies its effect.
  22913. */
  22914. onApplyObservable: Observable<Effect>;
  22915. private _onApplyObserver;
  22916. /**
  22917. * A function that is added to the onApplyObservable
  22918. */
  22919. set onApply(callback: (effect: Effect) => void);
  22920. /**
  22921. * An event triggered before rendering the postprocess
  22922. */
  22923. onBeforeRenderObservable: Observable<Effect>;
  22924. private _onBeforeRenderObserver;
  22925. /**
  22926. * A function that is added to the onBeforeRenderObservable
  22927. */
  22928. set onBeforeRender(callback: (effect: Effect) => void);
  22929. /**
  22930. * An event triggered after rendering the postprocess
  22931. */
  22932. onAfterRenderObservable: Observable<Effect>;
  22933. private _onAfterRenderObserver;
  22934. /**
  22935. * A function that is added to the onAfterRenderObservable
  22936. */
  22937. set onAfterRender(callback: (efect: Effect) => void);
  22938. /**
  22939. * 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
  22940. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22941. */
  22942. get inputTexture(): InternalTexture;
  22943. set inputTexture(value: InternalTexture);
  22944. /**
  22945. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22946. * the only way to unset it is to use this function to restore its internal state
  22947. */
  22948. restoreDefaultInputTexture(): void;
  22949. /**
  22950. * Gets the camera which post process is applied to.
  22951. * @returns The camera the post process is applied to.
  22952. */
  22953. getCamera(): Camera;
  22954. /**
  22955. * Gets the texel size of the postprocess.
  22956. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22957. */
  22958. get texelSize(): Vector2;
  22959. /**
  22960. * Creates a new instance PostProcess
  22961. * @param name The name of the PostProcess.
  22962. * @param fragmentUrl The url of the fragment shader to be used.
  22963. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22964. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22965. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22966. * @param camera The camera to apply the render pass to.
  22967. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22968. * @param engine The engine which the post process will be applied. (default: current engine)
  22969. * @param reusable If the post process can be reused on the same frame. (default: false)
  22970. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22971. * @param textureType Type of textures used when performing the post process. (default: 0)
  22972. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22973. * @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
  22974. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  22975. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22976. */
  22977. 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);
  22978. /**
  22979. * Gets a string identifying the name of the class
  22980. * @returns "PostProcess" string
  22981. */
  22982. getClassName(): string;
  22983. /**
  22984. * Gets the engine which this post process belongs to.
  22985. * @returns The engine the post process was enabled with.
  22986. */
  22987. getEngine(): Engine;
  22988. /**
  22989. * The effect that is created when initializing the post process.
  22990. * @returns The created effect corresponding the the postprocess.
  22991. */
  22992. getEffect(): Effect;
  22993. /**
  22994. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22995. * @param postProcess The post process to share the output with.
  22996. * @returns This post process.
  22997. */
  22998. shareOutputWith(postProcess: PostProcess): PostProcess;
  22999. /**
  23000. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23001. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23002. */
  23003. useOwnOutput(): void;
  23004. /**
  23005. * Updates the effect with the current post process compile time values and recompiles the shader.
  23006. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23007. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23008. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23009. * @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
  23010. * @param onCompiled Called when the shader has been compiled.
  23011. * @param onError Called if there is an error when compiling a shader.
  23012. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23013. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23014. */
  23015. 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;
  23016. /**
  23017. * The post process is reusable if it can be used multiple times within one frame.
  23018. * @returns If the post process is reusable
  23019. */
  23020. isReusable(): boolean;
  23021. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23022. markTextureDirty(): void;
  23023. /**
  23024. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23025. * 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.
  23026. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23027. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23028. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23029. * @returns The target texture that was bound to be written to.
  23030. */
  23031. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23032. /**
  23033. * If the post process is supported.
  23034. */
  23035. get isSupported(): boolean;
  23036. /**
  23037. * The aspect ratio of the output texture.
  23038. */
  23039. get aspectRatio(): number;
  23040. /**
  23041. * Get a value indicating if the post-process is ready to be used
  23042. * @returns true if the post-process is ready (shader is compiled)
  23043. */
  23044. isReady(): boolean;
  23045. /**
  23046. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23047. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23048. */
  23049. apply(): Nullable<Effect>;
  23050. private _disposeTextures;
  23051. /**
  23052. * Disposes the post process.
  23053. * @param camera The camera to dispose the post process on.
  23054. */
  23055. dispose(camera?: Camera): void;
  23056. /**
  23057. * Serializes the particle system to a JSON object
  23058. * @returns the JSON object
  23059. */
  23060. serialize(): any;
  23061. /**
  23062. * Creates a material from parsed material data
  23063. * @param parsedPostProcess defines parsed post process data
  23064. * @param scene defines the hosting scene
  23065. * @param rootUrl defines the root URL to use to load textures
  23066. * @returns a new post process
  23067. */
  23068. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23069. }
  23070. }
  23071. declare module BABYLON {
  23072. /** @hidden */
  23073. export var kernelBlurVaryingDeclaration: {
  23074. name: string;
  23075. shader: string;
  23076. };
  23077. }
  23078. declare module BABYLON {
  23079. /** @hidden */
  23080. export var kernelBlurFragment: {
  23081. name: string;
  23082. shader: string;
  23083. };
  23084. }
  23085. declare module BABYLON {
  23086. /** @hidden */
  23087. export var kernelBlurFragment2: {
  23088. name: string;
  23089. shader: string;
  23090. };
  23091. }
  23092. declare module BABYLON {
  23093. /** @hidden */
  23094. export var kernelBlurPixelShader: {
  23095. name: string;
  23096. shader: string;
  23097. };
  23098. }
  23099. declare module BABYLON {
  23100. /** @hidden */
  23101. export var kernelBlurVertex: {
  23102. name: string;
  23103. shader: string;
  23104. };
  23105. }
  23106. declare module BABYLON {
  23107. /** @hidden */
  23108. export var kernelBlurVertexShader: {
  23109. name: string;
  23110. shader: string;
  23111. };
  23112. }
  23113. declare module BABYLON {
  23114. /**
  23115. * The Blur Post Process which blurs an image based on a kernel and direction.
  23116. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23117. */
  23118. export class BlurPostProcess extends PostProcess {
  23119. private blockCompilation;
  23120. protected _kernel: number;
  23121. protected _idealKernel: number;
  23122. protected _packedFloat: boolean;
  23123. private _staticDefines;
  23124. /** The direction in which to blur the image. */
  23125. direction: Vector2;
  23126. /**
  23127. * Sets the length in pixels of the blur sample region
  23128. */
  23129. set kernel(v: number);
  23130. /**
  23131. * Gets the length in pixels of the blur sample region
  23132. */
  23133. get kernel(): number;
  23134. /**
  23135. * Sets wether or not the blur needs to unpack/repack floats
  23136. */
  23137. set packedFloat(v: boolean);
  23138. /**
  23139. * Gets wether or not the blur is unpacking/repacking floats
  23140. */
  23141. get packedFloat(): boolean;
  23142. /**
  23143. * Gets a string identifying the name of the class
  23144. * @returns "BlurPostProcess" string
  23145. */
  23146. getClassName(): string;
  23147. /**
  23148. * Creates a new instance BlurPostProcess
  23149. * @param name The name of the effect.
  23150. * @param direction The direction in which to blur the image.
  23151. * @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.
  23152. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23153. * @param camera The camera to apply the render pass to.
  23154. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23155. * @param engine The engine which the post process will be applied. (default: current engine)
  23156. * @param reusable If the post process can be reused on the same frame. (default: false)
  23157. * @param textureType Type of textures used when performing the post process. (default: 0)
  23158. * @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)
  23159. */
  23160. 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);
  23161. /**
  23162. * Updates the effect with the current post process compile time values and recompiles the shader.
  23163. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23164. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23165. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23166. * @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
  23167. * @param onCompiled Called when the shader has been compiled.
  23168. * @param onError Called if there is an error when compiling a shader.
  23169. */
  23170. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23171. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23172. /**
  23173. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23174. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23175. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23176. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23177. * The gaps between physical kernels are compensated for in the weighting of the samples
  23178. * @param idealKernel Ideal blur kernel.
  23179. * @return Nearest best kernel.
  23180. */
  23181. protected _nearestBestKernel(idealKernel: number): number;
  23182. /**
  23183. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23184. * @param x The point on the Gaussian distribution to sample.
  23185. * @return the value of the Gaussian function at x.
  23186. */
  23187. protected _gaussianWeight(x: number): number;
  23188. /**
  23189. * Generates a string that can be used as a floating point number in GLSL.
  23190. * @param x Value to print.
  23191. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23192. * @return GLSL float string.
  23193. */
  23194. protected _glslFloat(x: number, decimalFigures?: number): string;
  23195. /** @hidden */
  23196. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23197. }
  23198. }
  23199. declare module BABYLON {
  23200. /**
  23201. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23202. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23203. * You can then easily use it as a reflectionTexture on a flat surface.
  23204. * In case the surface is not a plane, please consider relying on reflection probes.
  23205. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23206. */
  23207. export class MirrorTexture extends RenderTargetTexture {
  23208. private scene;
  23209. /**
  23210. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23211. * 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.
  23212. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23213. */
  23214. mirrorPlane: Plane;
  23215. /**
  23216. * Define the blur ratio used to blur the reflection if needed.
  23217. */
  23218. set blurRatio(value: number);
  23219. get blurRatio(): number;
  23220. /**
  23221. * Define the adaptive blur kernel used to blur the reflection if needed.
  23222. * This will autocompute the closest best match for the `blurKernel`
  23223. */
  23224. set adaptiveBlurKernel(value: number);
  23225. /**
  23226. * Define the blur kernel used to blur the reflection if needed.
  23227. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23228. */
  23229. set blurKernel(value: number);
  23230. /**
  23231. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23232. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23233. */
  23234. set blurKernelX(value: number);
  23235. get blurKernelX(): number;
  23236. /**
  23237. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23238. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23239. */
  23240. set blurKernelY(value: number);
  23241. get blurKernelY(): number;
  23242. private _autoComputeBlurKernel;
  23243. protected _onRatioRescale(): void;
  23244. private _updateGammaSpace;
  23245. private _imageProcessingConfigChangeObserver;
  23246. private _transformMatrix;
  23247. private _mirrorMatrix;
  23248. private _savedViewMatrix;
  23249. private _blurX;
  23250. private _blurY;
  23251. private _adaptiveBlurKernel;
  23252. private _blurKernelX;
  23253. private _blurKernelY;
  23254. private _blurRatio;
  23255. /**
  23256. * Instantiates a Mirror Texture.
  23257. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23258. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23259. * You can then easily use it as a reflectionTexture on a flat surface.
  23260. * In case the surface is not a plane, please consider relying on reflection probes.
  23261. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23262. * @param name
  23263. * @param size
  23264. * @param scene
  23265. * @param generateMipMaps
  23266. * @param type
  23267. * @param samplingMode
  23268. * @param generateDepthBuffer
  23269. */
  23270. constructor(name: string, size: number | {
  23271. width: number;
  23272. height: number;
  23273. } | {
  23274. ratio: number;
  23275. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23276. private _preparePostProcesses;
  23277. /**
  23278. * Clone the mirror texture.
  23279. * @returns the cloned texture
  23280. */
  23281. clone(): MirrorTexture;
  23282. /**
  23283. * Serialize the texture to a JSON representation you could use in Parse later on
  23284. * @returns the serialized JSON representation
  23285. */
  23286. serialize(): any;
  23287. /**
  23288. * Dispose the texture and release its associated resources.
  23289. */
  23290. dispose(): void;
  23291. }
  23292. }
  23293. declare module BABYLON {
  23294. /**
  23295. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23296. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23297. */
  23298. export class Texture extends BaseTexture {
  23299. /**
  23300. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23301. */
  23302. static SerializeBuffers: boolean;
  23303. /** @hidden */
  23304. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23305. /** @hidden */
  23306. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23307. /** @hidden */
  23308. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23309. /** nearest is mag = nearest and min = nearest and mip = linear */
  23310. static readonly NEAREST_SAMPLINGMODE: number;
  23311. /** nearest is mag = nearest and min = nearest and mip = linear */
  23312. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23313. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23314. static readonly BILINEAR_SAMPLINGMODE: number;
  23315. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23316. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23317. /** Trilinear is mag = linear and min = linear and mip = linear */
  23318. static readonly TRILINEAR_SAMPLINGMODE: number;
  23319. /** Trilinear is mag = linear and min = linear and mip = linear */
  23320. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23321. /** mag = nearest and min = nearest and mip = nearest */
  23322. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23323. /** mag = nearest and min = linear and mip = nearest */
  23324. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23325. /** mag = nearest and min = linear and mip = linear */
  23326. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23327. /** mag = nearest and min = linear and mip = none */
  23328. static readonly NEAREST_LINEAR: number;
  23329. /** mag = nearest and min = nearest and mip = none */
  23330. static readonly NEAREST_NEAREST: number;
  23331. /** mag = linear and min = nearest and mip = nearest */
  23332. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23333. /** mag = linear and min = nearest and mip = linear */
  23334. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23335. /** mag = linear and min = linear and mip = none */
  23336. static readonly LINEAR_LINEAR: number;
  23337. /** mag = linear and min = nearest and mip = none */
  23338. static readonly LINEAR_NEAREST: number;
  23339. /** Explicit coordinates mode */
  23340. static readonly EXPLICIT_MODE: number;
  23341. /** Spherical coordinates mode */
  23342. static readonly SPHERICAL_MODE: number;
  23343. /** Planar coordinates mode */
  23344. static readonly PLANAR_MODE: number;
  23345. /** Cubic coordinates mode */
  23346. static readonly CUBIC_MODE: number;
  23347. /** Projection coordinates mode */
  23348. static readonly PROJECTION_MODE: number;
  23349. /** Inverse Cubic coordinates mode */
  23350. static readonly SKYBOX_MODE: number;
  23351. /** Inverse Cubic coordinates mode */
  23352. static readonly INVCUBIC_MODE: number;
  23353. /** Equirectangular coordinates mode */
  23354. static readonly EQUIRECTANGULAR_MODE: number;
  23355. /** Equirectangular Fixed coordinates mode */
  23356. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23357. /** Equirectangular Fixed Mirrored coordinates mode */
  23358. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23359. /** Texture is not repeating outside of 0..1 UVs */
  23360. static readonly CLAMP_ADDRESSMODE: number;
  23361. /** Texture is repeating outside of 0..1 UVs */
  23362. static readonly WRAP_ADDRESSMODE: number;
  23363. /** Texture is repeating and mirrored */
  23364. static readonly MIRROR_ADDRESSMODE: number;
  23365. /**
  23366. * 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
  23367. */
  23368. static UseSerializedUrlIfAny: boolean;
  23369. /**
  23370. * Define the url of the texture.
  23371. */
  23372. url: Nullable<string>;
  23373. /**
  23374. * Define an offset on the texture to offset the u coordinates of the UVs
  23375. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23376. */
  23377. uOffset: number;
  23378. /**
  23379. * Define an offset on the texture to offset the v coordinates of the UVs
  23380. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23381. */
  23382. vOffset: number;
  23383. /**
  23384. * Define an offset on the texture to scale the u coordinates of the UVs
  23385. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23386. */
  23387. uScale: number;
  23388. /**
  23389. * Define an offset on the texture to scale the v coordinates of the UVs
  23390. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23391. */
  23392. vScale: number;
  23393. /**
  23394. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23395. * @see https://doc.babylonjs.com/how_to/more_materials
  23396. */
  23397. uAng: number;
  23398. /**
  23399. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23400. * @see https://doc.babylonjs.com/how_to/more_materials
  23401. */
  23402. vAng: number;
  23403. /**
  23404. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23405. * @see https://doc.babylonjs.com/how_to/more_materials
  23406. */
  23407. wAng: number;
  23408. /**
  23409. * Defines the center of rotation (U)
  23410. */
  23411. uRotationCenter: number;
  23412. /**
  23413. * Defines the center of rotation (V)
  23414. */
  23415. vRotationCenter: number;
  23416. /**
  23417. * Defines the center of rotation (W)
  23418. */
  23419. wRotationCenter: number;
  23420. /**
  23421. * Are mip maps generated for this texture or not.
  23422. */
  23423. get noMipmap(): boolean;
  23424. /**
  23425. * List of inspectable custom properties (used by the Inspector)
  23426. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23427. */
  23428. inspectableCustomProperties: Nullable<IInspectable[]>;
  23429. private _noMipmap;
  23430. /** @hidden */
  23431. _invertY: boolean;
  23432. private _rowGenerationMatrix;
  23433. private _cachedTextureMatrix;
  23434. private _projectionModeMatrix;
  23435. private _t0;
  23436. private _t1;
  23437. private _t2;
  23438. private _cachedUOffset;
  23439. private _cachedVOffset;
  23440. private _cachedUScale;
  23441. private _cachedVScale;
  23442. private _cachedUAng;
  23443. private _cachedVAng;
  23444. private _cachedWAng;
  23445. private _cachedProjectionMatrixId;
  23446. private _cachedCoordinatesMode;
  23447. /** @hidden */
  23448. protected _initialSamplingMode: number;
  23449. /** @hidden */
  23450. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23451. private _deleteBuffer;
  23452. protected _format: Nullable<number>;
  23453. private _delayedOnLoad;
  23454. private _delayedOnError;
  23455. private _mimeType?;
  23456. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23457. get mimeType(): string | undefined;
  23458. /**
  23459. * Observable triggered once the texture has been loaded.
  23460. */
  23461. onLoadObservable: Observable<Texture>;
  23462. protected _isBlocking: boolean;
  23463. /**
  23464. * Is the texture preventing material to render while loading.
  23465. * If false, a default texture will be used instead of the loading one during the preparation step.
  23466. */
  23467. set isBlocking(value: boolean);
  23468. get isBlocking(): boolean;
  23469. /**
  23470. * Get the current sampling mode associated with the texture.
  23471. */
  23472. get samplingMode(): number;
  23473. /**
  23474. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23475. */
  23476. get invertY(): boolean;
  23477. /**
  23478. * Instantiates a new texture.
  23479. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23480. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23481. * @param url defines the url of the picture to load as a texture
  23482. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23483. * @param noMipmap defines if the texture will require mip maps or not
  23484. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23485. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23486. * @param onLoad defines a callback triggered when the texture has been loaded
  23487. * @param onError defines a callback triggered when an error occurred during the loading session
  23488. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23489. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23490. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23491. * @param mimeType defines an optional mime type information
  23492. */
  23493. 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);
  23494. /**
  23495. * Update the url (and optional buffer) of this texture if url was null during construction.
  23496. * @param url the url of the texture
  23497. * @param buffer the buffer of the texture (defaults to null)
  23498. * @param onLoad callback called when the texture is loaded (defaults to null)
  23499. */
  23500. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23501. /**
  23502. * Finish the loading sequence of a texture flagged as delayed load.
  23503. * @hidden
  23504. */
  23505. delayLoad(): void;
  23506. private _prepareRowForTextureGeneration;
  23507. /**
  23508. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23509. * @returns the transform matrix of the texture.
  23510. */
  23511. getTextureMatrix(uBase?: number): Matrix;
  23512. /**
  23513. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23514. * @returns The reflection texture transform
  23515. */
  23516. getReflectionTextureMatrix(): Matrix;
  23517. /**
  23518. * Clones the texture.
  23519. * @returns the cloned texture
  23520. */
  23521. clone(): Texture;
  23522. /**
  23523. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23524. * @returns The JSON representation of the texture
  23525. */
  23526. serialize(): any;
  23527. /**
  23528. * Get the current class name of the texture useful for serialization or dynamic coding.
  23529. * @returns "Texture"
  23530. */
  23531. getClassName(): string;
  23532. /**
  23533. * Dispose the texture and release its associated resources.
  23534. */
  23535. dispose(): void;
  23536. /**
  23537. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23538. * @param parsedTexture Define the JSON representation of the texture
  23539. * @param scene Define the scene the parsed texture should be instantiated in
  23540. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23541. * @returns The parsed texture if successful
  23542. */
  23543. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23544. /**
  23545. * Creates a texture from its base 64 representation.
  23546. * @param data Define the base64 payload without the data: prefix
  23547. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23548. * @param scene Define the scene the texture should belong to
  23549. * @param noMipmap Forces the texture to not create mip map information if true
  23550. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23551. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23552. * @param onLoad define a callback triggered when the texture has been loaded
  23553. * @param onError define a callback triggered when an error occurred during the loading session
  23554. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23555. * @returns the created texture
  23556. */
  23557. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23558. /**
  23559. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23560. * @param data Define the base64 payload without the data: prefix
  23561. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23562. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23563. * @param scene Define the scene the texture should belong to
  23564. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23565. * @param noMipmap Forces the texture to not create mip map information if true
  23566. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23567. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23568. * @param onLoad define a callback triggered when the texture has been loaded
  23569. * @param onError define a callback triggered when an error occurred during the loading session
  23570. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23571. * @returns the created texture
  23572. */
  23573. 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;
  23574. }
  23575. }
  23576. declare module BABYLON {
  23577. /**
  23578. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23579. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23580. */
  23581. export class PostProcessManager {
  23582. private _scene;
  23583. private _indexBuffer;
  23584. private _vertexBuffers;
  23585. /**
  23586. * Creates a new instance PostProcess
  23587. * @param scene The scene that the post process is associated with.
  23588. */
  23589. constructor(scene: Scene);
  23590. private _prepareBuffers;
  23591. private _buildIndexBuffer;
  23592. /**
  23593. * Rebuilds the vertex buffers of the manager.
  23594. * @hidden
  23595. */
  23596. _rebuild(): void;
  23597. /**
  23598. * Prepares a frame to be run through a post process.
  23599. * @param sourceTexture The input texture to the post procesess. (default: null)
  23600. * @param postProcesses An array of post processes to be run. (default: null)
  23601. * @returns True if the post processes were able to be run.
  23602. * @hidden
  23603. */
  23604. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23605. /**
  23606. * Manually render a set of post processes to a texture.
  23607. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23608. * @param postProcesses An array of post processes to be run.
  23609. * @param targetTexture The target texture to render to.
  23610. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23611. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23612. * @param lodLevel defines which lod of the texture to render to
  23613. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23614. */
  23615. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23616. /**
  23617. * Finalize the result of the output of the postprocesses.
  23618. * @param doNotPresent If true the result will not be displayed to the screen.
  23619. * @param targetTexture The target texture to render to.
  23620. * @param faceIndex The index of the face to bind the target texture to.
  23621. * @param postProcesses The array of post processes to render.
  23622. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23623. * @hidden
  23624. */
  23625. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23626. /**
  23627. * Disposes of the post process manager.
  23628. */
  23629. dispose(): void;
  23630. }
  23631. }
  23632. declare module BABYLON {
  23633. /**
  23634. * This Helps creating a texture that will be created from a camera in your scene.
  23635. * It is basically a dynamic texture that could be used to create special effects for instance.
  23636. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23637. */
  23638. export class RenderTargetTexture extends Texture {
  23639. /**
  23640. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23641. */
  23642. static readonly REFRESHRATE_RENDER_ONCE: number;
  23643. /**
  23644. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23645. */
  23646. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23647. /**
  23648. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23649. * the central point of your effect and can save a lot of performances.
  23650. */
  23651. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23652. /**
  23653. * Use this predicate to dynamically define the list of mesh you want to render.
  23654. * If set, the renderList property will be overwritten.
  23655. */
  23656. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23657. private _renderList;
  23658. /**
  23659. * Use this list to define the list of mesh you want to render.
  23660. */
  23661. get renderList(): Nullable<Array<AbstractMesh>>;
  23662. set renderList(value: Nullable<Array<AbstractMesh>>);
  23663. /**
  23664. * Use this function to overload the renderList array at rendering time.
  23665. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23666. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23667. * the cube (if the RTT is a cube, else layerOrFace=0).
  23668. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23669. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23670. * hold dummy elements!
  23671. */
  23672. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23673. private _hookArray;
  23674. /**
  23675. * Define if particles should be rendered in your texture.
  23676. */
  23677. renderParticles: boolean;
  23678. /**
  23679. * Define if sprites should be rendered in your texture.
  23680. */
  23681. renderSprites: boolean;
  23682. /**
  23683. * Define the camera used to render the texture.
  23684. */
  23685. activeCamera: Nullable<Camera>;
  23686. /**
  23687. * Override the mesh isReady function with your own one.
  23688. */
  23689. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23690. /**
  23691. * Override the render function of the texture with your own one.
  23692. */
  23693. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23694. /**
  23695. * Define if camera post processes should be use while rendering the texture.
  23696. */
  23697. useCameraPostProcesses: boolean;
  23698. /**
  23699. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23700. */
  23701. ignoreCameraViewport: boolean;
  23702. private _postProcessManager;
  23703. private _postProcesses;
  23704. private _resizeObserver;
  23705. /**
  23706. * An event triggered when the texture is unbind.
  23707. */
  23708. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23709. /**
  23710. * An event triggered when the texture is unbind.
  23711. */
  23712. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23713. private _onAfterUnbindObserver;
  23714. /**
  23715. * Set a after unbind callback in the texture.
  23716. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23717. */
  23718. set onAfterUnbind(callback: () => void);
  23719. /**
  23720. * An event triggered before rendering the texture
  23721. */
  23722. onBeforeRenderObservable: Observable<number>;
  23723. private _onBeforeRenderObserver;
  23724. /**
  23725. * Set a before render callback in the texture.
  23726. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23727. */
  23728. set onBeforeRender(callback: (faceIndex: number) => void);
  23729. /**
  23730. * An event triggered after rendering the texture
  23731. */
  23732. onAfterRenderObservable: Observable<number>;
  23733. private _onAfterRenderObserver;
  23734. /**
  23735. * Set a after render callback in the texture.
  23736. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23737. */
  23738. set onAfterRender(callback: (faceIndex: number) => void);
  23739. /**
  23740. * An event triggered after the texture clear
  23741. */
  23742. onClearObservable: Observable<Engine>;
  23743. private _onClearObserver;
  23744. /**
  23745. * Set a clear callback in the texture.
  23746. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23747. */
  23748. set onClear(callback: (Engine: Engine) => void);
  23749. /**
  23750. * An event triggered when the texture is resized.
  23751. */
  23752. onResizeObservable: Observable<RenderTargetTexture>;
  23753. /**
  23754. * Define the clear color of the Render Target if it should be different from the scene.
  23755. */
  23756. clearColor: Color4;
  23757. protected _size: number | {
  23758. width: number;
  23759. height: number;
  23760. layers?: number;
  23761. };
  23762. protected _initialSizeParameter: number | {
  23763. width: number;
  23764. height: number;
  23765. } | {
  23766. ratio: number;
  23767. };
  23768. protected _sizeRatio: Nullable<number>;
  23769. /** @hidden */
  23770. _generateMipMaps: boolean;
  23771. protected _renderingManager: RenderingManager;
  23772. /** @hidden */
  23773. _waitingRenderList?: string[];
  23774. protected _doNotChangeAspectRatio: boolean;
  23775. protected _currentRefreshId: number;
  23776. protected _refreshRate: number;
  23777. protected _textureMatrix: Matrix;
  23778. protected _samples: number;
  23779. protected _renderTargetOptions: RenderTargetCreationOptions;
  23780. /**
  23781. * Gets render target creation options that were used.
  23782. */
  23783. get renderTargetOptions(): RenderTargetCreationOptions;
  23784. protected _onRatioRescale(): void;
  23785. /**
  23786. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23787. * It must define where the camera used to render the texture is set
  23788. */
  23789. boundingBoxPosition: Vector3;
  23790. private _boundingBoxSize;
  23791. /**
  23792. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23793. * When defined, the cubemap will switch to local mode
  23794. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23795. * @example https://www.babylonjs-playground.com/#RNASML
  23796. */
  23797. set boundingBoxSize(value: Vector3);
  23798. get boundingBoxSize(): Vector3;
  23799. /**
  23800. * In case the RTT has been created with a depth texture, get the associated
  23801. * depth texture.
  23802. * Otherwise, return null.
  23803. */
  23804. get depthStencilTexture(): Nullable<InternalTexture>;
  23805. /**
  23806. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23807. * or used a shadow, depth texture...
  23808. * @param name The friendly name of the texture
  23809. * @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)
  23810. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23811. * @param generateMipMaps True if mip maps need to be generated after render.
  23812. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23813. * @param type The type of the buffer in the RTT (int, half float, float...)
  23814. * @param isCube True if a cube texture needs to be created
  23815. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23816. * @param generateDepthBuffer True to generate a depth buffer
  23817. * @param generateStencilBuffer True to generate a stencil buffer
  23818. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23819. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23820. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23821. */
  23822. constructor(name: string, size: number | {
  23823. width: number;
  23824. height: number;
  23825. layers?: number;
  23826. } | {
  23827. ratio: number;
  23828. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23829. /**
  23830. * Creates a depth stencil texture.
  23831. * This is only available in WebGL 2 or with the depth texture extension available.
  23832. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23833. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23834. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23835. */
  23836. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23837. private _processSizeParameter;
  23838. /**
  23839. * Define the number of samples to use in case of MSAA.
  23840. * It defaults to one meaning no MSAA has been enabled.
  23841. */
  23842. get samples(): number;
  23843. set samples(value: number);
  23844. /**
  23845. * Resets the refresh counter of the texture and start bak from scratch.
  23846. * Could be useful to regenerate the texture if it is setup to render only once.
  23847. */
  23848. resetRefreshCounter(): void;
  23849. /**
  23850. * Define the refresh rate of the texture or the rendering frequency.
  23851. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23852. */
  23853. get refreshRate(): number;
  23854. set refreshRate(value: number);
  23855. /**
  23856. * Adds a post process to the render target rendering passes.
  23857. * @param postProcess define the post process to add
  23858. */
  23859. addPostProcess(postProcess: PostProcess): void;
  23860. /**
  23861. * Clear all the post processes attached to the render target
  23862. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23863. */
  23864. clearPostProcesses(dispose?: boolean): void;
  23865. /**
  23866. * Remove one of the post process from the list of attached post processes to the texture
  23867. * @param postProcess define the post process to remove from the list
  23868. */
  23869. removePostProcess(postProcess: PostProcess): void;
  23870. /** @hidden */
  23871. _shouldRender(): boolean;
  23872. /**
  23873. * Gets the actual render size of the texture.
  23874. * @returns the width of the render size
  23875. */
  23876. getRenderSize(): number;
  23877. /**
  23878. * Gets the actual render width of the texture.
  23879. * @returns the width of the render size
  23880. */
  23881. getRenderWidth(): number;
  23882. /**
  23883. * Gets the actual render height of the texture.
  23884. * @returns the height of the render size
  23885. */
  23886. getRenderHeight(): number;
  23887. /**
  23888. * Gets the actual number of layers of the texture.
  23889. * @returns the number of layers
  23890. */
  23891. getRenderLayers(): number;
  23892. /**
  23893. * Get if the texture can be rescaled or not.
  23894. */
  23895. get canRescale(): boolean;
  23896. /**
  23897. * Resize the texture using a ratio.
  23898. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23899. */
  23900. scale(ratio: number): void;
  23901. /**
  23902. * Get the texture reflection matrix used to rotate/transform the reflection.
  23903. * @returns the reflection matrix
  23904. */
  23905. getReflectionTextureMatrix(): Matrix;
  23906. /**
  23907. * Resize the texture to a new desired size.
  23908. * Be carrefull as it will recreate all the data in the new texture.
  23909. * @param size Define the new size. It can be:
  23910. * - a number for squared texture,
  23911. * - an object containing { width: number, height: number }
  23912. * - or an object containing a ratio { ratio: number }
  23913. */
  23914. resize(size: number | {
  23915. width: number;
  23916. height: number;
  23917. } | {
  23918. ratio: number;
  23919. }): void;
  23920. private _defaultRenderListPrepared;
  23921. /**
  23922. * Renders all the objects from the render list into the texture.
  23923. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23924. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23925. */
  23926. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23927. private _bestReflectionRenderTargetDimension;
  23928. private _prepareRenderingManager;
  23929. /**
  23930. * @hidden
  23931. * @param faceIndex face index to bind to if this is a cubetexture
  23932. * @param layer defines the index of the texture to bind in the array
  23933. */
  23934. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23935. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23936. private renderToTarget;
  23937. /**
  23938. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23939. * This allowed control for front to back rendering or reversly depending of the special needs.
  23940. *
  23941. * @param renderingGroupId The rendering group id corresponding to its index
  23942. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23943. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23944. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23945. */
  23946. 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;
  23947. /**
  23948. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23949. *
  23950. * @param renderingGroupId The rendering group id corresponding to its index
  23951. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23952. */
  23953. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23954. /**
  23955. * Clones the texture.
  23956. * @returns the cloned texture
  23957. */
  23958. clone(): RenderTargetTexture;
  23959. /**
  23960. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23961. * @returns The JSON representation of the texture
  23962. */
  23963. serialize(): any;
  23964. /**
  23965. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23966. */
  23967. disposeFramebufferObjects(): void;
  23968. /**
  23969. * Dispose the texture and release its associated resources.
  23970. */
  23971. dispose(): void;
  23972. /** @hidden */
  23973. _rebuild(): void;
  23974. /**
  23975. * Clear the info related to rendering groups preventing retention point in material dispose.
  23976. */
  23977. freeRenderingGroups(): void;
  23978. /**
  23979. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23980. * @returns the view count
  23981. */
  23982. getViewCount(): number;
  23983. }
  23984. }
  23985. declare module BABYLON {
  23986. /**
  23987. * Class used to manipulate GUIDs
  23988. */
  23989. export class GUID {
  23990. /**
  23991. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23992. * Be aware Math.random() could cause collisions, but:
  23993. * "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"
  23994. * @returns a pseudo random id
  23995. */
  23996. static RandomId(): string;
  23997. }
  23998. }
  23999. declare module BABYLON {
  24000. /**
  24001. * Options to be used when creating a shadow depth material
  24002. */
  24003. export interface IIOptionShadowDepthMaterial {
  24004. /** Variables in the vertex shader code that need to have their names remapped.
  24005. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24006. * "var_name" should be either: worldPos or vNormalW
  24007. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24008. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24009. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24010. */
  24011. remappedVariables?: string[];
  24012. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24013. standalone?: boolean;
  24014. }
  24015. /**
  24016. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24017. */
  24018. export class ShadowDepthWrapper {
  24019. private _scene;
  24020. private _options?;
  24021. private _baseMaterial;
  24022. private _onEffectCreatedObserver;
  24023. private _subMeshToEffect;
  24024. private _subMeshToDepthEffect;
  24025. private _meshes;
  24026. /** @hidden */
  24027. _matriceNames: any;
  24028. /** Gets the standalone status of the wrapper */
  24029. get standalone(): boolean;
  24030. /** Gets the base material the wrapper is built upon */
  24031. get baseMaterial(): Material;
  24032. /**
  24033. * Instantiate a new shadow depth wrapper.
  24034. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24035. * generate the shadow depth map. For more information, please refer to the documentation:
  24036. * https://doc.babylonjs.com/babylon101/shadows
  24037. * @param baseMaterial Material to wrap
  24038. * @param scene Define the scene the material belongs to
  24039. * @param options Options used to create the wrapper
  24040. */
  24041. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24042. /**
  24043. * Gets the effect to use to generate the depth map
  24044. * @param subMesh subMesh to get the effect for
  24045. * @param shadowGenerator shadow generator to get the effect for
  24046. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24047. */
  24048. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24049. /**
  24050. * Specifies that the submesh is ready to be used for depth rendering
  24051. * @param subMesh submesh to check
  24052. * @param defines the list of defines to take into account when checking the effect
  24053. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24054. * @param useInstances specifies that instances should be used
  24055. * @returns a boolean indicating that the submesh is ready or not
  24056. */
  24057. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24058. /**
  24059. * Disposes the resources
  24060. */
  24061. dispose(): void;
  24062. private _makeEffect;
  24063. }
  24064. }
  24065. declare module BABYLON {
  24066. interface ThinEngine {
  24067. /**
  24068. * Unbind a list of render target textures from the webGL context
  24069. * This is used only when drawBuffer extension or webGL2 are active
  24070. * @param textures defines the render target textures to unbind
  24071. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  24072. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  24073. */
  24074. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  24075. /**
  24076. * Create a multi render target texture
  24077. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  24078. * @param size defines the size of the texture
  24079. * @param options defines the creation options
  24080. * @returns the cube texture as an InternalTexture
  24081. */
  24082. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  24083. /**
  24084. * Update the sample count for a given multiple render target texture
  24085. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  24086. * @param textures defines the textures to update
  24087. * @param samples defines the sample count to set
  24088. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  24089. */
  24090. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  24091. /**
  24092. * Select a subsets of attachments to draw to.
  24093. * @param attachments gl attachments
  24094. */
  24095. bindAttachments(attachments: number[]): void;
  24096. }
  24097. }
  24098. declare module BABYLON {
  24099. /**
  24100. * Creation options of the multi render target texture.
  24101. */
  24102. export interface IMultiRenderTargetOptions {
  24103. /**
  24104. * Define if the texture needs to create mip maps after render.
  24105. */
  24106. generateMipMaps?: boolean;
  24107. /**
  24108. * Define the types of all the draw buffers we want to create
  24109. */
  24110. types?: number[];
  24111. /**
  24112. * Define the sampling modes of all the draw buffers we want to create
  24113. */
  24114. samplingModes?: number[];
  24115. /**
  24116. * Define if a depth buffer is required
  24117. */
  24118. generateDepthBuffer?: boolean;
  24119. /**
  24120. * Define if a stencil buffer is required
  24121. */
  24122. generateStencilBuffer?: boolean;
  24123. /**
  24124. * Define if a depth texture is required instead of a depth buffer
  24125. */
  24126. generateDepthTexture?: boolean;
  24127. /**
  24128. * Define the number of desired draw buffers
  24129. */
  24130. textureCount?: number;
  24131. /**
  24132. * Define if aspect ratio should be adapted to the texture or stay the scene one
  24133. */
  24134. doNotChangeAspectRatio?: boolean;
  24135. /**
  24136. * Define the default type of the buffers we are creating
  24137. */
  24138. defaultType?: number;
  24139. }
  24140. /**
  24141. * A multi render target, like a render target provides the ability to render to a texture.
  24142. * Unlike the render target, it can render to several draw buffers in one draw.
  24143. * This is specially interesting in deferred rendering or for any effects requiring more than
  24144. * just one color from a single pass.
  24145. */
  24146. export class MultiRenderTarget extends RenderTargetTexture {
  24147. private _internalTextures;
  24148. private _textures;
  24149. private _multiRenderTargetOptions;
  24150. private _count;
  24151. /**
  24152. * Get if draw buffers are currently supported by the used hardware and browser.
  24153. */
  24154. get isSupported(): boolean;
  24155. /**
  24156. * Get the list of textures generated by the multi render target.
  24157. */
  24158. get textures(): Texture[];
  24159. /**
  24160. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  24161. */
  24162. get count(): number;
  24163. /**
  24164. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24165. */
  24166. get depthTexture(): Texture;
  24167. /**
  24168. * Set the wrapping mode on U of all the textures we are rendering to.
  24169. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24170. */
  24171. set wrapU(wrap: number);
  24172. /**
  24173. * Set the wrapping mode on V of all the textures we are rendering to.
  24174. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24175. */
  24176. set wrapV(wrap: number);
  24177. /**
  24178. * Instantiate a new multi render target texture.
  24179. * A multi render target, like a render target provides the ability to render to a texture.
  24180. * Unlike the render target, it can render to several draw buffers in one draw.
  24181. * This is specially interesting in deferred rendering or for any effects requiring more than
  24182. * just one color from a single pass.
  24183. * @param name Define the name of the texture
  24184. * @param size Define the size of the buffers to render to
  24185. * @param count Define the number of target we are rendering into
  24186. * @param scene Define the scene the texture belongs to
  24187. * @param options Define the options used to create the multi render target
  24188. */
  24189. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24190. private _initTypes;
  24191. /** @hidden */
  24192. _rebuild(forceFullRebuild?: boolean): void;
  24193. private _createInternalTextures;
  24194. private _createTextures;
  24195. /**
  24196. * Define the number of samples used if MSAA is enabled.
  24197. */
  24198. get samples(): number;
  24199. set samples(value: number);
  24200. /**
  24201. * Resize all the textures in the multi render target.
  24202. * Be careful as it will recreate all the data in the new texture.
  24203. * @param size Define the new size
  24204. */
  24205. resize(size: any): void;
  24206. /**
  24207. * Changes the number of render targets in this MRT
  24208. * Be careful as it will recreate all the data in the new texture.
  24209. * @param count new texture count
  24210. * @param options Specifies texture types and sampling modes for new textures
  24211. */
  24212. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  24213. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24214. /**
  24215. * Dispose the render targets and their associated resources
  24216. */
  24217. dispose(): void;
  24218. /**
  24219. * Release all the underlying texture used as draw buffers.
  24220. */
  24221. releaseInternalTextures(): void;
  24222. }
  24223. }
  24224. declare module BABYLON {
  24225. /** @hidden */
  24226. export var imageProcessingPixelShader: {
  24227. name: string;
  24228. shader: string;
  24229. };
  24230. }
  24231. declare module BABYLON {
  24232. /**
  24233. * ImageProcessingPostProcess
  24234. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24235. */
  24236. export class ImageProcessingPostProcess extends PostProcess {
  24237. /**
  24238. * Default configuration related to image processing available in the PBR Material.
  24239. */
  24240. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24241. /**
  24242. * Gets the image processing configuration used either in this material.
  24243. */
  24244. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24245. /**
  24246. * Sets the Default image processing configuration used either in the this material.
  24247. *
  24248. * If sets to null, the scene one is in use.
  24249. */
  24250. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24251. /**
  24252. * Keep track of the image processing observer to allow dispose and replace.
  24253. */
  24254. private _imageProcessingObserver;
  24255. /**
  24256. * Attaches a new image processing configuration to the PBR Material.
  24257. * @param configuration
  24258. */
  24259. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24260. /**
  24261. * If the post process is supported.
  24262. */
  24263. get isSupported(): boolean;
  24264. /**
  24265. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24266. */
  24267. get colorCurves(): Nullable<ColorCurves>;
  24268. /**
  24269. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24270. */
  24271. set colorCurves(value: Nullable<ColorCurves>);
  24272. /**
  24273. * Gets wether the color curves effect is enabled.
  24274. */
  24275. get colorCurvesEnabled(): boolean;
  24276. /**
  24277. * Sets wether the color curves effect is enabled.
  24278. */
  24279. set colorCurvesEnabled(value: boolean);
  24280. /**
  24281. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24282. */
  24283. get colorGradingTexture(): Nullable<BaseTexture>;
  24284. /**
  24285. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24286. */
  24287. set colorGradingTexture(value: Nullable<BaseTexture>);
  24288. /**
  24289. * Gets wether the color grading effect is enabled.
  24290. */
  24291. get colorGradingEnabled(): boolean;
  24292. /**
  24293. * Gets wether the color grading effect is enabled.
  24294. */
  24295. set colorGradingEnabled(value: boolean);
  24296. /**
  24297. * Gets exposure used in the effect.
  24298. */
  24299. get exposure(): number;
  24300. /**
  24301. * Sets exposure used in the effect.
  24302. */
  24303. set exposure(value: number);
  24304. /**
  24305. * Gets wether tonemapping is enabled or not.
  24306. */
  24307. get toneMappingEnabled(): boolean;
  24308. /**
  24309. * Sets wether tonemapping is enabled or not
  24310. */
  24311. set toneMappingEnabled(value: boolean);
  24312. /**
  24313. * Gets the type of tone mapping effect.
  24314. */
  24315. get toneMappingType(): number;
  24316. /**
  24317. * Sets the type of tone mapping effect.
  24318. */
  24319. set toneMappingType(value: number);
  24320. /**
  24321. * Gets contrast used in the effect.
  24322. */
  24323. get contrast(): number;
  24324. /**
  24325. * Sets contrast used in the effect.
  24326. */
  24327. set contrast(value: number);
  24328. /**
  24329. * Gets Vignette stretch size.
  24330. */
  24331. get vignetteStretch(): number;
  24332. /**
  24333. * Sets Vignette stretch size.
  24334. */
  24335. set vignetteStretch(value: number);
  24336. /**
  24337. * Gets Vignette centre X Offset.
  24338. */
  24339. get vignetteCentreX(): number;
  24340. /**
  24341. * Sets Vignette centre X Offset.
  24342. */
  24343. set vignetteCentreX(value: number);
  24344. /**
  24345. * Gets Vignette centre Y Offset.
  24346. */
  24347. get vignetteCentreY(): number;
  24348. /**
  24349. * Sets Vignette centre Y Offset.
  24350. */
  24351. set vignetteCentreY(value: number);
  24352. /**
  24353. * Gets Vignette weight or intensity of the vignette effect.
  24354. */
  24355. get vignetteWeight(): number;
  24356. /**
  24357. * Sets Vignette weight or intensity of the vignette effect.
  24358. */
  24359. set vignetteWeight(value: number);
  24360. /**
  24361. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24362. * if vignetteEnabled is set to true.
  24363. */
  24364. get vignetteColor(): Color4;
  24365. /**
  24366. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24367. * if vignetteEnabled is set to true.
  24368. */
  24369. set vignetteColor(value: Color4);
  24370. /**
  24371. * Gets Camera field of view used by the Vignette effect.
  24372. */
  24373. get vignetteCameraFov(): number;
  24374. /**
  24375. * Sets Camera field of view used by the Vignette effect.
  24376. */
  24377. set vignetteCameraFov(value: number);
  24378. /**
  24379. * Gets the vignette blend mode allowing different kind of effect.
  24380. */
  24381. get vignetteBlendMode(): number;
  24382. /**
  24383. * Sets the vignette blend mode allowing different kind of effect.
  24384. */
  24385. set vignetteBlendMode(value: number);
  24386. /**
  24387. * Gets wether the vignette effect is enabled.
  24388. */
  24389. get vignetteEnabled(): boolean;
  24390. /**
  24391. * Sets wether the vignette effect is enabled.
  24392. */
  24393. set vignetteEnabled(value: boolean);
  24394. private _fromLinearSpace;
  24395. /**
  24396. * Gets wether the input of the processing is in Gamma or Linear Space.
  24397. */
  24398. get fromLinearSpace(): boolean;
  24399. /**
  24400. * Sets wether the input of the processing is in Gamma or Linear Space.
  24401. */
  24402. set fromLinearSpace(value: boolean);
  24403. /**
  24404. * Defines cache preventing GC.
  24405. */
  24406. private _defines;
  24407. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24408. /**
  24409. * "ImageProcessingPostProcess"
  24410. * @returns "ImageProcessingPostProcess"
  24411. */
  24412. getClassName(): string;
  24413. /**
  24414. * @hidden
  24415. */
  24416. _updateParameters(): void;
  24417. dispose(camera?: Camera): void;
  24418. }
  24419. }
  24420. declare module BABYLON {
  24421. /**
  24422. * Interface for defining prepass effects in the prepass post-process pipeline
  24423. */
  24424. export interface PrePassEffectConfiguration {
  24425. /**
  24426. * Name of the effect
  24427. */
  24428. name: string;
  24429. /**
  24430. * Post process to attach for this effect
  24431. */
  24432. postProcess?: PostProcess;
  24433. /**
  24434. * Textures required in the MRT
  24435. */
  24436. texturesRequired: number[];
  24437. /**
  24438. * Is the effect enabled
  24439. */
  24440. enabled: boolean;
  24441. /**
  24442. * Disposes the effect configuration
  24443. */
  24444. dispose(): void;
  24445. /**
  24446. * Creates the associated post process
  24447. */
  24448. createPostProcess?: () => PostProcess;
  24449. }
  24450. }
  24451. declare module BABYLON {
  24452. /**
  24453. * Renders a pre pass of the scene
  24454. * This means every mesh in the scene will be rendered to a render target texture
  24455. * And then this texture will be composited to the rendering canvas with post processes
  24456. * It is necessary for effects like subsurface scattering or deferred shading
  24457. */
  24458. export class PrePassRenderer {
  24459. /** @hidden */
  24460. static _SceneComponentInitialization: (scene: Scene) => void;
  24461. private _textureFormats;
  24462. private _textureIndices;
  24463. private _scene;
  24464. private _engine;
  24465. private _isDirty;
  24466. /**
  24467. * Number of textures in the multi render target texture where the scene is directly rendered
  24468. */
  24469. mrtCount: number;
  24470. /**
  24471. * The render target where the scene is directly rendered
  24472. */
  24473. prePassRT: MultiRenderTarget;
  24474. private _multiRenderAttachments;
  24475. private _defaultAttachments;
  24476. private _clearAttachments;
  24477. private _postProcesses;
  24478. private readonly _clearColor;
  24479. /**
  24480. * Image processing post process for composition
  24481. */
  24482. imageProcessingPostProcess: ImageProcessingPostProcess;
  24483. /**
  24484. * Configuration for prepass effects
  24485. */
  24486. private _effectConfigurations;
  24487. /**
  24488. * Should materials render their geometry on the MRT
  24489. */
  24490. materialsShouldRenderGeometry: boolean;
  24491. /**
  24492. * Should materials render the irradiance information on the MRT
  24493. */
  24494. materialsShouldRenderIrradiance: boolean;
  24495. private _mrtFormats;
  24496. private _mrtLayout;
  24497. private _enabled;
  24498. /**
  24499. * Indicates if the prepass is enabled
  24500. */
  24501. get enabled(): boolean;
  24502. /**
  24503. * How many samples are used for MSAA of the scene render target
  24504. */
  24505. get samples(): number;
  24506. set samples(n: number);
  24507. /**
  24508. * Instanciates a prepass renderer
  24509. * @param scene The scene
  24510. */
  24511. constructor(scene: Scene);
  24512. private _initializeAttachments;
  24513. private _createCompositionEffect;
  24514. /**
  24515. * Indicates if rendering a prepass is supported
  24516. */
  24517. get isSupported(): boolean;
  24518. /**
  24519. * Sets the proper output textures to draw in the engine.
  24520. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  24521. */
  24522. bindAttachmentsForEffect(effect: Effect): void;
  24523. /**
  24524. * @hidden
  24525. */
  24526. _beforeCameraDraw(): void;
  24527. /**
  24528. * @hidden
  24529. */
  24530. _afterCameraDraw(): void;
  24531. private _checkRTSize;
  24532. private _bindFrameBuffer;
  24533. /**
  24534. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  24535. */
  24536. clear(): void;
  24537. private _setState;
  24538. private _checkTextureType;
  24539. /**
  24540. * Adds an effect configuration to the prepass.
  24541. * If an effect has already been added, it won't add it twice and will return the configuration
  24542. * already present.
  24543. * @param cfg the effect configuration
  24544. * @return the effect configuration now used by the prepass
  24545. */
  24546. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  24547. /**
  24548. * Returns the index of a texture in the multi render target texture array.
  24549. * @param type Texture type
  24550. * @return The index
  24551. */
  24552. getIndex(type: number): number;
  24553. private _enable;
  24554. private _disable;
  24555. private _resetLayout;
  24556. private _resetPostProcessChain;
  24557. private _bindPostProcessChain;
  24558. /**
  24559. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  24560. */
  24561. markAsDirty(): void;
  24562. /**
  24563. * Enables a texture on the MultiRenderTarget for prepass
  24564. */
  24565. private _enableTextures;
  24566. private _update;
  24567. /**
  24568. * Disposes the prepass renderer.
  24569. */
  24570. dispose(): void;
  24571. }
  24572. }
  24573. declare module BABYLON {
  24574. /**
  24575. * Options for compiling materials.
  24576. */
  24577. export interface IMaterialCompilationOptions {
  24578. /**
  24579. * Defines whether clip planes are enabled.
  24580. */
  24581. clipPlane: boolean;
  24582. /**
  24583. * Defines whether instances are enabled.
  24584. */
  24585. useInstances: boolean;
  24586. }
  24587. /**
  24588. * Options passed when calling customShaderNameResolve
  24589. */
  24590. export interface ICustomShaderNameResolveOptions {
  24591. /**
  24592. * 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
  24593. */
  24594. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24595. }
  24596. /**
  24597. * Base class for the main features of a material in Babylon.js
  24598. */
  24599. export class Material implements IAnimatable {
  24600. /**
  24601. * Returns the triangle fill mode
  24602. */
  24603. static readonly TriangleFillMode: number;
  24604. /**
  24605. * Returns the wireframe mode
  24606. */
  24607. static readonly WireFrameFillMode: number;
  24608. /**
  24609. * Returns the point fill mode
  24610. */
  24611. static readonly PointFillMode: number;
  24612. /**
  24613. * Returns the point list draw mode
  24614. */
  24615. static readonly PointListDrawMode: number;
  24616. /**
  24617. * Returns the line list draw mode
  24618. */
  24619. static readonly LineListDrawMode: number;
  24620. /**
  24621. * Returns the line loop draw mode
  24622. */
  24623. static readonly LineLoopDrawMode: number;
  24624. /**
  24625. * Returns the line strip draw mode
  24626. */
  24627. static readonly LineStripDrawMode: number;
  24628. /**
  24629. * Returns the triangle strip draw mode
  24630. */
  24631. static readonly TriangleStripDrawMode: number;
  24632. /**
  24633. * Returns the triangle fan draw mode
  24634. */
  24635. static readonly TriangleFanDrawMode: number;
  24636. /**
  24637. * Stores the clock-wise side orientation
  24638. */
  24639. static readonly ClockWiseSideOrientation: number;
  24640. /**
  24641. * Stores the counter clock-wise side orientation
  24642. */
  24643. static readonly CounterClockWiseSideOrientation: number;
  24644. /**
  24645. * The dirty texture flag value
  24646. */
  24647. static readonly TextureDirtyFlag: number;
  24648. /**
  24649. * The dirty light flag value
  24650. */
  24651. static readonly LightDirtyFlag: number;
  24652. /**
  24653. * The dirty fresnel flag value
  24654. */
  24655. static readonly FresnelDirtyFlag: number;
  24656. /**
  24657. * The dirty attribute flag value
  24658. */
  24659. static readonly AttributesDirtyFlag: number;
  24660. /**
  24661. * The dirty misc flag value
  24662. */
  24663. static readonly MiscDirtyFlag: number;
  24664. /**
  24665. * The all dirty flag value
  24666. */
  24667. static readonly AllDirtyFlag: number;
  24668. /**
  24669. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24670. */
  24671. static readonly MATERIAL_OPAQUE: number;
  24672. /**
  24673. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24674. */
  24675. static readonly MATERIAL_ALPHATEST: number;
  24676. /**
  24677. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24678. */
  24679. static readonly MATERIAL_ALPHABLEND: number;
  24680. /**
  24681. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24682. * They are also discarded below the alpha cutoff threshold to improve performances.
  24683. */
  24684. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24685. /**
  24686. * The Whiteout method is used to blend normals.
  24687. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24688. */
  24689. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24690. /**
  24691. * The Reoriented Normal Mapping method is used to blend normals.
  24692. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24693. */
  24694. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24695. /**
  24696. * Custom callback helping to override the default shader used in the material.
  24697. */
  24698. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24699. /**
  24700. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24701. */
  24702. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24703. /**
  24704. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24705. * This means that the material can keep using a previous shader while a new one is being compiled.
  24706. * This is mostly used when shader parallel compilation is supported (true by default)
  24707. */
  24708. allowShaderHotSwapping: boolean;
  24709. /**
  24710. * The ID of the material
  24711. */
  24712. id: string;
  24713. /**
  24714. * Gets or sets the unique id of the material
  24715. */
  24716. uniqueId: number;
  24717. /**
  24718. * The name of the material
  24719. */
  24720. name: string;
  24721. /**
  24722. * Gets or sets user defined metadata
  24723. */
  24724. metadata: any;
  24725. /**
  24726. * For internal use only. Please do not use.
  24727. */
  24728. reservedDataStore: any;
  24729. /**
  24730. * Specifies if the ready state should be checked on each call
  24731. */
  24732. checkReadyOnEveryCall: boolean;
  24733. /**
  24734. * Specifies if the ready state should be checked once
  24735. */
  24736. checkReadyOnlyOnce: boolean;
  24737. /**
  24738. * The state of the material
  24739. */
  24740. state: string;
  24741. /**
  24742. * If the material can be rendered to several textures with MRT extension
  24743. */
  24744. get canRenderToMRT(): boolean;
  24745. /**
  24746. * The alpha value of the material
  24747. */
  24748. protected _alpha: number;
  24749. /**
  24750. * List of inspectable custom properties (used by the Inspector)
  24751. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24752. */
  24753. inspectableCustomProperties: IInspectable[];
  24754. /**
  24755. * Sets the alpha value of the material
  24756. */
  24757. set alpha(value: number);
  24758. /**
  24759. * Gets the alpha value of the material
  24760. */
  24761. get alpha(): number;
  24762. /**
  24763. * Specifies if back face culling is enabled
  24764. */
  24765. protected _backFaceCulling: boolean;
  24766. /**
  24767. * Sets the back-face culling state
  24768. */
  24769. set backFaceCulling(value: boolean);
  24770. /**
  24771. * Gets the back-face culling state
  24772. */
  24773. get backFaceCulling(): boolean;
  24774. /**
  24775. * Stores the value for side orientation
  24776. */
  24777. sideOrientation: number;
  24778. /**
  24779. * Callback triggered when the material is compiled
  24780. */
  24781. onCompiled: Nullable<(effect: Effect) => void>;
  24782. /**
  24783. * Callback triggered when an error occurs
  24784. */
  24785. onError: Nullable<(effect: Effect, errors: string) => void>;
  24786. /**
  24787. * Callback triggered to get the render target textures
  24788. */
  24789. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24790. /**
  24791. * Gets a boolean indicating that current material needs to register RTT
  24792. */
  24793. get hasRenderTargetTextures(): boolean;
  24794. /**
  24795. * Specifies if the material should be serialized
  24796. */
  24797. doNotSerialize: boolean;
  24798. /**
  24799. * @hidden
  24800. */
  24801. _storeEffectOnSubMeshes: boolean;
  24802. /**
  24803. * Stores the animations for the material
  24804. */
  24805. animations: Nullable<Array<Animation>>;
  24806. /**
  24807. * An event triggered when the material is disposed
  24808. */
  24809. onDisposeObservable: Observable<Material>;
  24810. /**
  24811. * An observer which watches for dispose events
  24812. */
  24813. private _onDisposeObserver;
  24814. private _onUnBindObservable;
  24815. /**
  24816. * Called during a dispose event
  24817. */
  24818. set onDispose(callback: () => void);
  24819. private _onBindObservable;
  24820. /**
  24821. * An event triggered when the material is bound
  24822. */
  24823. get onBindObservable(): Observable<AbstractMesh>;
  24824. /**
  24825. * An observer which watches for bind events
  24826. */
  24827. private _onBindObserver;
  24828. /**
  24829. * Called during a bind event
  24830. */
  24831. set onBind(callback: (Mesh: AbstractMesh) => void);
  24832. /**
  24833. * An event triggered when the material is unbound
  24834. */
  24835. get onUnBindObservable(): Observable<Material>;
  24836. protected _onEffectCreatedObservable: Nullable<Observable<{
  24837. effect: Effect;
  24838. subMesh: Nullable<SubMesh>;
  24839. }>>;
  24840. /**
  24841. * An event triggered when the effect is (re)created
  24842. */
  24843. get onEffectCreatedObservable(): Observable<{
  24844. effect: Effect;
  24845. subMesh: Nullable<SubMesh>;
  24846. }>;
  24847. /**
  24848. * Stores the value of the alpha mode
  24849. */
  24850. private _alphaMode;
  24851. /**
  24852. * Sets the value of the alpha mode.
  24853. *
  24854. * | Value | Type | Description |
  24855. * | --- | --- | --- |
  24856. * | 0 | ALPHA_DISABLE | |
  24857. * | 1 | ALPHA_ADD | |
  24858. * | 2 | ALPHA_COMBINE | |
  24859. * | 3 | ALPHA_SUBTRACT | |
  24860. * | 4 | ALPHA_MULTIPLY | |
  24861. * | 5 | ALPHA_MAXIMIZED | |
  24862. * | 6 | ALPHA_ONEONE | |
  24863. * | 7 | ALPHA_PREMULTIPLIED | |
  24864. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24865. * | 9 | ALPHA_INTERPOLATE | |
  24866. * | 10 | ALPHA_SCREENMODE | |
  24867. *
  24868. */
  24869. set alphaMode(value: number);
  24870. /**
  24871. * Gets the value of the alpha mode
  24872. */
  24873. get alphaMode(): number;
  24874. /**
  24875. * Stores the state of the need depth pre-pass value
  24876. */
  24877. private _needDepthPrePass;
  24878. /**
  24879. * Sets the need depth pre-pass value
  24880. */
  24881. set needDepthPrePass(value: boolean);
  24882. /**
  24883. * Gets the depth pre-pass value
  24884. */
  24885. get needDepthPrePass(): boolean;
  24886. /**
  24887. * Specifies if depth writing should be disabled
  24888. */
  24889. disableDepthWrite: boolean;
  24890. /**
  24891. * Specifies if color writing should be disabled
  24892. */
  24893. disableColorWrite: boolean;
  24894. /**
  24895. * Specifies if depth writing should be forced
  24896. */
  24897. forceDepthWrite: boolean;
  24898. /**
  24899. * Specifies the depth function that should be used. 0 means the default engine function
  24900. */
  24901. depthFunction: number;
  24902. /**
  24903. * Specifies if there should be a separate pass for culling
  24904. */
  24905. separateCullingPass: boolean;
  24906. /**
  24907. * Stores the state specifing if fog should be enabled
  24908. */
  24909. private _fogEnabled;
  24910. /**
  24911. * Sets the state for enabling fog
  24912. */
  24913. set fogEnabled(value: boolean);
  24914. /**
  24915. * Gets the value of the fog enabled state
  24916. */
  24917. get fogEnabled(): boolean;
  24918. /**
  24919. * Stores the size of points
  24920. */
  24921. pointSize: number;
  24922. /**
  24923. * Stores the z offset value
  24924. */
  24925. zOffset: number;
  24926. get wireframe(): boolean;
  24927. /**
  24928. * Sets the state of wireframe mode
  24929. */
  24930. set wireframe(value: boolean);
  24931. /**
  24932. * Gets the value specifying if point clouds are enabled
  24933. */
  24934. get pointsCloud(): boolean;
  24935. /**
  24936. * Sets the state of point cloud mode
  24937. */
  24938. set pointsCloud(value: boolean);
  24939. /**
  24940. * Gets the material fill mode
  24941. */
  24942. get fillMode(): number;
  24943. /**
  24944. * Sets the material fill mode
  24945. */
  24946. set fillMode(value: number);
  24947. /**
  24948. * @hidden
  24949. * Stores the effects for the material
  24950. */
  24951. _effect: Nullable<Effect>;
  24952. /**
  24953. * Specifies if uniform buffers should be used
  24954. */
  24955. private _useUBO;
  24956. /**
  24957. * Stores a reference to the scene
  24958. */
  24959. private _scene;
  24960. /**
  24961. * Stores the fill mode state
  24962. */
  24963. private _fillMode;
  24964. /**
  24965. * Specifies if the depth write state should be cached
  24966. */
  24967. private _cachedDepthWriteState;
  24968. /**
  24969. * Specifies if the color write state should be cached
  24970. */
  24971. private _cachedColorWriteState;
  24972. /**
  24973. * Specifies if the depth function state should be cached
  24974. */
  24975. private _cachedDepthFunctionState;
  24976. /**
  24977. * Stores the uniform buffer
  24978. */
  24979. protected _uniformBuffer: UniformBuffer;
  24980. /** @hidden */
  24981. _indexInSceneMaterialArray: number;
  24982. /** @hidden */
  24983. meshMap: Nullable<{
  24984. [id: string]: AbstractMesh | undefined;
  24985. }>;
  24986. /**
  24987. * Creates a material instance
  24988. * @param name defines the name of the material
  24989. * @param scene defines the scene to reference
  24990. * @param doNotAdd specifies if the material should be added to the scene
  24991. */
  24992. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24993. /**
  24994. * Returns a string representation of the current material
  24995. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24996. * @returns a string with material information
  24997. */
  24998. toString(fullDetails?: boolean): string;
  24999. /**
  25000. * Gets the class name of the material
  25001. * @returns a string with the class name of the material
  25002. */
  25003. getClassName(): string;
  25004. /**
  25005. * Specifies if updates for the material been locked
  25006. */
  25007. get isFrozen(): boolean;
  25008. /**
  25009. * Locks updates for the material
  25010. */
  25011. freeze(): void;
  25012. /**
  25013. * Unlocks updates for the material
  25014. */
  25015. unfreeze(): void;
  25016. /**
  25017. * Specifies if the material is ready to be used
  25018. * @param mesh defines the mesh to check
  25019. * @param useInstances specifies if instances should be used
  25020. * @returns a boolean indicating if the material is ready to be used
  25021. */
  25022. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25023. /**
  25024. * Specifies that the submesh is ready to be used
  25025. * @param mesh defines the mesh to check
  25026. * @param subMesh defines which submesh to check
  25027. * @param useInstances specifies that instances should be used
  25028. * @returns a boolean indicating that the submesh is ready or not
  25029. */
  25030. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25031. /**
  25032. * Returns the material effect
  25033. * @returns the effect associated with the material
  25034. */
  25035. getEffect(): Nullable<Effect>;
  25036. /**
  25037. * Returns the current scene
  25038. * @returns a Scene
  25039. */
  25040. getScene(): Scene;
  25041. /**
  25042. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25043. */
  25044. protected _forceAlphaTest: boolean;
  25045. /**
  25046. * The transparency mode of the material.
  25047. */
  25048. protected _transparencyMode: Nullable<number>;
  25049. /**
  25050. * Gets the current transparency mode.
  25051. */
  25052. get transparencyMode(): Nullable<number>;
  25053. /**
  25054. * Sets the transparency mode of the material.
  25055. *
  25056. * | Value | Type | Description |
  25057. * | ----- | ----------------------------------- | ----------- |
  25058. * | 0 | OPAQUE | |
  25059. * | 1 | ALPHATEST | |
  25060. * | 2 | ALPHABLEND | |
  25061. * | 3 | ALPHATESTANDBLEND | |
  25062. *
  25063. */
  25064. set transparencyMode(value: Nullable<number>);
  25065. /**
  25066. * Returns true if alpha blending should be disabled.
  25067. */
  25068. protected get _disableAlphaBlending(): boolean;
  25069. /**
  25070. * Specifies whether or not this material should be rendered in alpha blend mode.
  25071. * @returns a boolean specifying if alpha blending is needed
  25072. */
  25073. needAlphaBlending(): boolean;
  25074. /**
  25075. * Specifies if the mesh will require alpha blending
  25076. * @param mesh defines the mesh to check
  25077. * @returns a boolean specifying if alpha blending is needed for the mesh
  25078. */
  25079. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25080. /**
  25081. * Specifies whether or not this material should be rendered in alpha test mode.
  25082. * @returns a boolean specifying if an alpha test is needed.
  25083. */
  25084. needAlphaTesting(): boolean;
  25085. /**
  25086. * Specifies if material alpha testing should be turned on for the mesh
  25087. * @param mesh defines the mesh to check
  25088. */
  25089. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25090. /**
  25091. * Gets the texture used for the alpha test
  25092. * @returns the texture to use for alpha testing
  25093. */
  25094. getAlphaTestTexture(): Nullable<BaseTexture>;
  25095. /**
  25096. * Marks the material to indicate that it needs to be re-calculated
  25097. */
  25098. markDirty(): void;
  25099. /** @hidden */
  25100. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25101. /**
  25102. * Binds the material to the mesh
  25103. * @param world defines the world transformation matrix
  25104. * @param mesh defines the mesh to bind the material to
  25105. */
  25106. bind(world: Matrix, mesh?: Mesh): void;
  25107. /**
  25108. * Binds the submesh to the material
  25109. * @param world defines the world transformation matrix
  25110. * @param mesh defines the mesh containing the submesh
  25111. * @param subMesh defines the submesh to bind the material to
  25112. */
  25113. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25114. /**
  25115. * Binds the world matrix to the material
  25116. * @param world defines the world transformation matrix
  25117. */
  25118. bindOnlyWorldMatrix(world: Matrix): void;
  25119. /**
  25120. * Binds the scene's uniform buffer to the effect.
  25121. * @param effect defines the effect to bind to the scene uniform buffer
  25122. * @param sceneUbo defines the uniform buffer storing scene data
  25123. */
  25124. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25125. /**
  25126. * Binds the view matrix to the effect
  25127. * @param effect defines the effect to bind the view matrix to
  25128. */
  25129. bindView(effect: Effect): void;
  25130. /**
  25131. * Binds the view projection matrix to the effect
  25132. * @param effect defines the effect to bind the view projection matrix to
  25133. */
  25134. bindViewProjection(effect: Effect): void;
  25135. /**
  25136. * Processes to execute after binding the material to a mesh
  25137. * @param mesh defines the rendered mesh
  25138. */
  25139. protected _afterBind(mesh?: Mesh): void;
  25140. /**
  25141. * Unbinds the material from the mesh
  25142. */
  25143. unbind(): void;
  25144. /**
  25145. * Gets the active textures from the material
  25146. * @returns an array of textures
  25147. */
  25148. getActiveTextures(): BaseTexture[];
  25149. /**
  25150. * Specifies if the material uses a texture
  25151. * @param texture defines the texture to check against the material
  25152. * @returns a boolean specifying if the material uses the texture
  25153. */
  25154. hasTexture(texture: BaseTexture): boolean;
  25155. /**
  25156. * Makes a duplicate of the material, and gives it a new name
  25157. * @param name defines the new name for the duplicated material
  25158. * @returns the cloned material
  25159. */
  25160. clone(name: string): Nullable<Material>;
  25161. /**
  25162. * Gets the meshes bound to the material
  25163. * @returns an array of meshes bound to the material
  25164. */
  25165. getBindedMeshes(): AbstractMesh[];
  25166. /**
  25167. * Force shader compilation
  25168. * @param mesh defines the mesh associated with this material
  25169. * @param onCompiled defines a function to execute once the material is compiled
  25170. * @param options defines the options to configure the compilation
  25171. * @param onError defines a function to execute if the material fails compiling
  25172. */
  25173. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25174. /**
  25175. * Force shader compilation
  25176. * @param mesh defines the mesh that will use this material
  25177. * @param options defines additional options for compiling the shaders
  25178. * @returns a promise that resolves when the compilation completes
  25179. */
  25180. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25181. private static readonly _AllDirtyCallBack;
  25182. private static readonly _ImageProcessingDirtyCallBack;
  25183. private static readonly _TextureDirtyCallBack;
  25184. private static readonly _FresnelDirtyCallBack;
  25185. private static readonly _MiscDirtyCallBack;
  25186. private static readonly _LightsDirtyCallBack;
  25187. private static readonly _AttributeDirtyCallBack;
  25188. private static _FresnelAndMiscDirtyCallBack;
  25189. private static _TextureAndMiscDirtyCallBack;
  25190. private static readonly _DirtyCallbackArray;
  25191. private static readonly _RunDirtyCallBacks;
  25192. /**
  25193. * Marks a define in the material to indicate that it needs to be re-computed
  25194. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25195. */
  25196. markAsDirty(flag: number): void;
  25197. /**
  25198. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25199. * @param func defines a function which checks material defines against the submeshes
  25200. */
  25201. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25202. /**
  25203. * Indicates that the scene should check if the rendering now needs a prepass
  25204. */
  25205. protected _markScenePrePassDirty(): void;
  25206. /**
  25207. * Indicates that we need to re-calculated for all submeshes
  25208. */
  25209. protected _markAllSubMeshesAsAllDirty(): void;
  25210. /**
  25211. * Indicates that image processing needs to be re-calculated for all submeshes
  25212. */
  25213. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25214. /**
  25215. * Indicates that textures need to be re-calculated for all submeshes
  25216. */
  25217. protected _markAllSubMeshesAsTexturesDirty(): void;
  25218. /**
  25219. * Indicates that fresnel needs to be re-calculated for all submeshes
  25220. */
  25221. protected _markAllSubMeshesAsFresnelDirty(): void;
  25222. /**
  25223. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25224. */
  25225. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25226. /**
  25227. * Indicates that lights need to be re-calculated for all submeshes
  25228. */
  25229. protected _markAllSubMeshesAsLightsDirty(): void;
  25230. /**
  25231. * Indicates that attributes need to be re-calculated for all submeshes
  25232. */
  25233. protected _markAllSubMeshesAsAttributesDirty(): void;
  25234. /**
  25235. * Indicates that misc needs to be re-calculated for all submeshes
  25236. */
  25237. protected _markAllSubMeshesAsMiscDirty(): void;
  25238. /**
  25239. * Indicates that textures and misc need to be re-calculated for all submeshes
  25240. */
  25241. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25242. /**
  25243. * Sets the required values to the prepass renderer.
  25244. * @param prePassRenderer defines the prepass renderer to setup.
  25245. * @returns true if the pre pass is needed.
  25246. */
  25247. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  25248. /**
  25249. * Disposes the material
  25250. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25251. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25252. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25253. */
  25254. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25255. /** @hidden */
  25256. private releaseVertexArrayObject;
  25257. /**
  25258. * Serializes this material
  25259. * @returns the serialized material object
  25260. */
  25261. serialize(): any;
  25262. /**
  25263. * Creates a material from parsed material data
  25264. * @param parsedMaterial defines parsed material data
  25265. * @param scene defines the hosting scene
  25266. * @param rootUrl defines the root URL to use to load textures
  25267. * @returns a new material
  25268. */
  25269. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25270. }
  25271. }
  25272. declare module BABYLON {
  25273. /**
  25274. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25275. * separate meshes. This can be use to improve performances.
  25276. * @see https://doc.babylonjs.com/how_to/multi_materials
  25277. */
  25278. export class MultiMaterial extends Material {
  25279. private _subMaterials;
  25280. /**
  25281. * Gets or Sets the list of Materials used within the multi material.
  25282. * They need to be ordered according to the submeshes order in the associated mesh
  25283. */
  25284. get subMaterials(): Nullable<Material>[];
  25285. set subMaterials(value: Nullable<Material>[]);
  25286. /**
  25287. * Function used to align with Node.getChildren()
  25288. * @returns the list of Materials used within the multi material
  25289. */
  25290. getChildren(): Nullable<Material>[];
  25291. /**
  25292. * Instantiates a new Multi Material
  25293. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25294. * separate meshes. This can be use to improve performances.
  25295. * @see https://doc.babylonjs.com/how_to/multi_materials
  25296. * @param name Define the name in the scene
  25297. * @param scene Define the scene the material belongs to
  25298. */
  25299. constructor(name: string, scene: Scene);
  25300. private _hookArray;
  25301. /**
  25302. * Get one of the submaterial by its index in the submaterials array
  25303. * @param index The index to look the sub material at
  25304. * @returns The Material if the index has been defined
  25305. */
  25306. getSubMaterial(index: number): Nullable<Material>;
  25307. /**
  25308. * Get the list of active textures for the whole sub materials list.
  25309. * @returns All the textures that will be used during the rendering
  25310. */
  25311. getActiveTextures(): BaseTexture[];
  25312. /**
  25313. * Gets the current class name of the material e.g. "MultiMaterial"
  25314. * Mainly use in serialization.
  25315. * @returns the class name
  25316. */
  25317. getClassName(): string;
  25318. /**
  25319. * Checks if the material is ready to render the requested sub mesh
  25320. * @param mesh Define the mesh the submesh belongs to
  25321. * @param subMesh Define the sub mesh to look readyness for
  25322. * @param useInstances Define whether or not the material is used with instances
  25323. * @returns true if ready, otherwise false
  25324. */
  25325. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25326. /**
  25327. * Clones the current material and its related sub materials
  25328. * @param name Define the name of the newly cloned material
  25329. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25330. * @returns the cloned material
  25331. */
  25332. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25333. /**
  25334. * Serializes the materials into a JSON representation.
  25335. * @returns the JSON representation
  25336. */
  25337. serialize(): any;
  25338. /**
  25339. * Dispose the material and release its associated resources
  25340. * @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)
  25341. * @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)
  25342. * @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)
  25343. */
  25344. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25345. /**
  25346. * Creates a MultiMaterial from parsed MultiMaterial data.
  25347. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25348. * @param scene defines the hosting scene
  25349. * @returns a new MultiMaterial
  25350. */
  25351. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25352. }
  25353. }
  25354. declare module BABYLON {
  25355. /**
  25356. * Defines a subdivision inside a mesh
  25357. */
  25358. export class SubMesh implements ICullable {
  25359. /** the material index to use */
  25360. materialIndex: number;
  25361. /** vertex index start */
  25362. verticesStart: number;
  25363. /** vertices count */
  25364. verticesCount: number;
  25365. /** index start */
  25366. indexStart: number;
  25367. /** indices count */
  25368. indexCount: number;
  25369. /** @hidden */
  25370. _materialDefines: Nullable<MaterialDefines>;
  25371. /** @hidden */
  25372. _materialEffect: Nullable<Effect>;
  25373. /** @hidden */
  25374. _effectOverride: Nullable<Effect>;
  25375. /**
  25376. * Gets material defines used by the effect associated to the sub mesh
  25377. */
  25378. get materialDefines(): Nullable<MaterialDefines>;
  25379. /**
  25380. * Sets material defines used by the effect associated to the sub mesh
  25381. */
  25382. set materialDefines(defines: Nullable<MaterialDefines>);
  25383. /**
  25384. * Gets associated effect
  25385. */
  25386. get effect(): Nullable<Effect>;
  25387. /**
  25388. * Sets associated effect (effect used to render this submesh)
  25389. * @param effect defines the effect to associate with
  25390. * @param defines defines the set of defines used to compile this effect
  25391. */
  25392. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25393. /** @hidden */
  25394. _linesIndexCount: number;
  25395. private _mesh;
  25396. private _renderingMesh;
  25397. private _boundingInfo;
  25398. private _linesIndexBuffer;
  25399. /** @hidden */
  25400. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25401. /** @hidden */
  25402. _trianglePlanes: Plane[];
  25403. /** @hidden */
  25404. _lastColliderTransformMatrix: Nullable<Matrix>;
  25405. /** @hidden */
  25406. _renderId: number;
  25407. /** @hidden */
  25408. _alphaIndex: number;
  25409. /** @hidden */
  25410. _distanceToCamera: number;
  25411. /** @hidden */
  25412. _id: number;
  25413. private _currentMaterial;
  25414. /**
  25415. * Add a new submesh to a mesh
  25416. * @param materialIndex defines the material index to use
  25417. * @param verticesStart defines vertex index start
  25418. * @param verticesCount defines vertices count
  25419. * @param indexStart defines index start
  25420. * @param indexCount defines indices count
  25421. * @param mesh defines the parent mesh
  25422. * @param renderingMesh defines an optional rendering mesh
  25423. * @param createBoundingBox defines if bounding box should be created for this submesh
  25424. * @returns the new submesh
  25425. */
  25426. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25427. /**
  25428. * Creates a new submesh
  25429. * @param materialIndex defines the material index to use
  25430. * @param verticesStart defines vertex index start
  25431. * @param verticesCount defines vertices count
  25432. * @param indexStart defines index start
  25433. * @param indexCount defines indices count
  25434. * @param mesh defines the parent mesh
  25435. * @param renderingMesh defines an optional rendering mesh
  25436. * @param createBoundingBox defines if bounding box should be created for this submesh
  25437. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25438. */
  25439. constructor(
  25440. /** the material index to use */
  25441. materialIndex: number,
  25442. /** vertex index start */
  25443. verticesStart: number,
  25444. /** vertices count */
  25445. verticesCount: number,
  25446. /** index start */
  25447. indexStart: number,
  25448. /** indices count */
  25449. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25450. /**
  25451. * Returns true if this submesh covers the entire parent mesh
  25452. * @ignorenaming
  25453. */
  25454. get IsGlobal(): boolean;
  25455. /**
  25456. * Returns the submesh BoudingInfo object
  25457. * @returns current bounding info (or mesh's one if the submesh is global)
  25458. */
  25459. getBoundingInfo(): BoundingInfo;
  25460. /**
  25461. * Sets the submesh BoundingInfo
  25462. * @param boundingInfo defines the new bounding info to use
  25463. * @returns the SubMesh
  25464. */
  25465. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25466. /**
  25467. * Returns the mesh of the current submesh
  25468. * @return the parent mesh
  25469. */
  25470. getMesh(): AbstractMesh;
  25471. /**
  25472. * Returns the rendering mesh of the submesh
  25473. * @returns the rendering mesh (could be different from parent mesh)
  25474. */
  25475. getRenderingMesh(): Mesh;
  25476. /**
  25477. * Returns the replacement mesh of the submesh
  25478. * @returns the replacement mesh (could be different from parent mesh)
  25479. */
  25480. getReplacementMesh(): Nullable<AbstractMesh>;
  25481. /**
  25482. * Returns the effective mesh of the submesh
  25483. * @returns the effective mesh (could be different from parent mesh)
  25484. */
  25485. getEffectiveMesh(): AbstractMesh;
  25486. /**
  25487. * Returns the submesh material
  25488. * @returns null or the current material
  25489. */
  25490. getMaterial(): Nullable<Material>;
  25491. private _IsMultiMaterial;
  25492. /**
  25493. * Sets a new updated BoundingInfo object to the submesh
  25494. * @param data defines an optional position array to use to determine the bounding info
  25495. * @returns the SubMesh
  25496. */
  25497. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25498. /** @hidden */
  25499. _checkCollision(collider: Collider): boolean;
  25500. /**
  25501. * Updates the submesh BoundingInfo
  25502. * @param world defines the world matrix to use to update the bounding info
  25503. * @returns the submesh
  25504. */
  25505. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25506. /**
  25507. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25508. * @param frustumPlanes defines the frustum planes
  25509. * @returns true if the submesh is intersecting with the frustum
  25510. */
  25511. isInFrustum(frustumPlanes: Plane[]): boolean;
  25512. /**
  25513. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25514. * @param frustumPlanes defines the frustum planes
  25515. * @returns true if the submesh is inside the frustum
  25516. */
  25517. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25518. /**
  25519. * Renders the submesh
  25520. * @param enableAlphaMode defines if alpha needs to be used
  25521. * @returns the submesh
  25522. */
  25523. render(enableAlphaMode: boolean): SubMesh;
  25524. /**
  25525. * @hidden
  25526. */
  25527. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25528. /**
  25529. * Checks if the submesh intersects with a ray
  25530. * @param ray defines the ray to test
  25531. * @returns true is the passed ray intersects the submesh bounding box
  25532. */
  25533. canIntersects(ray: Ray): boolean;
  25534. /**
  25535. * Intersects current submesh with a ray
  25536. * @param ray defines the ray to test
  25537. * @param positions defines mesh's positions array
  25538. * @param indices defines mesh's indices array
  25539. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25540. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25541. * @returns intersection info or null if no intersection
  25542. */
  25543. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25544. /** @hidden */
  25545. private _intersectLines;
  25546. /** @hidden */
  25547. private _intersectUnIndexedLines;
  25548. /** @hidden */
  25549. private _intersectTriangles;
  25550. /** @hidden */
  25551. private _intersectUnIndexedTriangles;
  25552. /** @hidden */
  25553. _rebuild(): void;
  25554. /**
  25555. * Creates a new submesh from the passed mesh
  25556. * @param newMesh defines the new hosting mesh
  25557. * @param newRenderingMesh defines an optional rendering mesh
  25558. * @returns the new submesh
  25559. */
  25560. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25561. /**
  25562. * Release associated resources
  25563. */
  25564. dispose(): void;
  25565. /**
  25566. * Gets the class name
  25567. * @returns the string "SubMesh".
  25568. */
  25569. getClassName(): string;
  25570. /**
  25571. * Creates a new submesh from indices data
  25572. * @param materialIndex the index of the main mesh material
  25573. * @param startIndex the index where to start the copy in the mesh indices array
  25574. * @param indexCount the number of indices to copy then from the startIndex
  25575. * @param mesh the main mesh to create the submesh from
  25576. * @param renderingMesh the optional rendering mesh
  25577. * @returns a new submesh
  25578. */
  25579. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25580. }
  25581. }
  25582. declare module BABYLON {
  25583. /**
  25584. * Class used to represent data loading progression
  25585. */
  25586. export class SceneLoaderFlags {
  25587. private static _ForceFullSceneLoadingForIncremental;
  25588. private static _ShowLoadingScreen;
  25589. private static _CleanBoneMatrixWeights;
  25590. private static _loggingLevel;
  25591. /**
  25592. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25593. */
  25594. static get ForceFullSceneLoadingForIncremental(): boolean;
  25595. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25596. /**
  25597. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25598. */
  25599. static get ShowLoadingScreen(): boolean;
  25600. static set ShowLoadingScreen(value: boolean);
  25601. /**
  25602. * Defines the current logging level (while loading the scene)
  25603. * @ignorenaming
  25604. */
  25605. static get loggingLevel(): number;
  25606. static set loggingLevel(value: number);
  25607. /**
  25608. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25609. */
  25610. static get CleanBoneMatrixWeights(): boolean;
  25611. static set CleanBoneMatrixWeights(value: boolean);
  25612. }
  25613. }
  25614. declare module BABYLON {
  25615. /**
  25616. * Class used to store geometry data (vertex buffers + index buffer)
  25617. */
  25618. export class Geometry implements IGetSetVerticesData {
  25619. /**
  25620. * Gets or sets the ID of the geometry
  25621. */
  25622. id: string;
  25623. /**
  25624. * Gets or sets the unique ID of the geometry
  25625. */
  25626. uniqueId: number;
  25627. /**
  25628. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25629. */
  25630. delayLoadState: number;
  25631. /**
  25632. * Gets the file containing the data to load when running in delay load state
  25633. */
  25634. delayLoadingFile: Nullable<string>;
  25635. /**
  25636. * Callback called when the geometry is updated
  25637. */
  25638. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25639. private _scene;
  25640. private _engine;
  25641. private _meshes;
  25642. private _totalVertices;
  25643. /** @hidden */
  25644. _indices: IndicesArray;
  25645. /** @hidden */
  25646. _vertexBuffers: {
  25647. [key: string]: VertexBuffer;
  25648. };
  25649. private _isDisposed;
  25650. private _extend;
  25651. private _boundingBias;
  25652. /** @hidden */
  25653. _delayInfo: Array<string>;
  25654. private _indexBuffer;
  25655. private _indexBufferIsUpdatable;
  25656. /** @hidden */
  25657. _boundingInfo: Nullable<BoundingInfo>;
  25658. /** @hidden */
  25659. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25660. /** @hidden */
  25661. _softwareSkinningFrameId: number;
  25662. private _vertexArrayObjects;
  25663. private _updatable;
  25664. /** @hidden */
  25665. _positions: Nullable<Vector3[]>;
  25666. /**
  25667. * 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
  25668. */
  25669. get boundingBias(): Vector2;
  25670. /**
  25671. * 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
  25672. */
  25673. set boundingBias(value: Vector2);
  25674. /**
  25675. * Static function used to attach a new empty geometry to a mesh
  25676. * @param mesh defines the mesh to attach the geometry to
  25677. * @returns the new Geometry
  25678. */
  25679. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25680. /** Get the list of meshes using this geometry */
  25681. get meshes(): Mesh[];
  25682. /**
  25683. * 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
  25684. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  25685. */
  25686. useBoundingInfoFromGeometry: boolean;
  25687. /**
  25688. * Creates a new geometry
  25689. * @param id defines the unique ID
  25690. * @param scene defines the hosting scene
  25691. * @param vertexData defines the VertexData used to get geometry data
  25692. * @param updatable defines if geometry must be updatable (false by default)
  25693. * @param mesh defines the mesh that will be associated with the geometry
  25694. */
  25695. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25696. /**
  25697. * Gets the current extend of the geometry
  25698. */
  25699. get extend(): {
  25700. minimum: Vector3;
  25701. maximum: Vector3;
  25702. };
  25703. /**
  25704. * Gets the hosting scene
  25705. * @returns the hosting Scene
  25706. */
  25707. getScene(): Scene;
  25708. /**
  25709. * Gets the hosting engine
  25710. * @returns the hosting Engine
  25711. */
  25712. getEngine(): Engine;
  25713. /**
  25714. * Defines if the geometry is ready to use
  25715. * @returns true if the geometry is ready to be used
  25716. */
  25717. isReady(): boolean;
  25718. /**
  25719. * Gets a value indicating that the geometry should not be serialized
  25720. */
  25721. get doNotSerialize(): boolean;
  25722. /** @hidden */
  25723. _rebuild(): void;
  25724. /**
  25725. * Affects all geometry data in one call
  25726. * @param vertexData defines the geometry data
  25727. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25728. */
  25729. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25730. /**
  25731. * Set specific vertex data
  25732. * @param kind defines the data kind (Position, normal, etc...)
  25733. * @param data defines the vertex data to use
  25734. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25735. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25736. */
  25737. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25738. /**
  25739. * Removes a specific vertex data
  25740. * @param kind defines the data kind (Position, normal, etc...)
  25741. */
  25742. removeVerticesData(kind: string): void;
  25743. /**
  25744. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25745. * @param buffer defines the vertex buffer to use
  25746. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25747. */
  25748. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25749. /**
  25750. * Update a specific vertex buffer
  25751. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25752. * It will do nothing if the buffer is not updatable
  25753. * @param kind defines the data kind (Position, normal, etc...)
  25754. * @param data defines the data to use
  25755. * @param offset defines the offset in the target buffer where to store the data
  25756. * @param useBytes set to true if the offset is in bytes
  25757. */
  25758. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25759. /**
  25760. * Update a specific vertex buffer
  25761. * This function will create a new buffer if the current one is not updatable
  25762. * @param kind defines the data kind (Position, normal, etc...)
  25763. * @param data defines the data to use
  25764. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25765. */
  25766. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25767. private _updateBoundingInfo;
  25768. /** @hidden */
  25769. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25770. /**
  25771. * Gets total number of vertices
  25772. * @returns the total number of vertices
  25773. */
  25774. getTotalVertices(): number;
  25775. /**
  25776. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25777. * @param kind defines the data kind (Position, normal, etc...)
  25778. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25779. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25780. * @returns a float array containing vertex data
  25781. */
  25782. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25783. /**
  25784. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25785. * @param kind defines the data kind (Position, normal, etc...)
  25786. * @returns true if the vertex buffer with the specified kind is updatable
  25787. */
  25788. isVertexBufferUpdatable(kind: string): boolean;
  25789. /**
  25790. * Gets a specific vertex buffer
  25791. * @param kind defines the data kind (Position, normal, etc...)
  25792. * @returns a VertexBuffer
  25793. */
  25794. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25795. /**
  25796. * Returns all vertex buffers
  25797. * @return an object holding all vertex buffers indexed by kind
  25798. */
  25799. getVertexBuffers(): Nullable<{
  25800. [key: string]: VertexBuffer;
  25801. }>;
  25802. /**
  25803. * Gets a boolean indicating if specific vertex buffer is present
  25804. * @param kind defines the data kind (Position, normal, etc...)
  25805. * @returns true if data is present
  25806. */
  25807. isVerticesDataPresent(kind: string): boolean;
  25808. /**
  25809. * Gets a list of all attached data kinds (Position, normal, etc...)
  25810. * @returns a list of string containing all kinds
  25811. */
  25812. getVerticesDataKinds(): string[];
  25813. /**
  25814. * Update index buffer
  25815. * @param indices defines the indices to store in the index buffer
  25816. * @param offset defines the offset in the target buffer where to store the data
  25817. * @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)
  25818. */
  25819. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25820. /**
  25821. * Creates a new index buffer
  25822. * @param indices defines the indices to store in the index buffer
  25823. * @param totalVertices defines the total number of vertices (could be null)
  25824. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25825. */
  25826. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25827. /**
  25828. * Return the total number of indices
  25829. * @returns the total number of indices
  25830. */
  25831. getTotalIndices(): number;
  25832. /**
  25833. * Gets the index buffer array
  25834. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25835. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25836. * @returns the index buffer array
  25837. */
  25838. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25839. /**
  25840. * Gets the index buffer
  25841. * @return the index buffer
  25842. */
  25843. getIndexBuffer(): Nullable<DataBuffer>;
  25844. /** @hidden */
  25845. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25846. /**
  25847. * Release the associated resources for a specific mesh
  25848. * @param mesh defines the source mesh
  25849. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25850. */
  25851. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25852. /**
  25853. * Apply current geometry to a given mesh
  25854. * @param mesh defines the mesh to apply geometry to
  25855. */
  25856. applyToMesh(mesh: Mesh): void;
  25857. private _updateExtend;
  25858. private _applyToMesh;
  25859. private notifyUpdate;
  25860. /**
  25861. * Load the geometry if it was flagged as delay loaded
  25862. * @param scene defines the hosting scene
  25863. * @param onLoaded defines a callback called when the geometry is loaded
  25864. */
  25865. load(scene: Scene, onLoaded?: () => void): void;
  25866. private _queueLoad;
  25867. /**
  25868. * Invert the geometry to move from a right handed system to a left handed one.
  25869. */
  25870. toLeftHanded(): void;
  25871. /** @hidden */
  25872. _resetPointsArrayCache(): void;
  25873. /** @hidden */
  25874. _generatePointsArray(): boolean;
  25875. /**
  25876. * Gets a value indicating if the geometry is disposed
  25877. * @returns true if the geometry was disposed
  25878. */
  25879. isDisposed(): boolean;
  25880. private _disposeVertexArrayObjects;
  25881. /**
  25882. * Free all associated resources
  25883. */
  25884. dispose(): void;
  25885. /**
  25886. * Clone the current geometry into a new geometry
  25887. * @param id defines the unique ID of the new geometry
  25888. * @returns a new geometry object
  25889. */
  25890. copy(id: string): Geometry;
  25891. /**
  25892. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25893. * @return a JSON representation of the current geometry data (without the vertices data)
  25894. */
  25895. serialize(): any;
  25896. private toNumberArray;
  25897. /**
  25898. * Serialize all vertices data into a JSON oject
  25899. * @returns a JSON representation of the current geometry data
  25900. */
  25901. serializeVerticeData(): any;
  25902. /**
  25903. * Extracts a clone of a mesh geometry
  25904. * @param mesh defines the source mesh
  25905. * @param id defines the unique ID of the new geometry object
  25906. * @returns the new geometry object
  25907. */
  25908. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25909. /**
  25910. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25911. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25912. * Be aware Math.random() could cause collisions, but:
  25913. * "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"
  25914. * @returns a string containing a new GUID
  25915. */
  25916. static RandomId(): string;
  25917. /** @hidden */
  25918. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25919. private static _CleanMatricesWeights;
  25920. /**
  25921. * Create a new geometry from persisted data (Using .babylon file format)
  25922. * @param parsedVertexData defines the persisted data
  25923. * @param scene defines the hosting scene
  25924. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25925. * @returns the new geometry object
  25926. */
  25927. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25928. }
  25929. }
  25930. declare module BABYLON {
  25931. /**
  25932. * Define an interface for all classes that will get and set the data on vertices
  25933. */
  25934. export interface IGetSetVerticesData {
  25935. /**
  25936. * Gets a boolean indicating if specific vertex data is present
  25937. * @param kind defines the vertex data kind to use
  25938. * @returns true is data kind is present
  25939. */
  25940. isVerticesDataPresent(kind: string): boolean;
  25941. /**
  25942. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25943. * @param kind defines the data kind (Position, normal, etc...)
  25944. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25945. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25946. * @returns a float array containing vertex data
  25947. */
  25948. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25949. /**
  25950. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25951. * @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.
  25952. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25953. * @returns the indices array or an empty array if the mesh has no geometry
  25954. */
  25955. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25956. /**
  25957. * Set specific vertex data
  25958. * @param kind defines the data kind (Position, normal, etc...)
  25959. * @param data defines the vertex data to use
  25960. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25961. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25962. */
  25963. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25964. /**
  25965. * Update a specific associated vertex buffer
  25966. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25967. * - VertexBuffer.PositionKind
  25968. * - VertexBuffer.UVKind
  25969. * - VertexBuffer.UV2Kind
  25970. * - VertexBuffer.UV3Kind
  25971. * - VertexBuffer.UV4Kind
  25972. * - VertexBuffer.UV5Kind
  25973. * - VertexBuffer.UV6Kind
  25974. * - VertexBuffer.ColorKind
  25975. * - VertexBuffer.MatricesIndicesKind
  25976. * - VertexBuffer.MatricesIndicesExtraKind
  25977. * - VertexBuffer.MatricesWeightsKind
  25978. * - VertexBuffer.MatricesWeightsExtraKind
  25979. * @param data defines the data source
  25980. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25981. * @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)
  25982. */
  25983. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25984. /**
  25985. * Creates a new index buffer
  25986. * @param indices defines the indices to store in the index buffer
  25987. * @param totalVertices defines the total number of vertices (could be null)
  25988. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25989. */
  25990. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25991. }
  25992. /**
  25993. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25994. */
  25995. export class VertexData {
  25996. /**
  25997. * Mesh side orientation : usually the external or front surface
  25998. */
  25999. static readonly FRONTSIDE: number;
  26000. /**
  26001. * Mesh side orientation : usually the internal or back surface
  26002. */
  26003. static readonly BACKSIDE: number;
  26004. /**
  26005. * Mesh side orientation : both internal and external or front and back surfaces
  26006. */
  26007. static readonly DOUBLESIDE: number;
  26008. /**
  26009. * Mesh side orientation : by default, `FRONTSIDE`
  26010. */
  26011. static readonly DEFAULTSIDE: number;
  26012. /**
  26013. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26014. */
  26015. positions: Nullable<FloatArray>;
  26016. /**
  26017. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26018. */
  26019. normals: Nullable<FloatArray>;
  26020. /**
  26021. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26022. */
  26023. tangents: Nullable<FloatArray>;
  26024. /**
  26025. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26026. */
  26027. uvs: Nullable<FloatArray>;
  26028. /**
  26029. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26030. */
  26031. uvs2: Nullable<FloatArray>;
  26032. /**
  26033. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26034. */
  26035. uvs3: Nullable<FloatArray>;
  26036. /**
  26037. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26038. */
  26039. uvs4: Nullable<FloatArray>;
  26040. /**
  26041. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26042. */
  26043. uvs5: Nullable<FloatArray>;
  26044. /**
  26045. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26046. */
  26047. uvs6: Nullable<FloatArray>;
  26048. /**
  26049. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26050. */
  26051. colors: Nullable<FloatArray>;
  26052. /**
  26053. * 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).
  26054. */
  26055. matricesIndices: Nullable<FloatArray>;
  26056. /**
  26057. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26058. */
  26059. matricesWeights: Nullable<FloatArray>;
  26060. /**
  26061. * An array extending the number of possible indices
  26062. */
  26063. matricesIndicesExtra: Nullable<FloatArray>;
  26064. /**
  26065. * An array extending the number of possible weights when the number of indices is extended
  26066. */
  26067. matricesWeightsExtra: Nullable<FloatArray>;
  26068. /**
  26069. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26070. */
  26071. indices: Nullable<IndicesArray>;
  26072. /**
  26073. * Uses the passed data array to set the set the values for the specified kind of data
  26074. * @param data a linear array of floating numbers
  26075. * @param kind the type of data that is being set, eg positions, colors etc
  26076. */
  26077. set(data: FloatArray, kind: string): void;
  26078. /**
  26079. * Associates the vertexData to the passed Mesh.
  26080. * Sets it as updatable or not (default `false`)
  26081. * @param mesh the mesh the vertexData is applied to
  26082. * @param updatable when used and having the value true allows new data to update the vertexData
  26083. * @returns the VertexData
  26084. */
  26085. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26086. /**
  26087. * Associates the vertexData to the passed Geometry.
  26088. * Sets it as updatable or not (default `false`)
  26089. * @param geometry the geometry the vertexData is applied to
  26090. * @param updatable when used and having the value true allows new data to update the vertexData
  26091. * @returns VertexData
  26092. */
  26093. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26094. /**
  26095. * Updates the associated mesh
  26096. * @param mesh the mesh to be updated
  26097. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26098. * @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
  26099. * @returns VertexData
  26100. */
  26101. updateMesh(mesh: Mesh): VertexData;
  26102. /**
  26103. * Updates the associated geometry
  26104. * @param geometry the geometry to be updated
  26105. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26106. * @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
  26107. * @returns VertexData.
  26108. */
  26109. updateGeometry(geometry: Geometry): VertexData;
  26110. private _applyTo;
  26111. private _update;
  26112. /**
  26113. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26114. * @param matrix the transforming matrix
  26115. * @returns the VertexData
  26116. */
  26117. transform(matrix: Matrix): VertexData;
  26118. /**
  26119. * Merges the passed VertexData into the current one
  26120. * @param other the VertexData to be merged into the current one
  26121. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26122. * @returns the modified VertexData
  26123. */
  26124. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26125. private _mergeElement;
  26126. private _validate;
  26127. /**
  26128. * Serializes the VertexData
  26129. * @returns a serialized object
  26130. */
  26131. serialize(): any;
  26132. /**
  26133. * Extracts the vertexData from a mesh
  26134. * @param mesh the mesh from which to extract the VertexData
  26135. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26136. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26137. * @returns the object VertexData associated to the passed mesh
  26138. */
  26139. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26140. /**
  26141. * Extracts the vertexData from the geometry
  26142. * @param geometry the geometry from which to extract the VertexData
  26143. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26144. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26145. * @returns the object VertexData associated to the passed mesh
  26146. */
  26147. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26148. private static _ExtractFrom;
  26149. /**
  26150. * Creates the VertexData for a Ribbon
  26151. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26152. * * pathArray array of paths, each of which an array of successive Vector3
  26153. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26154. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26155. * * 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
  26156. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26157. * * 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)
  26158. * * 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)
  26159. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26160. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26161. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26162. * @returns the VertexData of the ribbon
  26163. */
  26164. static CreateRibbon(options: {
  26165. pathArray: Vector3[][];
  26166. closeArray?: boolean;
  26167. closePath?: boolean;
  26168. offset?: number;
  26169. sideOrientation?: number;
  26170. frontUVs?: Vector4;
  26171. backUVs?: Vector4;
  26172. invertUV?: boolean;
  26173. uvs?: Vector2[];
  26174. colors?: Color4[];
  26175. }): VertexData;
  26176. /**
  26177. * Creates the VertexData for a box
  26178. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26179. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26180. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26181. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26182. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26183. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26184. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26185. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26186. * * 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)
  26187. * * 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)
  26188. * @returns the VertexData of the box
  26189. */
  26190. static CreateBox(options: {
  26191. size?: number;
  26192. width?: number;
  26193. height?: number;
  26194. depth?: number;
  26195. faceUV?: Vector4[];
  26196. faceColors?: Color4[];
  26197. sideOrientation?: number;
  26198. frontUVs?: Vector4;
  26199. backUVs?: Vector4;
  26200. }): VertexData;
  26201. /**
  26202. * Creates the VertexData for a tiled box
  26203. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26204. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26205. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26206. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26207. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26208. * @returns the VertexData of the box
  26209. */
  26210. static CreateTiledBox(options: {
  26211. pattern?: number;
  26212. width?: number;
  26213. height?: number;
  26214. depth?: number;
  26215. tileSize?: number;
  26216. tileWidth?: number;
  26217. tileHeight?: number;
  26218. alignHorizontal?: number;
  26219. alignVertical?: number;
  26220. faceUV?: Vector4[];
  26221. faceColors?: Color4[];
  26222. sideOrientation?: number;
  26223. }): VertexData;
  26224. /**
  26225. * Creates the VertexData for a tiled plane
  26226. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26227. * * pattern a limited pattern arrangement depending on the number
  26228. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26229. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26230. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26231. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26232. * * 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)
  26233. * * 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)
  26234. * @returns the VertexData of the tiled plane
  26235. */
  26236. static CreateTiledPlane(options: {
  26237. pattern?: number;
  26238. tileSize?: number;
  26239. tileWidth?: number;
  26240. tileHeight?: number;
  26241. size?: number;
  26242. width?: number;
  26243. height?: number;
  26244. alignHorizontal?: number;
  26245. alignVertical?: number;
  26246. sideOrientation?: number;
  26247. frontUVs?: Vector4;
  26248. backUVs?: Vector4;
  26249. }): VertexData;
  26250. /**
  26251. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26252. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26253. * * segments sets the number of horizontal strips optional, default 32
  26254. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26255. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26256. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26257. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26258. * * 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
  26259. * * 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
  26260. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26261. * * 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)
  26262. * * 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)
  26263. * @returns the VertexData of the ellipsoid
  26264. */
  26265. static CreateSphere(options: {
  26266. segments?: number;
  26267. diameter?: number;
  26268. diameterX?: number;
  26269. diameterY?: number;
  26270. diameterZ?: number;
  26271. arc?: number;
  26272. slice?: number;
  26273. sideOrientation?: number;
  26274. frontUVs?: Vector4;
  26275. backUVs?: Vector4;
  26276. }): VertexData;
  26277. /**
  26278. * Creates the VertexData for a cylinder, cone or prism
  26279. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26280. * * height sets the height (y direction) of the cylinder, optional, default 2
  26281. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26282. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26283. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26284. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26285. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26286. * * 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
  26287. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26288. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26289. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26290. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26291. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26292. * * 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)
  26293. * * 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)
  26294. * @returns the VertexData of the cylinder, cone or prism
  26295. */
  26296. static CreateCylinder(options: {
  26297. height?: number;
  26298. diameterTop?: number;
  26299. diameterBottom?: number;
  26300. diameter?: number;
  26301. tessellation?: number;
  26302. subdivisions?: number;
  26303. arc?: number;
  26304. faceColors?: Color4[];
  26305. faceUV?: Vector4[];
  26306. hasRings?: boolean;
  26307. enclose?: boolean;
  26308. sideOrientation?: number;
  26309. frontUVs?: Vector4;
  26310. backUVs?: Vector4;
  26311. }): VertexData;
  26312. /**
  26313. * Creates the VertexData for a torus
  26314. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26315. * * diameter the diameter of the torus, optional default 1
  26316. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26317. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26318. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26319. * * 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)
  26320. * * 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)
  26321. * @returns the VertexData of the torus
  26322. */
  26323. static CreateTorus(options: {
  26324. diameter?: number;
  26325. thickness?: number;
  26326. tessellation?: number;
  26327. sideOrientation?: number;
  26328. frontUVs?: Vector4;
  26329. backUVs?: Vector4;
  26330. }): VertexData;
  26331. /**
  26332. * Creates the VertexData of the LineSystem
  26333. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26334. * - lines an array of lines, each line being an array of successive Vector3
  26335. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26336. * @returns the VertexData of the LineSystem
  26337. */
  26338. static CreateLineSystem(options: {
  26339. lines: Vector3[][];
  26340. colors?: Nullable<Color4[][]>;
  26341. }): VertexData;
  26342. /**
  26343. * Create the VertexData for a DashedLines
  26344. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26345. * - points an array successive Vector3
  26346. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26347. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26348. * - dashNb the intended total number of dashes, optional, default 200
  26349. * @returns the VertexData for the DashedLines
  26350. */
  26351. static CreateDashedLines(options: {
  26352. points: Vector3[];
  26353. dashSize?: number;
  26354. gapSize?: number;
  26355. dashNb?: number;
  26356. }): VertexData;
  26357. /**
  26358. * Creates the VertexData for a Ground
  26359. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26360. * - width the width (x direction) of the ground, optional, default 1
  26361. * - height the height (z direction) of the ground, optional, default 1
  26362. * - subdivisions the number of subdivisions per side, optional, default 1
  26363. * @returns the VertexData of the Ground
  26364. */
  26365. static CreateGround(options: {
  26366. width?: number;
  26367. height?: number;
  26368. subdivisions?: number;
  26369. subdivisionsX?: number;
  26370. subdivisionsY?: number;
  26371. }): VertexData;
  26372. /**
  26373. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26374. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26375. * * xmin the ground minimum X coordinate, optional, default -1
  26376. * * zmin the ground minimum Z coordinate, optional, default -1
  26377. * * xmax the ground maximum X coordinate, optional, default 1
  26378. * * zmax the ground maximum Z coordinate, optional, default 1
  26379. * * 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}
  26380. * * 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}
  26381. * @returns the VertexData of the TiledGround
  26382. */
  26383. static CreateTiledGround(options: {
  26384. xmin: number;
  26385. zmin: number;
  26386. xmax: number;
  26387. zmax: number;
  26388. subdivisions?: {
  26389. w: number;
  26390. h: number;
  26391. };
  26392. precision?: {
  26393. w: number;
  26394. h: number;
  26395. };
  26396. }): VertexData;
  26397. /**
  26398. * Creates the VertexData of the Ground designed from a heightmap
  26399. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26400. * * width the width (x direction) of the ground
  26401. * * height the height (z direction) of the ground
  26402. * * subdivisions the number of subdivisions per side
  26403. * * minHeight the minimum altitude on the ground, optional, default 0
  26404. * * maxHeight the maximum altitude on the ground, optional default 1
  26405. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26406. * * buffer the array holding the image color data
  26407. * * bufferWidth the width of image
  26408. * * bufferHeight the height of image
  26409. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26410. * @returns the VertexData of the Ground designed from a heightmap
  26411. */
  26412. static CreateGroundFromHeightMap(options: {
  26413. width: number;
  26414. height: number;
  26415. subdivisions: number;
  26416. minHeight: number;
  26417. maxHeight: number;
  26418. colorFilter: Color3;
  26419. buffer: Uint8Array;
  26420. bufferWidth: number;
  26421. bufferHeight: number;
  26422. alphaFilter: number;
  26423. }): VertexData;
  26424. /**
  26425. * Creates the VertexData for a Plane
  26426. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26427. * * size sets the width and height of the plane to the value of size, optional default 1
  26428. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26429. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26430. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26431. * * 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)
  26432. * * 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)
  26433. * @returns the VertexData of the box
  26434. */
  26435. static CreatePlane(options: {
  26436. size?: number;
  26437. width?: number;
  26438. height?: number;
  26439. sideOrientation?: number;
  26440. frontUVs?: Vector4;
  26441. backUVs?: Vector4;
  26442. }): VertexData;
  26443. /**
  26444. * Creates the VertexData of the Disc or regular Polygon
  26445. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26446. * * radius the radius of the disc, optional default 0.5
  26447. * * tessellation the number of polygon sides, optional, default 64
  26448. * * 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
  26449. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26450. * * 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)
  26451. * * 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)
  26452. * @returns the VertexData of the box
  26453. */
  26454. static CreateDisc(options: {
  26455. radius?: number;
  26456. tessellation?: number;
  26457. arc?: number;
  26458. sideOrientation?: number;
  26459. frontUVs?: Vector4;
  26460. backUVs?: Vector4;
  26461. }): VertexData;
  26462. /**
  26463. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26464. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26465. * @param polygon a mesh built from polygonTriangulation.build()
  26466. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26467. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26468. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26469. * @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)
  26470. * @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)
  26471. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26472. * @returns the VertexData of the Polygon
  26473. */
  26474. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26475. /**
  26476. * Creates the VertexData of the IcoSphere
  26477. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26478. * * radius the radius of the IcoSphere, optional default 1
  26479. * * radiusX allows stretching in the x direction, optional, default radius
  26480. * * radiusY allows stretching in the y direction, optional, default radius
  26481. * * radiusZ allows stretching in the z direction, optional, default radius
  26482. * * flat when true creates a flat shaded mesh, optional, default true
  26483. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26484. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26485. * * 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)
  26486. * * 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)
  26487. * @returns the VertexData of the IcoSphere
  26488. */
  26489. static CreateIcoSphere(options: {
  26490. radius?: number;
  26491. radiusX?: number;
  26492. radiusY?: number;
  26493. radiusZ?: number;
  26494. flat?: boolean;
  26495. subdivisions?: number;
  26496. sideOrientation?: number;
  26497. frontUVs?: Vector4;
  26498. backUVs?: Vector4;
  26499. }): VertexData;
  26500. /**
  26501. * Creates the VertexData for a Polyhedron
  26502. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26503. * * type provided types are:
  26504. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26505. * * 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)
  26506. * * size the size of the IcoSphere, optional default 1
  26507. * * sizeX allows stretching in the x direction, optional, default size
  26508. * * sizeY allows stretching in the y direction, optional, default size
  26509. * * sizeZ allows stretching in the z direction, optional, default size
  26510. * * 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
  26511. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26512. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26513. * * flat when true creates a flat shaded mesh, optional, default true
  26514. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26515. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26516. * * 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)
  26517. * * 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)
  26518. * @returns the VertexData of the Polyhedron
  26519. */
  26520. static CreatePolyhedron(options: {
  26521. type?: number;
  26522. size?: number;
  26523. sizeX?: number;
  26524. sizeY?: number;
  26525. sizeZ?: number;
  26526. custom?: any;
  26527. faceUV?: Vector4[];
  26528. faceColors?: Color4[];
  26529. flat?: boolean;
  26530. sideOrientation?: number;
  26531. frontUVs?: Vector4;
  26532. backUVs?: Vector4;
  26533. }): VertexData;
  26534. /**
  26535. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  26536. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  26537. * @returns the VertexData of the Capsule
  26538. */
  26539. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  26540. /**
  26541. * Creates the VertexData for a TorusKnot
  26542. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26543. * * radius the radius of the torus knot, optional, default 2
  26544. * * tube the thickness of the tube, optional, default 0.5
  26545. * * radialSegments the number of sides on each tube segments, optional, default 32
  26546. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26547. * * p the number of windings around the z axis, optional, default 2
  26548. * * q the number of windings around the x axis, optional, default 3
  26549. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26550. * * 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)
  26551. * * 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)
  26552. * @returns the VertexData of the Torus Knot
  26553. */
  26554. static CreateTorusKnot(options: {
  26555. radius?: number;
  26556. tube?: number;
  26557. radialSegments?: number;
  26558. tubularSegments?: number;
  26559. p?: number;
  26560. q?: number;
  26561. sideOrientation?: number;
  26562. frontUVs?: Vector4;
  26563. backUVs?: Vector4;
  26564. }): VertexData;
  26565. /**
  26566. * Compute normals for given positions and indices
  26567. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26568. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26569. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26570. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26571. * * facetNormals : optional array of facet normals (vector3)
  26572. * * facetPositions : optional array of facet positions (vector3)
  26573. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26574. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26575. * * bInfo : optional bounding info, required for facetPartitioning computation
  26576. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26577. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26578. * * useRightHandedSystem: optional boolean to for right handed system computation
  26579. * * depthSort : optional boolean to enable the facet depth sort computation
  26580. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26581. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26582. */
  26583. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26584. facetNormals?: any;
  26585. facetPositions?: any;
  26586. facetPartitioning?: any;
  26587. ratio?: number;
  26588. bInfo?: any;
  26589. bbSize?: Vector3;
  26590. subDiv?: any;
  26591. useRightHandedSystem?: boolean;
  26592. depthSort?: boolean;
  26593. distanceTo?: Vector3;
  26594. depthSortedFacets?: any;
  26595. }): void;
  26596. /** @hidden */
  26597. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26598. /**
  26599. * Applies VertexData created from the imported parameters to the geometry
  26600. * @param parsedVertexData the parsed data from an imported file
  26601. * @param geometry the geometry to apply the VertexData to
  26602. */
  26603. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26604. }
  26605. }
  26606. declare module BABYLON {
  26607. /**
  26608. * Defines a target to use with MorphTargetManager
  26609. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26610. */
  26611. export class MorphTarget implements IAnimatable {
  26612. /** defines the name of the target */
  26613. name: string;
  26614. /**
  26615. * Gets or sets the list of animations
  26616. */
  26617. animations: Animation[];
  26618. private _scene;
  26619. private _positions;
  26620. private _normals;
  26621. private _tangents;
  26622. private _uvs;
  26623. private _influence;
  26624. private _uniqueId;
  26625. /**
  26626. * Observable raised when the influence changes
  26627. */
  26628. onInfluenceChanged: Observable<boolean>;
  26629. /** @hidden */
  26630. _onDataLayoutChanged: Observable<void>;
  26631. /**
  26632. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26633. */
  26634. get influence(): number;
  26635. set influence(influence: number);
  26636. /**
  26637. * Gets or sets the id of the morph Target
  26638. */
  26639. id: string;
  26640. private _animationPropertiesOverride;
  26641. /**
  26642. * Gets or sets the animation properties override
  26643. */
  26644. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26645. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26646. /**
  26647. * Creates a new MorphTarget
  26648. * @param name defines the name of the target
  26649. * @param influence defines the influence to use
  26650. * @param scene defines the scene the morphtarget belongs to
  26651. */
  26652. constructor(
  26653. /** defines the name of the target */
  26654. name: string, influence?: number, scene?: Nullable<Scene>);
  26655. /**
  26656. * Gets the unique ID of this manager
  26657. */
  26658. get uniqueId(): number;
  26659. /**
  26660. * Gets a boolean defining if the target contains position data
  26661. */
  26662. get hasPositions(): boolean;
  26663. /**
  26664. * Gets a boolean defining if the target contains normal data
  26665. */
  26666. get hasNormals(): boolean;
  26667. /**
  26668. * Gets a boolean defining if the target contains tangent data
  26669. */
  26670. get hasTangents(): boolean;
  26671. /**
  26672. * Gets a boolean defining if the target contains texture coordinates data
  26673. */
  26674. get hasUVs(): boolean;
  26675. /**
  26676. * Affects position data to this target
  26677. * @param data defines the position data to use
  26678. */
  26679. setPositions(data: Nullable<FloatArray>): void;
  26680. /**
  26681. * Gets the position data stored in this target
  26682. * @returns a FloatArray containing the position data (or null if not present)
  26683. */
  26684. getPositions(): Nullable<FloatArray>;
  26685. /**
  26686. * Affects normal data to this target
  26687. * @param data defines the normal data to use
  26688. */
  26689. setNormals(data: Nullable<FloatArray>): void;
  26690. /**
  26691. * Gets the normal data stored in this target
  26692. * @returns a FloatArray containing the normal data (or null if not present)
  26693. */
  26694. getNormals(): Nullable<FloatArray>;
  26695. /**
  26696. * Affects tangent data to this target
  26697. * @param data defines the tangent data to use
  26698. */
  26699. setTangents(data: Nullable<FloatArray>): void;
  26700. /**
  26701. * Gets the tangent data stored in this target
  26702. * @returns a FloatArray containing the tangent data (or null if not present)
  26703. */
  26704. getTangents(): Nullable<FloatArray>;
  26705. /**
  26706. * Affects texture coordinates data to this target
  26707. * @param data defines the texture coordinates data to use
  26708. */
  26709. setUVs(data: Nullable<FloatArray>): void;
  26710. /**
  26711. * Gets the texture coordinates data stored in this target
  26712. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26713. */
  26714. getUVs(): Nullable<FloatArray>;
  26715. /**
  26716. * Clone the current target
  26717. * @returns a new MorphTarget
  26718. */
  26719. clone(): MorphTarget;
  26720. /**
  26721. * Serializes the current target into a Serialization object
  26722. * @returns the serialized object
  26723. */
  26724. serialize(): any;
  26725. /**
  26726. * Returns the string "MorphTarget"
  26727. * @returns "MorphTarget"
  26728. */
  26729. getClassName(): string;
  26730. /**
  26731. * Creates a new target from serialized data
  26732. * @param serializationObject defines the serialized data to use
  26733. * @returns a new MorphTarget
  26734. */
  26735. static Parse(serializationObject: any): MorphTarget;
  26736. /**
  26737. * Creates a MorphTarget from mesh data
  26738. * @param mesh defines the source mesh
  26739. * @param name defines the name to use for the new target
  26740. * @param influence defines the influence to attach to the target
  26741. * @returns a new MorphTarget
  26742. */
  26743. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26744. }
  26745. }
  26746. declare module BABYLON {
  26747. /**
  26748. * This class is used to deform meshes using morphing between different targets
  26749. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26750. */
  26751. export class MorphTargetManager {
  26752. private _targets;
  26753. private _targetInfluenceChangedObservers;
  26754. private _targetDataLayoutChangedObservers;
  26755. private _activeTargets;
  26756. private _scene;
  26757. private _influences;
  26758. private _supportsNormals;
  26759. private _supportsTangents;
  26760. private _supportsUVs;
  26761. private _vertexCount;
  26762. private _uniqueId;
  26763. private _tempInfluences;
  26764. /**
  26765. * Gets or sets a boolean indicating if normals must be morphed
  26766. */
  26767. enableNormalMorphing: boolean;
  26768. /**
  26769. * Gets or sets a boolean indicating if tangents must be morphed
  26770. */
  26771. enableTangentMorphing: boolean;
  26772. /**
  26773. * Gets or sets a boolean indicating if UV must be morphed
  26774. */
  26775. enableUVMorphing: boolean;
  26776. /**
  26777. * Creates a new MorphTargetManager
  26778. * @param scene defines the current scene
  26779. */
  26780. constructor(scene?: Nullable<Scene>);
  26781. /**
  26782. * Gets the unique ID of this manager
  26783. */
  26784. get uniqueId(): number;
  26785. /**
  26786. * Gets the number of vertices handled by this manager
  26787. */
  26788. get vertexCount(): number;
  26789. /**
  26790. * Gets a boolean indicating if this manager supports morphing of normals
  26791. */
  26792. get supportsNormals(): boolean;
  26793. /**
  26794. * Gets a boolean indicating if this manager supports morphing of tangents
  26795. */
  26796. get supportsTangents(): boolean;
  26797. /**
  26798. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26799. */
  26800. get supportsUVs(): boolean;
  26801. /**
  26802. * Gets the number of targets stored in this manager
  26803. */
  26804. get numTargets(): number;
  26805. /**
  26806. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26807. */
  26808. get numInfluencers(): number;
  26809. /**
  26810. * Gets the list of influences (one per target)
  26811. */
  26812. get influences(): Float32Array;
  26813. /**
  26814. * Gets the active target at specified index. An active target is a target with an influence > 0
  26815. * @param index defines the index to check
  26816. * @returns the requested target
  26817. */
  26818. getActiveTarget(index: number): MorphTarget;
  26819. /**
  26820. * Gets the target at specified index
  26821. * @param index defines the index to check
  26822. * @returns the requested target
  26823. */
  26824. getTarget(index: number): MorphTarget;
  26825. /**
  26826. * Add a new target to this manager
  26827. * @param target defines the target to add
  26828. */
  26829. addTarget(target: MorphTarget): void;
  26830. /**
  26831. * Removes a target from the manager
  26832. * @param target defines the target to remove
  26833. */
  26834. removeTarget(target: MorphTarget): void;
  26835. /**
  26836. * Clone the current manager
  26837. * @returns a new MorphTargetManager
  26838. */
  26839. clone(): MorphTargetManager;
  26840. /**
  26841. * Serializes the current manager into a Serialization object
  26842. * @returns the serialized object
  26843. */
  26844. serialize(): any;
  26845. private _syncActiveTargets;
  26846. /**
  26847. * Syncrhonize the targets with all the meshes using this morph target manager
  26848. */
  26849. synchronize(): void;
  26850. /**
  26851. * Creates a new MorphTargetManager from serialized data
  26852. * @param serializationObject defines the serialized data
  26853. * @param scene defines the hosting scene
  26854. * @returns the new MorphTargetManager
  26855. */
  26856. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26857. }
  26858. }
  26859. declare module BABYLON {
  26860. /**
  26861. * Class used to represent a specific level of detail of a mesh
  26862. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26863. */
  26864. export class MeshLODLevel {
  26865. /** Defines the distance where this level should start being displayed */
  26866. distance: number;
  26867. /** Defines the mesh to use to render this level */
  26868. mesh: Nullable<Mesh>;
  26869. /**
  26870. * Creates a new LOD level
  26871. * @param distance defines the distance where this level should star being displayed
  26872. * @param mesh defines the mesh to use to render this level
  26873. */
  26874. constructor(
  26875. /** Defines the distance where this level should start being displayed */
  26876. distance: number,
  26877. /** Defines the mesh to use to render this level */
  26878. mesh: Nullable<Mesh>);
  26879. }
  26880. }
  26881. declare module BABYLON {
  26882. /**
  26883. * Helper class used to generate a canvas to manipulate images
  26884. */
  26885. export class CanvasGenerator {
  26886. /**
  26887. * Create a new canvas (or offscreen canvas depending on the context)
  26888. * @param width defines the expected width
  26889. * @param height defines the expected height
  26890. * @return a new canvas or offscreen canvas
  26891. */
  26892. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26893. }
  26894. }
  26895. declare module BABYLON {
  26896. /**
  26897. * Mesh representing the gorund
  26898. */
  26899. export class GroundMesh extends Mesh {
  26900. /** If octree should be generated */
  26901. generateOctree: boolean;
  26902. private _heightQuads;
  26903. /** @hidden */
  26904. _subdivisionsX: number;
  26905. /** @hidden */
  26906. _subdivisionsY: number;
  26907. /** @hidden */
  26908. _width: number;
  26909. /** @hidden */
  26910. _height: number;
  26911. /** @hidden */
  26912. _minX: number;
  26913. /** @hidden */
  26914. _maxX: number;
  26915. /** @hidden */
  26916. _minZ: number;
  26917. /** @hidden */
  26918. _maxZ: number;
  26919. constructor(name: string, scene: Scene);
  26920. /**
  26921. * "GroundMesh"
  26922. * @returns "GroundMesh"
  26923. */
  26924. getClassName(): string;
  26925. /**
  26926. * The minimum of x and y subdivisions
  26927. */
  26928. get subdivisions(): number;
  26929. /**
  26930. * X subdivisions
  26931. */
  26932. get subdivisionsX(): number;
  26933. /**
  26934. * Y subdivisions
  26935. */
  26936. get subdivisionsY(): number;
  26937. /**
  26938. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26939. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26940. * @param chunksCount the number of subdivisions for x and y
  26941. * @param octreeBlocksSize (Default: 32)
  26942. */
  26943. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26944. /**
  26945. * Returns a height (y) value in the Worl system :
  26946. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26947. * @param x x coordinate
  26948. * @param z z coordinate
  26949. * @returns the ground y position if (x, z) are outside the ground surface.
  26950. */
  26951. getHeightAtCoordinates(x: number, z: number): number;
  26952. /**
  26953. * Returns a normalized vector (Vector3) orthogonal to the ground
  26954. * at the ground coordinates (x, z) expressed in the World system.
  26955. * @param x x coordinate
  26956. * @param z z coordinate
  26957. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26958. */
  26959. getNormalAtCoordinates(x: number, z: number): Vector3;
  26960. /**
  26961. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26962. * at the ground coordinates (x, z) expressed in the World system.
  26963. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26964. * @param x x coordinate
  26965. * @param z z coordinate
  26966. * @param ref vector to store the result
  26967. * @returns the GroundMesh.
  26968. */
  26969. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26970. /**
  26971. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26972. * if the ground has been updated.
  26973. * This can be used in the render loop.
  26974. * @returns the GroundMesh.
  26975. */
  26976. updateCoordinateHeights(): GroundMesh;
  26977. private _getFacetAt;
  26978. private _initHeightQuads;
  26979. private _computeHeightQuads;
  26980. /**
  26981. * Serializes this ground mesh
  26982. * @param serializationObject object to write serialization to
  26983. */
  26984. serialize(serializationObject: any): void;
  26985. /**
  26986. * Parses a serialized ground mesh
  26987. * @param parsedMesh the serialized mesh
  26988. * @param scene the scene to create the ground mesh in
  26989. * @returns the created ground mesh
  26990. */
  26991. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26992. }
  26993. }
  26994. declare module BABYLON {
  26995. /**
  26996. * Interface for Physics-Joint data
  26997. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26998. */
  26999. export interface PhysicsJointData {
  27000. /**
  27001. * The main pivot of the joint
  27002. */
  27003. mainPivot?: Vector3;
  27004. /**
  27005. * The connected pivot of the joint
  27006. */
  27007. connectedPivot?: Vector3;
  27008. /**
  27009. * The main axis of the joint
  27010. */
  27011. mainAxis?: Vector3;
  27012. /**
  27013. * The connected axis of the joint
  27014. */
  27015. connectedAxis?: Vector3;
  27016. /**
  27017. * The collision of the joint
  27018. */
  27019. collision?: boolean;
  27020. /**
  27021. * Native Oimo/Cannon/Energy data
  27022. */
  27023. nativeParams?: any;
  27024. }
  27025. /**
  27026. * This is a holder class for the physics joint created by the physics plugin
  27027. * It holds a set of functions to control the underlying joint
  27028. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27029. */
  27030. export class PhysicsJoint {
  27031. /**
  27032. * The type of the physics joint
  27033. */
  27034. type: number;
  27035. /**
  27036. * The data for the physics joint
  27037. */
  27038. jointData: PhysicsJointData;
  27039. private _physicsJoint;
  27040. protected _physicsPlugin: IPhysicsEnginePlugin;
  27041. /**
  27042. * Initializes the physics joint
  27043. * @param type The type of the physics joint
  27044. * @param jointData The data for the physics joint
  27045. */
  27046. constructor(
  27047. /**
  27048. * The type of the physics joint
  27049. */
  27050. type: number,
  27051. /**
  27052. * The data for the physics joint
  27053. */
  27054. jointData: PhysicsJointData);
  27055. /**
  27056. * Gets the physics joint
  27057. */
  27058. get physicsJoint(): any;
  27059. /**
  27060. * Sets the physics joint
  27061. */
  27062. set physicsJoint(newJoint: any);
  27063. /**
  27064. * Sets the physics plugin
  27065. */
  27066. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  27067. /**
  27068. * Execute a function that is physics-plugin specific.
  27069. * @param {Function} func the function that will be executed.
  27070. * It accepts two parameters: the physics world and the physics joint
  27071. */
  27072. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27073. /**
  27074. * Distance-Joint type
  27075. */
  27076. static DistanceJoint: number;
  27077. /**
  27078. * Hinge-Joint type
  27079. */
  27080. static HingeJoint: number;
  27081. /**
  27082. * Ball-and-Socket joint type
  27083. */
  27084. static BallAndSocketJoint: number;
  27085. /**
  27086. * Wheel-Joint type
  27087. */
  27088. static WheelJoint: number;
  27089. /**
  27090. * Slider-Joint type
  27091. */
  27092. static SliderJoint: number;
  27093. /**
  27094. * Prismatic-Joint type
  27095. */
  27096. static PrismaticJoint: number;
  27097. /**
  27098. * Universal-Joint type
  27099. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27100. */
  27101. static UniversalJoint: number;
  27102. /**
  27103. * Hinge-Joint 2 type
  27104. */
  27105. static Hinge2Joint: number;
  27106. /**
  27107. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27108. */
  27109. static PointToPointJoint: number;
  27110. /**
  27111. * Spring-Joint type
  27112. */
  27113. static SpringJoint: number;
  27114. /**
  27115. * Lock-Joint type
  27116. */
  27117. static LockJoint: number;
  27118. }
  27119. /**
  27120. * A class representing a physics distance joint
  27121. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27122. */
  27123. export class DistanceJoint extends PhysicsJoint {
  27124. /**
  27125. *
  27126. * @param jointData The data for the Distance-Joint
  27127. */
  27128. constructor(jointData: DistanceJointData);
  27129. /**
  27130. * Update the predefined distance.
  27131. * @param maxDistance The maximum preferred distance
  27132. * @param minDistance The minimum preferred distance
  27133. */
  27134. updateDistance(maxDistance: number, minDistance?: number): void;
  27135. }
  27136. /**
  27137. * Represents a Motor-Enabled Joint
  27138. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27139. */
  27140. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27141. /**
  27142. * Initializes the Motor-Enabled Joint
  27143. * @param type The type of the joint
  27144. * @param jointData The physica joint data for the joint
  27145. */
  27146. constructor(type: number, jointData: PhysicsJointData);
  27147. /**
  27148. * Set the motor values.
  27149. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27150. * @param force the force to apply
  27151. * @param maxForce max force for this motor.
  27152. */
  27153. setMotor(force?: number, maxForce?: number): void;
  27154. /**
  27155. * Set the motor's limits.
  27156. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27157. * @param upperLimit The upper limit of the motor
  27158. * @param lowerLimit The lower limit of the motor
  27159. */
  27160. setLimit(upperLimit: number, lowerLimit?: number): void;
  27161. }
  27162. /**
  27163. * This class represents a single physics Hinge-Joint
  27164. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27165. */
  27166. export class HingeJoint extends MotorEnabledJoint {
  27167. /**
  27168. * Initializes the Hinge-Joint
  27169. * @param jointData The joint data for the Hinge-Joint
  27170. */
  27171. constructor(jointData: PhysicsJointData);
  27172. /**
  27173. * Set the motor values.
  27174. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27175. * @param {number} force the force to apply
  27176. * @param {number} maxForce max force for this motor.
  27177. */
  27178. setMotor(force?: number, maxForce?: number): void;
  27179. /**
  27180. * Set the motor's limits.
  27181. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27182. * @param upperLimit The upper limit of the motor
  27183. * @param lowerLimit The lower limit of the motor
  27184. */
  27185. setLimit(upperLimit: number, lowerLimit?: number): void;
  27186. }
  27187. /**
  27188. * This class represents a dual hinge physics joint (same as wheel joint)
  27189. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27190. */
  27191. export class Hinge2Joint extends MotorEnabledJoint {
  27192. /**
  27193. * Initializes the Hinge2-Joint
  27194. * @param jointData The joint data for the Hinge2-Joint
  27195. */
  27196. constructor(jointData: PhysicsJointData);
  27197. /**
  27198. * Set the motor values.
  27199. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27200. * @param {number} targetSpeed the speed the motor is to reach
  27201. * @param {number} maxForce max force for this motor.
  27202. * @param {motorIndex} the motor's index, 0 or 1.
  27203. */
  27204. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27205. /**
  27206. * Set the motor limits.
  27207. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27208. * @param {number} upperLimit the upper limit
  27209. * @param {number} lowerLimit lower limit
  27210. * @param {motorIndex} the motor's index, 0 or 1.
  27211. */
  27212. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27213. }
  27214. /**
  27215. * Interface for a motor enabled joint
  27216. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27217. */
  27218. export interface IMotorEnabledJoint {
  27219. /**
  27220. * Physics joint
  27221. */
  27222. physicsJoint: any;
  27223. /**
  27224. * Sets the motor of the motor-enabled joint
  27225. * @param force The force of the motor
  27226. * @param maxForce The maximum force of the motor
  27227. * @param motorIndex The index of the motor
  27228. */
  27229. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27230. /**
  27231. * Sets the limit of the motor
  27232. * @param upperLimit The upper limit of the motor
  27233. * @param lowerLimit The lower limit of the motor
  27234. * @param motorIndex The index of the motor
  27235. */
  27236. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27237. }
  27238. /**
  27239. * Joint data for a Distance-Joint
  27240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27241. */
  27242. export interface DistanceJointData extends PhysicsJointData {
  27243. /**
  27244. * Max distance the 2 joint objects can be apart
  27245. */
  27246. maxDistance: number;
  27247. }
  27248. /**
  27249. * Joint data from a spring joint
  27250. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27251. */
  27252. export interface SpringJointData extends PhysicsJointData {
  27253. /**
  27254. * Length of the spring
  27255. */
  27256. length: number;
  27257. /**
  27258. * Stiffness of the spring
  27259. */
  27260. stiffness: number;
  27261. /**
  27262. * Damping of the spring
  27263. */
  27264. damping: number;
  27265. /** this callback will be called when applying the force to the impostors. */
  27266. forceApplicationCallback: () => void;
  27267. }
  27268. }
  27269. declare module BABYLON {
  27270. /**
  27271. * Holds the data for the raycast result
  27272. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27273. */
  27274. export class PhysicsRaycastResult {
  27275. private _hasHit;
  27276. private _hitDistance;
  27277. private _hitNormalWorld;
  27278. private _hitPointWorld;
  27279. private _rayFromWorld;
  27280. private _rayToWorld;
  27281. /**
  27282. * Gets if there was a hit
  27283. */
  27284. get hasHit(): boolean;
  27285. /**
  27286. * Gets the distance from the hit
  27287. */
  27288. get hitDistance(): number;
  27289. /**
  27290. * Gets the hit normal/direction in the world
  27291. */
  27292. get hitNormalWorld(): Vector3;
  27293. /**
  27294. * Gets the hit point in the world
  27295. */
  27296. get hitPointWorld(): Vector3;
  27297. /**
  27298. * Gets the ray "start point" of the ray in the world
  27299. */
  27300. get rayFromWorld(): Vector3;
  27301. /**
  27302. * Gets the ray "end point" of the ray in the world
  27303. */
  27304. get rayToWorld(): Vector3;
  27305. /**
  27306. * Sets the hit data (normal & point in world space)
  27307. * @param hitNormalWorld defines the normal in world space
  27308. * @param hitPointWorld defines the point in world space
  27309. */
  27310. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27311. /**
  27312. * Sets the distance from the start point to the hit point
  27313. * @param distance
  27314. */
  27315. setHitDistance(distance: number): void;
  27316. /**
  27317. * Calculates the distance manually
  27318. */
  27319. calculateHitDistance(): void;
  27320. /**
  27321. * Resets all the values to default
  27322. * @param from The from point on world space
  27323. * @param to The to point on world space
  27324. */
  27325. reset(from?: Vector3, to?: Vector3): void;
  27326. }
  27327. /**
  27328. * Interface for the size containing width and height
  27329. */
  27330. interface IXYZ {
  27331. /**
  27332. * X
  27333. */
  27334. x: number;
  27335. /**
  27336. * Y
  27337. */
  27338. y: number;
  27339. /**
  27340. * Z
  27341. */
  27342. z: number;
  27343. }
  27344. }
  27345. declare module BABYLON {
  27346. /**
  27347. * Interface used to describe a physics joint
  27348. */
  27349. export interface PhysicsImpostorJoint {
  27350. /** Defines the main impostor to which the joint is linked */
  27351. mainImpostor: PhysicsImpostor;
  27352. /** Defines the impostor that is connected to the main impostor using this joint */
  27353. connectedImpostor: PhysicsImpostor;
  27354. /** Defines the joint itself */
  27355. joint: PhysicsJoint;
  27356. }
  27357. /** @hidden */
  27358. export interface IPhysicsEnginePlugin {
  27359. world: any;
  27360. name: string;
  27361. setGravity(gravity: Vector3): void;
  27362. setTimeStep(timeStep: number): void;
  27363. getTimeStep(): number;
  27364. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27365. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27366. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27367. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27368. removePhysicsBody(impostor: PhysicsImpostor): void;
  27369. generateJoint(joint: PhysicsImpostorJoint): void;
  27370. removeJoint(joint: PhysicsImpostorJoint): void;
  27371. isSupported(): boolean;
  27372. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27373. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27374. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27375. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27376. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27377. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27378. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27379. getBodyMass(impostor: PhysicsImpostor): number;
  27380. getBodyFriction(impostor: PhysicsImpostor): number;
  27381. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27382. getBodyRestitution(impostor: PhysicsImpostor): number;
  27383. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27384. getBodyPressure?(impostor: PhysicsImpostor): number;
  27385. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27386. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27387. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27388. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27389. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27390. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27391. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27392. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27393. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27394. sleepBody(impostor: PhysicsImpostor): void;
  27395. wakeUpBody(impostor: PhysicsImpostor): void;
  27396. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27397. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27398. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27399. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27400. getRadius(impostor: PhysicsImpostor): number;
  27401. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27402. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27403. dispose(): void;
  27404. }
  27405. /**
  27406. * Interface used to define a physics engine
  27407. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27408. */
  27409. export interface IPhysicsEngine {
  27410. /**
  27411. * Gets the gravity vector used by the simulation
  27412. */
  27413. gravity: Vector3;
  27414. /**
  27415. * Sets the gravity vector used by the simulation
  27416. * @param gravity defines the gravity vector to use
  27417. */
  27418. setGravity(gravity: Vector3): void;
  27419. /**
  27420. * Set the time step of the physics engine.
  27421. * Default is 1/60.
  27422. * To slow it down, enter 1/600 for example.
  27423. * To speed it up, 1/30
  27424. * @param newTimeStep the new timestep to apply to this world.
  27425. */
  27426. setTimeStep(newTimeStep: number): void;
  27427. /**
  27428. * Get the time step of the physics engine.
  27429. * @returns the current time step
  27430. */
  27431. getTimeStep(): number;
  27432. /**
  27433. * Set the sub time step of the physics engine.
  27434. * Default is 0 meaning there is no sub steps
  27435. * To increase physics resolution precision, set a small value (like 1 ms)
  27436. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27437. */
  27438. setSubTimeStep(subTimeStep: number): void;
  27439. /**
  27440. * Get the sub time step of the physics engine.
  27441. * @returns the current sub time step
  27442. */
  27443. getSubTimeStep(): number;
  27444. /**
  27445. * Release all resources
  27446. */
  27447. dispose(): void;
  27448. /**
  27449. * Gets the name of the current physics plugin
  27450. * @returns the name of the plugin
  27451. */
  27452. getPhysicsPluginName(): string;
  27453. /**
  27454. * Adding a new impostor for the impostor tracking.
  27455. * This will be done by the impostor itself.
  27456. * @param impostor the impostor to add
  27457. */
  27458. addImpostor(impostor: PhysicsImpostor): void;
  27459. /**
  27460. * Remove an impostor from the engine.
  27461. * This impostor and its mesh will not longer be updated by the physics engine.
  27462. * @param impostor the impostor to remove
  27463. */
  27464. removeImpostor(impostor: PhysicsImpostor): void;
  27465. /**
  27466. * Add a joint to the physics engine
  27467. * @param mainImpostor defines the main impostor to which the joint is added.
  27468. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27469. * @param joint defines the joint that will connect both impostors.
  27470. */
  27471. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27472. /**
  27473. * Removes a joint from the simulation
  27474. * @param mainImpostor defines the impostor used with the joint
  27475. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27476. * @param joint defines the joint to remove
  27477. */
  27478. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27479. /**
  27480. * Gets the current plugin used to run the simulation
  27481. * @returns current plugin
  27482. */
  27483. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27484. /**
  27485. * Gets the list of physic impostors
  27486. * @returns an array of PhysicsImpostor
  27487. */
  27488. getImpostors(): Array<PhysicsImpostor>;
  27489. /**
  27490. * Gets the impostor for a physics enabled object
  27491. * @param object defines the object impersonated by the impostor
  27492. * @returns the PhysicsImpostor or null if not found
  27493. */
  27494. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27495. /**
  27496. * Gets the impostor for a physics body object
  27497. * @param body defines physics body used by the impostor
  27498. * @returns the PhysicsImpostor or null if not found
  27499. */
  27500. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27501. /**
  27502. * Does a raycast in the physics world
  27503. * @param from when should the ray start?
  27504. * @param to when should the ray end?
  27505. * @returns PhysicsRaycastResult
  27506. */
  27507. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27508. /**
  27509. * Called by the scene. No need to call it.
  27510. * @param delta defines the timespam between frames
  27511. */
  27512. _step(delta: number): void;
  27513. }
  27514. }
  27515. declare module BABYLON {
  27516. /**
  27517. * The interface for the physics imposter parameters
  27518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27519. */
  27520. export interface PhysicsImpostorParameters {
  27521. /**
  27522. * The mass of the physics imposter
  27523. */
  27524. mass: number;
  27525. /**
  27526. * The friction of the physics imposter
  27527. */
  27528. friction?: number;
  27529. /**
  27530. * The coefficient of restitution of the physics imposter
  27531. */
  27532. restitution?: number;
  27533. /**
  27534. * The native options of the physics imposter
  27535. */
  27536. nativeOptions?: any;
  27537. /**
  27538. * Specifies if the parent should be ignored
  27539. */
  27540. ignoreParent?: boolean;
  27541. /**
  27542. * Specifies if bi-directional transformations should be disabled
  27543. */
  27544. disableBidirectionalTransformation?: boolean;
  27545. /**
  27546. * The pressure inside the physics imposter, soft object only
  27547. */
  27548. pressure?: number;
  27549. /**
  27550. * The stiffness the physics imposter, soft object only
  27551. */
  27552. stiffness?: number;
  27553. /**
  27554. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27555. */
  27556. velocityIterations?: number;
  27557. /**
  27558. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27559. */
  27560. positionIterations?: number;
  27561. /**
  27562. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27563. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27564. * Add to fix multiple points
  27565. */
  27566. fixedPoints?: number;
  27567. /**
  27568. * The collision margin around a soft object
  27569. */
  27570. margin?: number;
  27571. /**
  27572. * The collision margin around a soft object
  27573. */
  27574. damping?: number;
  27575. /**
  27576. * The path for a rope based on an extrusion
  27577. */
  27578. path?: any;
  27579. /**
  27580. * The shape of an extrusion used for a rope based on an extrusion
  27581. */
  27582. shape?: any;
  27583. }
  27584. /**
  27585. * Interface for a physics-enabled object
  27586. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27587. */
  27588. export interface IPhysicsEnabledObject {
  27589. /**
  27590. * The position of the physics-enabled object
  27591. */
  27592. position: Vector3;
  27593. /**
  27594. * The rotation of the physics-enabled object
  27595. */
  27596. rotationQuaternion: Nullable<Quaternion>;
  27597. /**
  27598. * The scale of the physics-enabled object
  27599. */
  27600. scaling: Vector3;
  27601. /**
  27602. * The rotation of the physics-enabled object
  27603. */
  27604. rotation?: Vector3;
  27605. /**
  27606. * The parent of the physics-enabled object
  27607. */
  27608. parent?: any;
  27609. /**
  27610. * The bounding info of the physics-enabled object
  27611. * @returns The bounding info of the physics-enabled object
  27612. */
  27613. getBoundingInfo(): BoundingInfo;
  27614. /**
  27615. * Computes the world matrix
  27616. * @param force Specifies if the world matrix should be computed by force
  27617. * @returns A world matrix
  27618. */
  27619. computeWorldMatrix(force: boolean): Matrix;
  27620. /**
  27621. * Gets the world matrix
  27622. * @returns A world matrix
  27623. */
  27624. getWorldMatrix?(): Matrix;
  27625. /**
  27626. * Gets the child meshes
  27627. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27628. * @returns An array of abstract meshes
  27629. */
  27630. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27631. /**
  27632. * Gets the vertex data
  27633. * @param kind The type of vertex data
  27634. * @returns A nullable array of numbers, or a float32 array
  27635. */
  27636. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27637. /**
  27638. * Gets the indices from the mesh
  27639. * @returns A nullable array of index arrays
  27640. */
  27641. getIndices?(): Nullable<IndicesArray>;
  27642. /**
  27643. * Gets the scene from the mesh
  27644. * @returns the indices array or null
  27645. */
  27646. getScene?(): Scene;
  27647. /**
  27648. * Gets the absolute position from the mesh
  27649. * @returns the absolute position
  27650. */
  27651. getAbsolutePosition(): Vector3;
  27652. /**
  27653. * Gets the absolute pivot point from the mesh
  27654. * @returns the absolute pivot point
  27655. */
  27656. getAbsolutePivotPoint(): Vector3;
  27657. /**
  27658. * Rotates the mesh
  27659. * @param axis The axis of rotation
  27660. * @param amount The amount of rotation
  27661. * @param space The space of the rotation
  27662. * @returns The rotation transform node
  27663. */
  27664. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27665. /**
  27666. * Translates the mesh
  27667. * @param axis The axis of translation
  27668. * @param distance The distance of translation
  27669. * @param space The space of the translation
  27670. * @returns The transform node
  27671. */
  27672. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27673. /**
  27674. * Sets the absolute position of the mesh
  27675. * @param absolutePosition The absolute position of the mesh
  27676. * @returns The transform node
  27677. */
  27678. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27679. /**
  27680. * Gets the class name of the mesh
  27681. * @returns The class name
  27682. */
  27683. getClassName(): string;
  27684. }
  27685. /**
  27686. * Represents a physics imposter
  27687. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27688. */
  27689. export class PhysicsImpostor {
  27690. /**
  27691. * The physics-enabled object used as the physics imposter
  27692. */
  27693. object: IPhysicsEnabledObject;
  27694. /**
  27695. * The type of the physics imposter
  27696. */
  27697. type: number;
  27698. private _options;
  27699. private _scene?;
  27700. /**
  27701. * The default object size of the imposter
  27702. */
  27703. static DEFAULT_OBJECT_SIZE: Vector3;
  27704. /**
  27705. * The identity quaternion of the imposter
  27706. */
  27707. static IDENTITY_QUATERNION: Quaternion;
  27708. /** @hidden */
  27709. _pluginData: any;
  27710. private _physicsEngine;
  27711. private _physicsBody;
  27712. private _bodyUpdateRequired;
  27713. private _onBeforePhysicsStepCallbacks;
  27714. private _onAfterPhysicsStepCallbacks;
  27715. /** @hidden */
  27716. _onPhysicsCollideCallbacks: Array<{
  27717. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27718. otherImpostors: Array<PhysicsImpostor>;
  27719. }>;
  27720. private _deltaPosition;
  27721. private _deltaRotation;
  27722. private _deltaRotationConjugated;
  27723. /** @hidden */
  27724. _isFromLine: boolean;
  27725. private _parent;
  27726. private _isDisposed;
  27727. private static _tmpVecs;
  27728. private static _tmpQuat;
  27729. /**
  27730. * Specifies if the physics imposter is disposed
  27731. */
  27732. get isDisposed(): boolean;
  27733. /**
  27734. * Gets the mass of the physics imposter
  27735. */
  27736. get mass(): number;
  27737. set mass(value: number);
  27738. /**
  27739. * Gets the coefficient of friction
  27740. */
  27741. get friction(): number;
  27742. /**
  27743. * Sets the coefficient of friction
  27744. */
  27745. set friction(value: number);
  27746. /**
  27747. * Gets the coefficient of restitution
  27748. */
  27749. get restitution(): number;
  27750. /**
  27751. * Sets the coefficient of restitution
  27752. */
  27753. set restitution(value: number);
  27754. /**
  27755. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27756. */
  27757. get pressure(): number;
  27758. /**
  27759. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27760. */
  27761. set pressure(value: number);
  27762. /**
  27763. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27764. */
  27765. get stiffness(): number;
  27766. /**
  27767. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27768. */
  27769. set stiffness(value: number);
  27770. /**
  27771. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27772. */
  27773. get velocityIterations(): number;
  27774. /**
  27775. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27776. */
  27777. set velocityIterations(value: number);
  27778. /**
  27779. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27780. */
  27781. get positionIterations(): number;
  27782. /**
  27783. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27784. */
  27785. set positionIterations(value: number);
  27786. /**
  27787. * The unique id of the physics imposter
  27788. * set by the physics engine when adding this impostor to the array
  27789. */
  27790. uniqueId: number;
  27791. /**
  27792. * @hidden
  27793. */
  27794. soft: boolean;
  27795. /**
  27796. * @hidden
  27797. */
  27798. segments: number;
  27799. private _joints;
  27800. /**
  27801. * Initializes the physics imposter
  27802. * @param object The physics-enabled object used as the physics imposter
  27803. * @param type The type of the physics imposter
  27804. * @param _options The options for the physics imposter
  27805. * @param _scene The Babylon scene
  27806. */
  27807. constructor(
  27808. /**
  27809. * The physics-enabled object used as the physics imposter
  27810. */
  27811. object: IPhysicsEnabledObject,
  27812. /**
  27813. * The type of the physics imposter
  27814. */
  27815. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27816. /**
  27817. * This function will completly initialize this impostor.
  27818. * It will create a new body - but only if this mesh has no parent.
  27819. * If it has, this impostor will not be used other than to define the impostor
  27820. * of the child mesh.
  27821. * @hidden
  27822. */
  27823. _init(): void;
  27824. private _getPhysicsParent;
  27825. /**
  27826. * Should a new body be generated.
  27827. * @returns boolean specifying if body initialization is required
  27828. */
  27829. isBodyInitRequired(): boolean;
  27830. /**
  27831. * Sets the updated scaling
  27832. * @param updated Specifies if the scaling is updated
  27833. */
  27834. setScalingUpdated(): void;
  27835. /**
  27836. * Force a regeneration of this or the parent's impostor's body.
  27837. * Use under cautious - This will remove all joints already implemented.
  27838. */
  27839. forceUpdate(): void;
  27840. /**
  27841. * Gets the body that holds this impostor. Either its own, or its parent.
  27842. */
  27843. get physicsBody(): any;
  27844. /**
  27845. * Get the parent of the physics imposter
  27846. * @returns Physics imposter or null
  27847. */
  27848. get parent(): Nullable<PhysicsImpostor>;
  27849. /**
  27850. * Sets the parent of the physics imposter
  27851. */
  27852. set parent(value: Nullable<PhysicsImpostor>);
  27853. /**
  27854. * Set the physics body. Used mainly by the physics engine/plugin
  27855. */
  27856. set physicsBody(physicsBody: any);
  27857. /**
  27858. * Resets the update flags
  27859. */
  27860. resetUpdateFlags(): void;
  27861. /**
  27862. * Gets the object extend size
  27863. * @returns the object extend size
  27864. */
  27865. getObjectExtendSize(): Vector3;
  27866. /**
  27867. * Gets the object center
  27868. * @returns The object center
  27869. */
  27870. getObjectCenter(): Vector3;
  27871. /**
  27872. * Get a specific parameter from the options parameters
  27873. * @param paramName The object parameter name
  27874. * @returns The object parameter
  27875. */
  27876. getParam(paramName: string): any;
  27877. /**
  27878. * Sets a specific parameter in the options given to the physics plugin
  27879. * @param paramName The parameter name
  27880. * @param value The value of the parameter
  27881. */
  27882. setParam(paramName: string, value: number): void;
  27883. /**
  27884. * Specifically change the body's mass option. Won't recreate the physics body object
  27885. * @param mass The mass of the physics imposter
  27886. */
  27887. setMass(mass: number): void;
  27888. /**
  27889. * Gets the linear velocity
  27890. * @returns linear velocity or null
  27891. */
  27892. getLinearVelocity(): Nullable<Vector3>;
  27893. /**
  27894. * Sets the linear velocity
  27895. * @param velocity linear velocity or null
  27896. */
  27897. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27898. /**
  27899. * Gets the angular velocity
  27900. * @returns angular velocity or null
  27901. */
  27902. getAngularVelocity(): Nullable<Vector3>;
  27903. /**
  27904. * Sets the angular velocity
  27905. * @param velocity The velocity or null
  27906. */
  27907. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27908. /**
  27909. * Execute a function with the physics plugin native code
  27910. * Provide a function the will have two variables - the world object and the physics body object
  27911. * @param func The function to execute with the physics plugin native code
  27912. */
  27913. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27914. /**
  27915. * Register a function that will be executed before the physics world is stepping forward
  27916. * @param func The function to execute before the physics world is stepped forward
  27917. */
  27918. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27919. /**
  27920. * Unregister a function that will be executed before the physics world is stepping forward
  27921. * @param func The function to execute before the physics world is stepped forward
  27922. */
  27923. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27924. /**
  27925. * Register a function that will be executed after the physics step
  27926. * @param func The function to execute after physics step
  27927. */
  27928. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27929. /**
  27930. * Unregisters a function that will be executed after the physics step
  27931. * @param func The function to execute after physics step
  27932. */
  27933. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27934. /**
  27935. * register a function that will be executed when this impostor collides against a different body
  27936. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27937. * @param func Callback that is executed on collision
  27938. */
  27939. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27940. /**
  27941. * Unregisters the physics imposter on contact
  27942. * @param collideAgainst The physics object to collide against
  27943. * @param func Callback to execute on collision
  27944. */
  27945. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27946. private _tmpQuat;
  27947. private _tmpQuat2;
  27948. /**
  27949. * Get the parent rotation
  27950. * @returns The parent rotation
  27951. */
  27952. getParentsRotation(): Quaternion;
  27953. /**
  27954. * this function is executed by the physics engine.
  27955. */
  27956. beforeStep: () => void;
  27957. /**
  27958. * this function is executed by the physics engine
  27959. */
  27960. afterStep: () => void;
  27961. /**
  27962. * Legacy collision detection event support
  27963. */
  27964. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27965. /**
  27966. * event and body object due to cannon's event-based architecture.
  27967. */
  27968. onCollide: (e: {
  27969. body: any;
  27970. }) => void;
  27971. /**
  27972. * Apply a force
  27973. * @param force The force to apply
  27974. * @param contactPoint The contact point for the force
  27975. * @returns The physics imposter
  27976. */
  27977. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27978. /**
  27979. * Apply an impulse
  27980. * @param force The impulse force
  27981. * @param contactPoint The contact point for the impulse force
  27982. * @returns The physics imposter
  27983. */
  27984. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27985. /**
  27986. * A help function to create a joint
  27987. * @param otherImpostor A physics imposter used to create a joint
  27988. * @param jointType The type of joint
  27989. * @param jointData The data for the joint
  27990. * @returns The physics imposter
  27991. */
  27992. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27993. /**
  27994. * Add a joint to this impostor with a different impostor
  27995. * @param otherImpostor A physics imposter used to add a joint
  27996. * @param joint The joint to add
  27997. * @returns The physics imposter
  27998. */
  27999. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  28000. /**
  28001. * Add an anchor to a cloth impostor
  28002. * @param otherImpostor rigid impostor to anchor to
  28003. * @param width ratio across width from 0 to 1
  28004. * @param height ratio up height from 0 to 1
  28005. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  28006. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  28007. * @returns impostor the soft imposter
  28008. */
  28009. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28010. /**
  28011. * Add a hook to a rope impostor
  28012. * @param otherImpostor rigid impostor to anchor to
  28013. * @param length ratio across rope from 0 to 1
  28014. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  28015. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  28016. * @returns impostor the rope imposter
  28017. */
  28018. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28019. /**
  28020. * Will keep this body still, in a sleep mode.
  28021. * @returns the physics imposter
  28022. */
  28023. sleep(): PhysicsImpostor;
  28024. /**
  28025. * Wake the body up.
  28026. * @returns The physics imposter
  28027. */
  28028. wakeUp(): PhysicsImpostor;
  28029. /**
  28030. * Clones the physics imposter
  28031. * @param newObject The physics imposter clones to this physics-enabled object
  28032. * @returns A nullable physics imposter
  28033. */
  28034. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28035. /**
  28036. * Disposes the physics imposter
  28037. */
  28038. dispose(): void;
  28039. /**
  28040. * Sets the delta position
  28041. * @param position The delta position amount
  28042. */
  28043. setDeltaPosition(position: Vector3): void;
  28044. /**
  28045. * Sets the delta rotation
  28046. * @param rotation The delta rotation amount
  28047. */
  28048. setDeltaRotation(rotation: Quaternion): void;
  28049. /**
  28050. * Gets the box size of the physics imposter and stores the result in the input parameter
  28051. * @param result Stores the box size
  28052. * @returns The physics imposter
  28053. */
  28054. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  28055. /**
  28056. * Gets the radius of the physics imposter
  28057. * @returns Radius of the physics imposter
  28058. */
  28059. getRadius(): number;
  28060. /**
  28061. * Sync a bone with this impostor
  28062. * @param bone The bone to sync to the impostor.
  28063. * @param boneMesh The mesh that the bone is influencing.
  28064. * @param jointPivot The pivot of the joint / bone in local space.
  28065. * @param distToJoint Optional distance from the impostor to the joint.
  28066. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28067. */
  28068. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  28069. /**
  28070. * Sync impostor to a bone
  28071. * @param bone The bone that the impostor will be synced to.
  28072. * @param boneMesh The mesh that the bone is influencing.
  28073. * @param jointPivot The pivot of the joint / bone in local space.
  28074. * @param distToJoint Optional distance from the impostor to the joint.
  28075. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28076. * @param boneAxis Optional vector3 axis the bone is aligned with
  28077. */
  28078. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28079. /**
  28080. * No-Imposter type
  28081. */
  28082. static NoImpostor: number;
  28083. /**
  28084. * Sphere-Imposter type
  28085. */
  28086. static SphereImpostor: number;
  28087. /**
  28088. * Box-Imposter type
  28089. */
  28090. static BoxImpostor: number;
  28091. /**
  28092. * Plane-Imposter type
  28093. */
  28094. static PlaneImpostor: number;
  28095. /**
  28096. * Mesh-imposter type
  28097. */
  28098. static MeshImpostor: number;
  28099. /**
  28100. * Capsule-Impostor type (Ammo.js plugin only)
  28101. */
  28102. static CapsuleImpostor: number;
  28103. /**
  28104. * Cylinder-Imposter type
  28105. */
  28106. static CylinderImpostor: number;
  28107. /**
  28108. * Particle-Imposter type
  28109. */
  28110. static ParticleImpostor: number;
  28111. /**
  28112. * Heightmap-Imposter type
  28113. */
  28114. static HeightmapImpostor: number;
  28115. /**
  28116. * ConvexHull-Impostor type (Ammo.js plugin only)
  28117. */
  28118. static ConvexHullImpostor: number;
  28119. /**
  28120. * Custom-Imposter type (Ammo.js plugin only)
  28121. */
  28122. static CustomImpostor: number;
  28123. /**
  28124. * Rope-Imposter type
  28125. */
  28126. static RopeImpostor: number;
  28127. /**
  28128. * Cloth-Imposter type
  28129. */
  28130. static ClothImpostor: number;
  28131. /**
  28132. * Softbody-Imposter type
  28133. */
  28134. static SoftbodyImpostor: number;
  28135. }
  28136. }
  28137. declare module BABYLON {
  28138. /**
  28139. * @hidden
  28140. **/
  28141. export class _CreationDataStorage {
  28142. closePath?: boolean;
  28143. closeArray?: boolean;
  28144. idx: number[];
  28145. dashSize: number;
  28146. gapSize: number;
  28147. path3D: Path3D;
  28148. pathArray: Vector3[][];
  28149. arc: number;
  28150. radius: number;
  28151. cap: number;
  28152. tessellation: number;
  28153. }
  28154. /**
  28155. * @hidden
  28156. **/
  28157. class _InstanceDataStorage {
  28158. visibleInstances: any;
  28159. batchCache: _InstancesBatch;
  28160. instancesBufferSize: number;
  28161. instancesBuffer: Nullable<Buffer>;
  28162. instancesData: Float32Array;
  28163. overridenInstanceCount: number;
  28164. isFrozen: boolean;
  28165. previousBatch: Nullable<_InstancesBatch>;
  28166. hardwareInstancedRendering: boolean;
  28167. sideOrientation: number;
  28168. manualUpdate: boolean;
  28169. previousRenderId: number;
  28170. }
  28171. /**
  28172. * @hidden
  28173. **/
  28174. export class _InstancesBatch {
  28175. mustReturn: boolean;
  28176. visibleInstances: Nullable<InstancedMesh[]>[];
  28177. renderSelf: boolean[];
  28178. hardwareInstancedRendering: boolean[];
  28179. }
  28180. /**
  28181. * @hidden
  28182. **/
  28183. class _ThinInstanceDataStorage {
  28184. instancesCount: number;
  28185. matrixBuffer: Nullable<Buffer>;
  28186. matrixBufferSize: number;
  28187. matrixData: Nullable<Float32Array>;
  28188. boundingVectors: Array<Vector3>;
  28189. worldMatrices: Nullable<Matrix[]>;
  28190. }
  28191. /**
  28192. * Class used to represent renderable models
  28193. */
  28194. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28195. /**
  28196. * Mesh side orientation : usually the external or front surface
  28197. */
  28198. static readonly FRONTSIDE: number;
  28199. /**
  28200. * Mesh side orientation : usually the internal or back surface
  28201. */
  28202. static readonly BACKSIDE: number;
  28203. /**
  28204. * Mesh side orientation : both internal and external or front and back surfaces
  28205. */
  28206. static readonly DOUBLESIDE: number;
  28207. /**
  28208. * Mesh side orientation : by default, `FRONTSIDE`
  28209. */
  28210. static readonly DEFAULTSIDE: number;
  28211. /**
  28212. * Mesh cap setting : no cap
  28213. */
  28214. static readonly NO_CAP: number;
  28215. /**
  28216. * Mesh cap setting : one cap at the beginning of the mesh
  28217. */
  28218. static readonly CAP_START: number;
  28219. /**
  28220. * Mesh cap setting : one cap at the end of the mesh
  28221. */
  28222. static readonly CAP_END: number;
  28223. /**
  28224. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28225. */
  28226. static readonly CAP_ALL: number;
  28227. /**
  28228. * Mesh pattern setting : no flip or rotate
  28229. */
  28230. static readonly NO_FLIP: number;
  28231. /**
  28232. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28233. */
  28234. static readonly FLIP_TILE: number;
  28235. /**
  28236. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28237. */
  28238. static readonly ROTATE_TILE: number;
  28239. /**
  28240. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28241. */
  28242. static readonly FLIP_ROW: number;
  28243. /**
  28244. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28245. */
  28246. static readonly ROTATE_ROW: number;
  28247. /**
  28248. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28249. */
  28250. static readonly FLIP_N_ROTATE_TILE: number;
  28251. /**
  28252. * Mesh pattern setting : rotate pattern and rotate
  28253. */
  28254. static readonly FLIP_N_ROTATE_ROW: number;
  28255. /**
  28256. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28257. */
  28258. static readonly CENTER: number;
  28259. /**
  28260. * Mesh tile positioning : part tiles on left
  28261. */
  28262. static readonly LEFT: number;
  28263. /**
  28264. * Mesh tile positioning : part tiles on right
  28265. */
  28266. static readonly RIGHT: number;
  28267. /**
  28268. * Mesh tile positioning : part tiles on top
  28269. */
  28270. static readonly TOP: number;
  28271. /**
  28272. * Mesh tile positioning : part tiles on bottom
  28273. */
  28274. static readonly BOTTOM: number;
  28275. /**
  28276. * Gets the default side orientation.
  28277. * @param orientation the orientation to value to attempt to get
  28278. * @returns the default orientation
  28279. * @hidden
  28280. */
  28281. static _GetDefaultSideOrientation(orientation?: number): number;
  28282. private _internalMeshDataInfo;
  28283. get computeBonesUsingShaders(): boolean;
  28284. set computeBonesUsingShaders(value: boolean);
  28285. /**
  28286. * An event triggered before rendering the mesh
  28287. */
  28288. get onBeforeRenderObservable(): Observable<Mesh>;
  28289. /**
  28290. * An event triggered before binding the mesh
  28291. */
  28292. get onBeforeBindObservable(): Observable<Mesh>;
  28293. /**
  28294. * An event triggered after rendering the mesh
  28295. */
  28296. get onAfterRenderObservable(): Observable<Mesh>;
  28297. /**
  28298. * An event triggered before drawing the mesh
  28299. */
  28300. get onBeforeDrawObservable(): Observable<Mesh>;
  28301. private _onBeforeDrawObserver;
  28302. /**
  28303. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28304. */
  28305. set onBeforeDraw(callback: () => void);
  28306. get hasInstances(): boolean;
  28307. get hasThinInstances(): boolean;
  28308. /**
  28309. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28310. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28311. */
  28312. delayLoadState: number;
  28313. /**
  28314. * Gets the list of instances created from this mesh
  28315. * it is not supposed to be modified manually.
  28316. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28317. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28318. */
  28319. instances: InstancedMesh[];
  28320. /**
  28321. * Gets the file containing delay loading data for this mesh
  28322. */
  28323. delayLoadingFile: string;
  28324. /** @hidden */
  28325. _binaryInfo: any;
  28326. /**
  28327. * User defined function used to change how LOD level selection is done
  28328. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28329. */
  28330. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28331. /**
  28332. * Gets or sets the morph target manager
  28333. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28334. */
  28335. get morphTargetManager(): Nullable<MorphTargetManager>;
  28336. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28337. /** @hidden */
  28338. _creationDataStorage: Nullable<_CreationDataStorage>;
  28339. /** @hidden */
  28340. _geometry: Nullable<Geometry>;
  28341. /** @hidden */
  28342. _delayInfo: Array<string>;
  28343. /** @hidden */
  28344. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28345. /** @hidden */
  28346. _instanceDataStorage: _InstanceDataStorage;
  28347. /** @hidden */
  28348. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28349. private _effectiveMaterial;
  28350. /** @hidden */
  28351. _shouldGenerateFlatShading: boolean;
  28352. /** @hidden */
  28353. _originalBuilderSideOrientation: number;
  28354. /**
  28355. * Use this property to change the original side orientation defined at construction time
  28356. */
  28357. overrideMaterialSideOrientation: Nullable<number>;
  28358. /**
  28359. * Gets the source mesh (the one used to clone this one from)
  28360. */
  28361. get source(): Nullable<Mesh>;
  28362. /**
  28363. * Gets the list of clones of this mesh
  28364. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  28365. * Note that useClonedMeshMap=true is the default setting
  28366. */
  28367. get cloneMeshMap(): Nullable<{
  28368. [id: string]: Mesh | undefined;
  28369. }>;
  28370. /**
  28371. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28372. */
  28373. get isUnIndexed(): boolean;
  28374. set isUnIndexed(value: boolean);
  28375. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28376. get worldMatrixInstancedBuffer(): Float32Array;
  28377. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28378. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28379. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28380. /**
  28381. * @constructor
  28382. * @param name The value used by scene.getMeshByName() to do a lookup.
  28383. * @param scene The scene to add this mesh to.
  28384. * @param parent The parent of this mesh, if it has one
  28385. * @param source An optional Mesh from which geometry is shared, cloned.
  28386. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28387. * When false, achieved by calling a clone(), also passing False.
  28388. * This will make creation of children, recursive.
  28389. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28390. */
  28391. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28392. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28393. doNotInstantiate: boolean;
  28394. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28395. /**
  28396. * Gets the class name
  28397. * @returns the string "Mesh".
  28398. */
  28399. getClassName(): string;
  28400. /** @hidden */
  28401. get _isMesh(): boolean;
  28402. /**
  28403. * Returns a description of this mesh
  28404. * @param fullDetails define if full details about this mesh must be used
  28405. * @returns a descriptive string representing this mesh
  28406. */
  28407. toString(fullDetails?: boolean): string;
  28408. /** @hidden */
  28409. _unBindEffect(): void;
  28410. /**
  28411. * Gets a boolean indicating if this mesh has LOD
  28412. */
  28413. get hasLODLevels(): boolean;
  28414. /**
  28415. * Gets the list of MeshLODLevel associated with the current mesh
  28416. * @returns an array of MeshLODLevel
  28417. */
  28418. getLODLevels(): MeshLODLevel[];
  28419. private _sortLODLevels;
  28420. /**
  28421. * Add a mesh as LOD level triggered at the given distance.
  28422. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28423. * @param distance The distance from the center of the object to show this level
  28424. * @param mesh The mesh to be added as LOD level (can be null)
  28425. * @return This mesh (for chaining)
  28426. */
  28427. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28428. /**
  28429. * Returns the LOD level mesh at the passed distance or null if not found.
  28430. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28431. * @param distance The distance from the center of the object to show this level
  28432. * @returns a Mesh or `null`
  28433. */
  28434. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28435. /**
  28436. * Remove a mesh from the LOD array
  28437. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28438. * @param mesh defines the mesh to be removed
  28439. * @return This mesh (for chaining)
  28440. */
  28441. removeLODLevel(mesh: Mesh): Mesh;
  28442. /**
  28443. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28444. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28445. * @param camera defines the camera to use to compute distance
  28446. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28447. * @return This mesh (for chaining)
  28448. */
  28449. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28450. /**
  28451. * Gets the mesh internal Geometry object
  28452. */
  28453. get geometry(): Nullable<Geometry>;
  28454. /**
  28455. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28456. * @returns the total number of vertices
  28457. */
  28458. getTotalVertices(): number;
  28459. /**
  28460. * Returns the content of an associated vertex buffer
  28461. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28462. * - VertexBuffer.PositionKind
  28463. * - VertexBuffer.UVKind
  28464. * - VertexBuffer.UV2Kind
  28465. * - VertexBuffer.UV3Kind
  28466. * - VertexBuffer.UV4Kind
  28467. * - VertexBuffer.UV5Kind
  28468. * - VertexBuffer.UV6Kind
  28469. * - VertexBuffer.ColorKind
  28470. * - VertexBuffer.MatricesIndicesKind
  28471. * - VertexBuffer.MatricesIndicesExtraKind
  28472. * - VertexBuffer.MatricesWeightsKind
  28473. * - VertexBuffer.MatricesWeightsExtraKind
  28474. * @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
  28475. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28476. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28477. */
  28478. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28479. /**
  28480. * Returns the mesh VertexBuffer object from the requested `kind`
  28481. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28482. * - VertexBuffer.PositionKind
  28483. * - VertexBuffer.NormalKind
  28484. * - VertexBuffer.UVKind
  28485. * - VertexBuffer.UV2Kind
  28486. * - VertexBuffer.UV3Kind
  28487. * - VertexBuffer.UV4Kind
  28488. * - VertexBuffer.UV5Kind
  28489. * - VertexBuffer.UV6Kind
  28490. * - VertexBuffer.ColorKind
  28491. * - VertexBuffer.MatricesIndicesKind
  28492. * - VertexBuffer.MatricesIndicesExtraKind
  28493. * - VertexBuffer.MatricesWeightsKind
  28494. * - VertexBuffer.MatricesWeightsExtraKind
  28495. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28496. */
  28497. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28498. /**
  28499. * Tests if a specific vertex buffer is associated with this mesh
  28500. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28501. * - VertexBuffer.PositionKind
  28502. * - VertexBuffer.NormalKind
  28503. * - VertexBuffer.UVKind
  28504. * - VertexBuffer.UV2Kind
  28505. * - VertexBuffer.UV3Kind
  28506. * - VertexBuffer.UV4Kind
  28507. * - VertexBuffer.UV5Kind
  28508. * - VertexBuffer.UV6Kind
  28509. * - VertexBuffer.ColorKind
  28510. * - VertexBuffer.MatricesIndicesKind
  28511. * - VertexBuffer.MatricesIndicesExtraKind
  28512. * - VertexBuffer.MatricesWeightsKind
  28513. * - VertexBuffer.MatricesWeightsExtraKind
  28514. * @returns a boolean
  28515. */
  28516. isVerticesDataPresent(kind: string): boolean;
  28517. /**
  28518. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28519. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28520. * - VertexBuffer.PositionKind
  28521. * - VertexBuffer.UVKind
  28522. * - VertexBuffer.UV2Kind
  28523. * - VertexBuffer.UV3Kind
  28524. * - VertexBuffer.UV4Kind
  28525. * - VertexBuffer.UV5Kind
  28526. * - VertexBuffer.UV6Kind
  28527. * - VertexBuffer.ColorKind
  28528. * - VertexBuffer.MatricesIndicesKind
  28529. * - VertexBuffer.MatricesIndicesExtraKind
  28530. * - VertexBuffer.MatricesWeightsKind
  28531. * - VertexBuffer.MatricesWeightsExtraKind
  28532. * @returns a boolean
  28533. */
  28534. isVertexBufferUpdatable(kind: string): boolean;
  28535. /**
  28536. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28537. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28538. * - VertexBuffer.PositionKind
  28539. * - VertexBuffer.NormalKind
  28540. * - VertexBuffer.UVKind
  28541. * - VertexBuffer.UV2Kind
  28542. * - VertexBuffer.UV3Kind
  28543. * - VertexBuffer.UV4Kind
  28544. * - VertexBuffer.UV5Kind
  28545. * - VertexBuffer.UV6Kind
  28546. * - VertexBuffer.ColorKind
  28547. * - VertexBuffer.MatricesIndicesKind
  28548. * - VertexBuffer.MatricesIndicesExtraKind
  28549. * - VertexBuffer.MatricesWeightsKind
  28550. * - VertexBuffer.MatricesWeightsExtraKind
  28551. * @returns an array of strings
  28552. */
  28553. getVerticesDataKinds(): string[];
  28554. /**
  28555. * Returns a positive integer : the total number of indices in this mesh geometry.
  28556. * @returns the numner of indices or zero if the mesh has no geometry.
  28557. */
  28558. getTotalIndices(): number;
  28559. /**
  28560. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28561. * @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.
  28562. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28563. * @returns the indices array or an empty array if the mesh has no geometry
  28564. */
  28565. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28566. get isBlocked(): boolean;
  28567. /**
  28568. * Determine if the current mesh is ready to be rendered
  28569. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28570. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28571. * @returns true if all associated assets are ready (material, textures, shaders)
  28572. */
  28573. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28574. /**
  28575. * 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.
  28576. */
  28577. get areNormalsFrozen(): boolean;
  28578. /**
  28579. * 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.
  28580. * @returns the current mesh
  28581. */
  28582. freezeNormals(): Mesh;
  28583. /**
  28584. * 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
  28585. * @returns the current mesh
  28586. */
  28587. unfreezeNormals(): Mesh;
  28588. /**
  28589. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28590. */
  28591. set overridenInstanceCount(count: number);
  28592. /** @hidden */
  28593. _preActivate(): Mesh;
  28594. /** @hidden */
  28595. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28596. /** @hidden */
  28597. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28598. protected _afterComputeWorldMatrix(): void;
  28599. /** @hidden */
  28600. _postActivate(): void;
  28601. /**
  28602. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28603. * This means the mesh underlying bounding box and sphere are recomputed.
  28604. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28605. * @returns the current mesh
  28606. */
  28607. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28608. /** @hidden */
  28609. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28610. /**
  28611. * This function will subdivide the mesh into multiple submeshes
  28612. * @param count defines the expected number of submeshes
  28613. */
  28614. subdivide(count: number): void;
  28615. /**
  28616. * Copy a FloatArray into a specific associated vertex buffer
  28617. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28618. * - VertexBuffer.PositionKind
  28619. * - VertexBuffer.UVKind
  28620. * - VertexBuffer.UV2Kind
  28621. * - VertexBuffer.UV3Kind
  28622. * - VertexBuffer.UV4Kind
  28623. * - VertexBuffer.UV5Kind
  28624. * - VertexBuffer.UV6Kind
  28625. * - VertexBuffer.ColorKind
  28626. * - VertexBuffer.MatricesIndicesKind
  28627. * - VertexBuffer.MatricesIndicesExtraKind
  28628. * - VertexBuffer.MatricesWeightsKind
  28629. * - VertexBuffer.MatricesWeightsExtraKind
  28630. * @param data defines the data source
  28631. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28632. * @param stride defines the data stride size (can be null)
  28633. * @returns the current mesh
  28634. */
  28635. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28636. /**
  28637. * Delete a vertex buffer associated with this mesh
  28638. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28639. * - VertexBuffer.PositionKind
  28640. * - VertexBuffer.UVKind
  28641. * - VertexBuffer.UV2Kind
  28642. * - VertexBuffer.UV3Kind
  28643. * - VertexBuffer.UV4Kind
  28644. * - VertexBuffer.UV5Kind
  28645. * - VertexBuffer.UV6Kind
  28646. * - VertexBuffer.ColorKind
  28647. * - VertexBuffer.MatricesIndicesKind
  28648. * - VertexBuffer.MatricesIndicesExtraKind
  28649. * - VertexBuffer.MatricesWeightsKind
  28650. * - VertexBuffer.MatricesWeightsExtraKind
  28651. */
  28652. removeVerticesData(kind: string): void;
  28653. /**
  28654. * Flags an associated vertex buffer as updatable
  28655. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28656. * - VertexBuffer.PositionKind
  28657. * - VertexBuffer.UVKind
  28658. * - VertexBuffer.UV2Kind
  28659. * - VertexBuffer.UV3Kind
  28660. * - VertexBuffer.UV4Kind
  28661. * - VertexBuffer.UV5Kind
  28662. * - VertexBuffer.UV6Kind
  28663. * - VertexBuffer.ColorKind
  28664. * - VertexBuffer.MatricesIndicesKind
  28665. * - VertexBuffer.MatricesIndicesExtraKind
  28666. * - VertexBuffer.MatricesWeightsKind
  28667. * - VertexBuffer.MatricesWeightsExtraKind
  28668. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28669. */
  28670. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28671. /**
  28672. * Sets the mesh global Vertex Buffer
  28673. * @param buffer defines the buffer to use
  28674. * @returns the current mesh
  28675. */
  28676. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28677. /**
  28678. * Update a specific associated vertex buffer
  28679. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28680. * - VertexBuffer.PositionKind
  28681. * - VertexBuffer.UVKind
  28682. * - VertexBuffer.UV2Kind
  28683. * - VertexBuffer.UV3Kind
  28684. * - VertexBuffer.UV4Kind
  28685. * - VertexBuffer.UV5Kind
  28686. * - VertexBuffer.UV6Kind
  28687. * - VertexBuffer.ColorKind
  28688. * - VertexBuffer.MatricesIndicesKind
  28689. * - VertexBuffer.MatricesIndicesExtraKind
  28690. * - VertexBuffer.MatricesWeightsKind
  28691. * - VertexBuffer.MatricesWeightsExtraKind
  28692. * @param data defines the data source
  28693. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28694. * @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)
  28695. * @returns the current mesh
  28696. */
  28697. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28698. /**
  28699. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28700. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28701. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28702. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28703. * @returns the current mesh
  28704. */
  28705. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28706. /**
  28707. * Creates a un-shared specific occurence of the geometry for the mesh.
  28708. * @returns the current mesh
  28709. */
  28710. makeGeometryUnique(): Mesh;
  28711. /**
  28712. * Set the index buffer of this mesh
  28713. * @param indices defines the source data
  28714. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28715. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28716. * @returns the current mesh
  28717. */
  28718. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28719. /**
  28720. * Update the current index buffer
  28721. * @param indices defines the source data
  28722. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28723. * @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)
  28724. * @returns the current mesh
  28725. */
  28726. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28727. /**
  28728. * Invert the geometry to move from a right handed system to a left handed one.
  28729. * @returns the current mesh
  28730. */
  28731. toLeftHanded(): Mesh;
  28732. /** @hidden */
  28733. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28734. /** @hidden */
  28735. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28736. /**
  28737. * Registers for this mesh a javascript function called just before the rendering process
  28738. * @param func defines the function to call before rendering this mesh
  28739. * @returns the current mesh
  28740. */
  28741. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28742. /**
  28743. * Disposes a previously registered javascript function called before the rendering
  28744. * @param func defines the function to remove
  28745. * @returns the current mesh
  28746. */
  28747. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28748. /**
  28749. * Registers for this mesh a javascript function called just after the rendering is complete
  28750. * @param func defines the function to call after rendering this mesh
  28751. * @returns the current mesh
  28752. */
  28753. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28754. /**
  28755. * Disposes a previously registered javascript function called after the rendering.
  28756. * @param func defines the function to remove
  28757. * @returns the current mesh
  28758. */
  28759. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28760. /** @hidden */
  28761. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28762. /** @hidden */
  28763. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28764. /** @hidden */
  28765. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28766. /** @hidden */
  28767. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28768. /** @hidden */
  28769. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28770. /** @hidden */
  28771. _rebuild(): void;
  28772. /** @hidden */
  28773. _freeze(): void;
  28774. /** @hidden */
  28775. _unFreeze(): void;
  28776. /**
  28777. * 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
  28778. * @param subMesh defines the subMesh to render
  28779. * @param enableAlphaMode defines if alpha mode can be changed
  28780. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28781. * @returns the current mesh
  28782. */
  28783. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28784. private _onBeforeDraw;
  28785. /**
  28786. * Renormalize the mesh and patch it up if there are no weights
  28787. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28788. * However in the case of zero weights then we set just a single influence to 1.
  28789. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28790. */
  28791. cleanMatrixWeights(): void;
  28792. private normalizeSkinFourWeights;
  28793. private normalizeSkinWeightsAndExtra;
  28794. /**
  28795. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28796. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28797. * the user know there was an issue with importing the mesh
  28798. * @returns a validation object with skinned, valid and report string
  28799. */
  28800. validateSkinning(): {
  28801. skinned: boolean;
  28802. valid: boolean;
  28803. report: string;
  28804. };
  28805. /** @hidden */
  28806. _checkDelayState(): Mesh;
  28807. private _queueLoad;
  28808. /**
  28809. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28810. * A mesh is in the frustum if its bounding box intersects the frustum
  28811. * @param frustumPlanes defines the frustum to test
  28812. * @returns true if the mesh is in the frustum planes
  28813. */
  28814. isInFrustum(frustumPlanes: Plane[]): boolean;
  28815. /**
  28816. * Sets the mesh material by the material or multiMaterial `id` property
  28817. * @param id is a string identifying the material or the multiMaterial
  28818. * @returns the current mesh
  28819. */
  28820. setMaterialByID(id: string): Mesh;
  28821. /**
  28822. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28823. * @returns an array of IAnimatable
  28824. */
  28825. getAnimatables(): IAnimatable[];
  28826. /**
  28827. * Modifies the mesh geometry according to the passed transformation matrix.
  28828. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28829. * The mesh normals are modified using the same transformation.
  28830. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28831. * @param transform defines the transform matrix to use
  28832. * @see https://doc.babylonjs.com/resources/baking_transformations
  28833. * @returns the current mesh
  28834. */
  28835. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28836. /**
  28837. * Modifies the mesh geometry according to its own current World Matrix.
  28838. * The mesh World Matrix is then reset.
  28839. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28840. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28841. * @see https://doc.babylonjs.com/resources/baking_transformations
  28842. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28843. * @returns the current mesh
  28844. */
  28845. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28846. /** @hidden */
  28847. get _positions(): Nullable<Vector3[]>;
  28848. /** @hidden */
  28849. _resetPointsArrayCache(): Mesh;
  28850. /** @hidden */
  28851. _generatePointsArray(): boolean;
  28852. /**
  28853. * Returns a new Mesh object generated from the current mesh properties.
  28854. * This method must not get confused with createInstance()
  28855. * @param name is a string, the name given to the new mesh
  28856. * @param newParent can be any Node object (default `null`)
  28857. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28858. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28859. * @returns a new mesh
  28860. */
  28861. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28862. /**
  28863. * Releases resources associated with this mesh.
  28864. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28865. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28866. */
  28867. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28868. /** @hidden */
  28869. _disposeInstanceSpecificData(): void;
  28870. /** @hidden */
  28871. _disposeThinInstanceSpecificData(): void;
  28872. /**
  28873. * Modifies the mesh geometry according to a displacement map.
  28874. * 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.
  28875. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28876. * @param url is a string, the URL from the image file is to be downloaded.
  28877. * @param minHeight is the lower limit of the displacement.
  28878. * @param maxHeight is the upper limit of the displacement.
  28879. * @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.
  28880. * @param uvOffset is an optional vector2 used to offset UV.
  28881. * @param uvScale is an optional vector2 used to scale UV.
  28882. * @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.
  28883. * @returns the Mesh.
  28884. */
  28885. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28886. /**
  28887. * Modifies the mesh geometry according to a displacementMap buffer.
  28888. * 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.
  28889. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28890. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28891. * @param heightMapWidth is the width of the buffer image.
  28892. * @param heightMapHeight is the height of the buffer image.
  28893. * @param minHeight is the lower limit of the displacement.
  28894. * @param maxHeight is the upper limit of the displacement.
  28895. * @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.
  28896. * @param uvOffset is an optional vector2 used to offset UV.
  28897. * @param uvScale is an optional vector2 used to scale UV.
  28898. * @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.
  28899. * @returns the Mesh.
  28900. */
  28901. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28902. /**
  28903. * Modify the mesh to get a flat shading rendering.
  28904. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28905. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28906. * @returns current mesh
  28907. */
  28908. convertToFlatShadedMesh(): Mesh;
  28909. /**
  28910. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28911. * In other words, more vertices, no more indices and a single bigger VBO.
  28912. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28913. * @returns current mesh
  28914. */
  28915. convertToUnIndexedMesh(): Mesh;
  28916. /**
  28917. * Inverses facet orientations.
  28918. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28919. * @param flipNormals will also inverts the normals
  28920. * @returns current mesh
  28921. */
  28922. flipFaces(flipNormals?: boolean): Mesh;
  28923. /**
  28924. * Increase the number of facets and hence vertices in a mesh
  28925. * Vertex normals are interpolated from existing vertex normals
  28926. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28927. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28928. */
  28929. increaseVertices(numberPerEdge: number): void;
  28930. /**
  28931. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28932. * This will undo any application of covertToFlatShadedMesh
  28933. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28934. */
  28935. forceSharedVertices(): void;
  28936. /** @hidden */
  28937. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28938. /** @hidden */
  28939. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28940. /**
  28941. * Creates a new InstancedMesh object from the mesh model.
  28942. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28943. * @param name defines the name of the new instance
  28944. * @returns a new InstancedMesh
  28945. */
  28946. createInstance(name: string): InstancedMesh;
  28947. /**
  28948. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28949. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28950. * @returns the current mesh
  28951. */
  28952. synchronizeInstances(): Mesh;
  28953. /**
  28954. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28955. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28956. * This should be used together with the simplification to avoid disappearing triangles.
  28957. * @param successCallback an optional success callback to be called after the optimization finished.
  28958. * @returns the current mesh
  28959. */
  28960. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28961. /**
  28962. * Serialize current mesh
  28963. * @param serializationObject defines the object which will receive the serialization data
  28964. */
  28965. serialize(serializationObject: any): void;
  28966. /** @hidden */
  28967. _syncGeometryWithMorphTargetManager(): void;
  28968. /** @hidden */
  28969. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28970. /**
  28971. * Returns a new Mesh object parsed from the source provided.
  28972. * @param parsedMesh is the source
  28973. * @param scene defines the hosting scene
  28974. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28975. * @returns a new Mesh
  28976. */
  28977. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28978. /**
  28979. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28980. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28981. * @param name defines the name of the mesh to create
  28982. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28983. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28984. * @param closePath creates a seam between the first and the last points of each path of the path array
  28985. * @param offset is taken in account only if the `pathArray` is containing a single path
  28986. * @param scene defines the hosting scene
  28987. * @param updatable defines if the mesh must be flagged as updatable
  28988. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28989. * @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)
  28990. * @returns a new Mesh
  28991. */
  28992. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28993. /**
  28994. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28995. * @param name defines the name of the mesh to create
  28996. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28997. * @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
  28998. * @param scene defines the hosting scene
  28999. * @param updatable defines if the mesh must be flagged as updatable
  29000. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29001. * @returns a new Mesh
  29002. */
  29003. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29004. /**
  29005. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  29006. * @param name defines the name of the mesh to create
  29007. * @param size sets the size (float) of each box side (default 1)
  29008. * @param scene defines the hosting scene
  29009. * @param updatable defines if the mesh must be flagged as updatable
  29010. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29011. * @returns a new Mesh
  29012. */
  29013. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29014. /**
  29015. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  29016. * @param name defines the name of the mesh to create
  29017. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29018. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29019. * @param scene defines the hosting scene
  29020. * @param updatable defines if the mesh must be flagged as updatable
  29021. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29022. * @returns a new Mesh
  29023. */
  29024. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29025. /**
  29026. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  29027. * @param name defines the name of the mesh to create
  29028. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29029. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29030. * @param scene defines the hosting scene
  29031. * @returns a new Mesh
  29032. */
  29033. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  29034. /**
  29035. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  29036. * @param name defines the name of the mesh to create
  29037. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  29038. * @param diameterTop set the top cap diameter (floats, default 1)
  29039. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  29040. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  29041. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  29042. * @param scene defines the hosting scene
  29043. * @param updatable defines if the mesh must be flagged as updatable
  29044. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29045. * @returns a new Mesh
  29046. */
  29047. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  29048. /**
  29049. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  29050. * @param name defines the name of the mesh to create
  29051. * @param diameter sets the diameter size (float) of the torus (default 1)
  29052. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  29053. * @param tessellation sets the number of torus sides (postive integer, default 16)
  29054. * @param scene defines the hosting scene
  29055. * @param updatable defines if the mesh must be flagged as updatable
  29056. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29057. * @returns a new Mesh
  29058. */
  29059. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29060. /**
  29061. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  29062. * @param name defines the name of the mesh to create
  29063. * @param radius sets the global radius size (float) of the torus knot (default 2)
  29064. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  29065. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  29066. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  29067. * @param p the number of windings on X axis (positive integers, default 2)
  29068. * @param q the number of windings on Y axis (positive integers, default 3)
  29069. * @param scene defines the hosting scene
  29070. * @param updatable defines if the mesh must be flagged as updatable
  29071. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29072. * @returns a new Mesh
  29073. */
  29074. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29075. /**
  29076. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29077. * @param name defines the name of the mesh to create
  29078. * @param points is an array successive Vector3
  29079. * @param scene defines the hosting scene
  29080. * @param updatable defines if the mesh must be flagged as updatable
  29081. * @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).
  29082. * @returns a new Mesh
  29083. */
  29084. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29085. /**
  29086. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29087. * @param name defines the name of the mesh to create
  29088. * @param points is an array successive Vector3
  29089. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29090. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29091. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29092. * @param scene defines the hosting scene
  29093. * @param updatable defines if the mesh must be flagged as updatable
  29094. * @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)
  29095. * @returns a new Mesh
  29096. */
  29097. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29098. /**
  29099. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29100. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29101. * 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.
  29102. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29103. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29104. * Remember you can only change the shape positions, not their number when updating a polygon.
  29105. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29106. * @param name defines the name of the mesh to create
  29107. * @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
  29108. * @param scene defines the hosting scene
  29109. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29110. * @param updatable defines if the mesh must be flagged as updatable
  29111. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29112. * @param earcutInjection can be used to inject your own earcut reference
  29113. * @returns a new Mesh
  29114. */
  29115. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29116. /**
  29117. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29118. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29119. * @param name defines the name of the mesh to create
  29120. * @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
  29121. * @param depth defines the height of extrusion
  29122. * @param scene defines the hosting scene
  29123. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29124. * @param updatable defines if the mesh must be flagged as updatable
  29125. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29126. * @param earcutInjection can be used to inject your own earcut reference
  29127. * @returns a new Mesh
  29128. */
  29129. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29130. /**
  29131. * Creates an extruded shape mesh.
  29132. * 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
  29133. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29134. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29135. * @param name defines the name of the mesh to create
  29136. * @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
  29137. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29138. * @param scale is the value to scale the shape
  29139. * @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
  29140. * @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
  29141. * @param scene defines the hosting scene
  29142. * @param updatable defines if the mesh must be flagged as updatable
  29143. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29144. * @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)
  29145. * @returns a new Mesh
  29146. */
  29147. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29148. /**
  29149. * Creates an custom extruded shape mesh.
  29150. * The custom extrusion is a parametric shape.
  29151. * It has no predefined shape. Its final shape will depend on the input parameters.
  29152. * Please consider using the same method from the MeshBuilder class instead
  29153. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29154. * @param name defines the name of the mesh to create
  29155. * @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
  29156. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29157. * @param scaleFunction is a custom Javascript function called on each path point
  29158. * @param rotationFunction is a custom Javascript function called on each path point
  29159. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29160. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29161. * @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
  29162. * @param scene defines the hosting scene
  29163. * @param updatable defines if the mesh must be flagged as updatable
  29164. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29165. * @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)
  29166. * @returns a new Mesh
  29167. */
  29168. 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;
  29169. /**
  29170. * Creates lathe mesh.
  29171. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29172. * Please consider using the same method from the MeshBuilder class instead
  29173. * @param name defines the name of the mesh to create
  29174. * @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
  29175. * @param radius is the radius value of the lathe
  29176. * @param tessellation is the side number of the lathe.
  29177. * @param scene defines the hosting scene
  29178. * @param updatable defines if the mesh must be flagged as updatable
  29179. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29180. * @returns a new Mesh
  29181. */
  29182. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29183. /**
  29184. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29185. * @param name defines the name of the mesh to create
  29186. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29187. * @param scene defines the hosting scene
  29188. * @param updatable defines if the mesh must be flagged as updatable
  29189. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29190. * @returns a new Mesh
  29191. */
  29192. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29193. /**
  29194. * Creates a ground mesh.
  29195. * Please consider using the same method from the MeshBuilder class instead
  29196. * @param name defines the name of the mesh to create
  29197. * @param width set the width of the ground
  29198. * @param height set the height of the ground
  29199. * @param subdivisions sets the number of subdivisions per side
  29200. * @param scene defines the hosting scene
  29201. * @param updatable defines if the mesh must be flagged as updatable
  29202. * @returns a new Mesh
  29203. */
  29204. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29205. /**
  29206. * Creates a tiled ground mesh.
  29207. * Please consider using the same method from the MeshBuilder class instead
  29208. * @param name defines the name of the mesh to create
  29209. * @param xmin set the ground minimum X coordinate
  29210. * @param zmin set the ground minimum Y coordinate
  29211. * @param xmax set the ground maximum X coordinate
  29212. * @param zmax set the ground maximum Z coordinate
  29213. * @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
  29214. * @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
  29215. * @param scene defines the hosting scene
  29216. * @param updatable defines if the mesh must be flagged as updatable
  29217. * @returns a new Mesh
  29218. */
  29219. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29220. w: number;
  29221. h: number;
  29222. }, precision: {
  29223. w: number;
  29224. h: number;
  29225. }, scene: Scene, updatable?: boolean): Mesh;
  29226. /**
  29227. * Creates a ground mesh from a height map.
  29228. * Please consider using the same method from the MeshBuilder class instead
  29229. * @see https://doc.babylonjs.com/babylon101/height_map
  29230. * @param name defines the name of the mesh to create
  29231. * @param url sets the URL of the height map image resource
  29232. * @param width set the ground width size
  29233. * @param height set the ground height size
  29234. * @param subdivisions sets the number of subdivision per side
  29235. * @param minHeight is the minimum altitude on the ground
  29236. * @param maxHeight is the maximum altitude on the ground
  29237. * @param scene defines the hosting scene
  29238. * @param updatable defines if the mesh must be flagged as updatable
  29239. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29240. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29241. * @returns a new Mesh
  29242. */
  29243. 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;
  29244. /**
  29245. * Creates a tube mesh.
  29246. * The tube is a parametric shape.
  29247. * It has no predefined shape. Its final shape will depend on the input parameters.
  29248. * Please consider using the same method from the MeshBuilder class instead
  29249. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29250. * @param name defines the name of the mesh to create
  29251. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29252. * @param radius sets the tube radius size
  29253. * @param tessellation is the number of sides on the tubular surface
  29254. * @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
  29255. * @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
  29256. * @param scene defines the hosting scene
  29257. * @param updatable defines if the mesh must be flagged as updatable
  29258. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29259. * @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)
  29260. * @returns a new Mesh
  29261. */
  29262. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29263. (i: number, distance: number): number;
  29264. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29265. /**
  29266. * Creates a polyhedron mesh.
  29267. * Please consider using the same method from the MeshBuilder class instead.
  29268. * * 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
  29269. * * The parameter `size` (positive float, default 1) sets the polygon size
  29270. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29271. * * 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`
  29272. * * 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
  29273. * * 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)`)
  29274. * * 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
  29275. * * 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
  29276. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29277. * * 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
  29278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29279. * @param name defines the name of the mesh to create
  29280. * @param options defines the options used to create the mesh
  29281. * @param scene defines the hosting scene
  29282. * @returns a new Mesh
  29283. */
  29284. static CreatePolyhedron(name: string, options: {
  29285. type?: number;
  29286. size?: number;
  29287. sizeX?: number;
  29288. sizeY?: number;
  29289. sizeZ?: number;
  29290. custom?: any;
  29291. faceUV?: Vector4[];
  29292. faceColors?: Color4[];
  29293. updatable?: boolean;
  29294. sideOrientation?: number;
  29295. }, scene: Scene): Mesh;
  29296. /**
  29297. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29298. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29299. * * 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`)
  29300. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29301. * * 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
  29302. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29303. * * 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
  29304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29305. * @param name defines the name of the mesh
  29306. * @param options defines the options used to create the mesh
  29307. * @param scene defines the hosting scene
  29308. * @returns a new Mesh
  29309. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29310. */
  29311. static CreateIcoSphere(name: string, options: {
  29312. radius?: number;
  29313. flat?: boolean;
  29314. subdivisions?: number;
  29315. sideOrientation?: number;
  29316. updatable?: boolean;
  29317. }, scene: Scene): Mesh;
  29318. /**
  29319. * Creates a decal mesh.
  29320. * Please consider using the same method from the MeshBuilder class instead.
  29321. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29322. * @param name defines the name of the mesh
  29323. * @param sourceMesh defines the mesh receiving the decal
  29324. * @param position sets the position of the decal in world coordinates
  29325. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29326. * @param size sets the decal scaling
  29327. * @param angle sets the angle to rotate the decal
  29328. * @returns a new Mesh
  29329. */
  29330. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29331. /** Creates a Capsule Mesh
  29332. * @param name defines the name of the mesh.
  29333. * @param options the constructors options used to shape the mesh.
  29334. * @param scene defines the scene the mesh is scoped to.
  29335. * @returns the capsule mesh
  29336. * @see https://doc.babylonjs.com/how_to/capsule_shape
  29337. */
  29338. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  29339. /**
  29340. * Prepare internal position array for software CPU skinning
  29341. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29342. */
  29343. setPositionsForCPUSkinning(): Float32Array;
  29344. /**
  29345. * Prepare internal normal array for software CPU skinning
  29346. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29347. */
  29348. setNormalsForCPUSkinning(): Float32Array;
  29349. /**
  29350. * Updates the vertex buffer by applying transformation from the bones
  29351. * @param skeleton defines the skeleton to apply to current mesh
  29352. * @returns the current mesh
  29353. */
  29354. applySkeleton(skeleton: Skeleton): Mesh;
  29355. /**
  29356. * 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
  29357. * @param meshes defines the list of meshes to scan
  29358. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29359. */
  29360. static MinMax(meshes: AbstractMesh[]): {
  29361. min: Vector3;
  29362. max: Vector3;
  29363. };
  29364. /**
  29365. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29366. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29367. * @returns a vector3
  29368. */
  29369. static Center(meshesOrMinMaxVector: {
  29370. min: Vector3;
  29371. max: Vector3;
  29372. } | AbstractMesh[]): Vector3;
  29373. /**
  29374. * Merge the array of meshes into a single mesh for performance reasons.
  29375. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29376. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29377. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29378. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29379. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29380. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29381. * @returns a new mesh
  29382. */
  29383. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29384. /** @hidden */
  29385. addInstance(instance: InstancedMesh): void;
  29386. /** @hidden */
  29387. removeInstance(instance: InstancedMesh): void;
  29388. }
  29389. }
  29390. declare module BABYLON {
  29391. /**
  29392. * This is the base class of all the camera used in the application.
  29393. * @see https://doc.babylonjs.com/features/cameras
  29394. */
  29395. export class Camera extends Node {
  29396. /** @hidden */
  29397. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29398. /**
  29399. * This is the default projection mode used by the cameras.
  29400. * It helps recreating a feeling of perspective and better appreciate depth.
  29401. * This is the best way to simulate real life cameras.
  29402. */
  29403. static readonly PERSPECTIVE_CAMERA: number;
  29404. /**
  29405. * This helps creating camera with an orthographic mode.
  29406. * 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.
  29407. */
  29408. static readonly ORTHOGRAPHIC_CAMERA: number;
  29409. /**
  29410. * This is the default FOV mode for perspective cameras.
  29411. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29412. */
  29413. static readonly FOVMODE_VERTICAL_FIXED: number;
  29414. /**
  29415. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29416. */
  29417. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29418. /**
  29419. * This specifies ther is no need for a camera rig.
  29420. * Basically only one eye is rendered corresponding to the camera.
  29421. */
  29422. static readonly RIG_MODE_NONE: number;
  29423. /**
  29424. * Simulates a camera Rig with one blue eye and one red eye.
  29425. * This can be use with 3d blue and red glasses.
  29426. */
  29427. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29428. /**
  29429. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29430. */
  29431. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29432. /**
  29433. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29434. */
  29435. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29436. /**
  29437. * Defines that both eyes of the camera will be rendered over under each other.
  29438. */
  29439. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29440. /**
  29441. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29442. */
  29443. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29444. /**
  29445. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29446. */
  29447. static readonly RIG_MODE_VR: number;
  29448. /**
  29449. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29450. */
  29451. static readonly RIG_MODE_WEBVR: number;
  29452. /**
  29453. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29454. */
  29455. static readonly RIG_MODE_CUSTOM: number;
  29456. /**
  29457. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29458. */
  29459. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29460. /**
  29461. * Define the input manager associated with the camera.
  29462. */
  29463. inputs: CameraInputsManager<Camera>;
  29464. /** @hidden */
  29465. _position: Vector3;
  29466. /**
  29467. * Define the current local position of the camera in the scene
  29468. */
  29469. get position(): Vector3;
  29470. set position(newPosition: Vector3);
  29471. protected _upVector: Vector3;
  29472. /**
  29473. * The vector the camera should consider as up.
  29474. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29475. */
  29476. set upVector(vec: Vector3);
  29477. get upVector(): Vector3;
  29478. /**
  29479. * Define the current limit on the left side for an orthographic camera
  29480. * In scene unit
  29481. */
  29482. orthoLeft: Nullable<number>;
  29483. /**
  29484. * Define the current limit on the right side for an orthographic camera
  29485. * In scene unit
  29486. */
  29487. orthoRight: Nullable<number>;
  29488. /**
  29489. * Define the current limit on the bottom side for an orthographic camera
  29490. * In scene unit
  29491. */
  29492. orthoBottom: Nullable<number>;
  29493. /**
  29494. * Define the current limit on the top side for an orthographic camera
  29495. * In scene unit
  29496. */
  29497. orthoTop: Nullable<number>;
  29498. /**
  29499. * Field Of View is set in Radians. (default is 0.8)
  29500. */
  29501. fov: number;
  29502. /**
  29503. * Define the minimum distance the camera can see from.
  29504. * This is important to note that the depth buffer are not infinite and the closer it starts
  29505. * the more your scene might encounter depth fighting issue.
  29506. */
  29507. minZ: number;
  29508. /**
  29509. * Define the maximum distance the camera can see to.
  29510. * This is important to note that the depth buffer are not infinite and the further it end
  29511. * the more your scene might encounter depth fighting issue.
  29512. */
  29513. maxZ: number;
  29514. /**
  29515. * Define the default inertia of the camera.
  29516. * This helps giving a smooth feeling to the camera movement.
  29517. */
  29518. inertia: number;
  29519. /**
  29520. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29521. */
  29522. mode: number;
  29523. /**
  29524. * Define whether the camera is intermediate.
  29525. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29526. */
  29527. isIntermediate: boolean;
  29528. /**
  29529. * Define the viewport of the camera.
  29530. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29531. */
  29532. viewport: Viewport;
  29533. /**
  29534. * Restricts the camera to viewing objects with the same layerMask.
  29535. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29536. */
  29537. layerMask: number;
  29538. /**
  29539. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29540. */
  29541. fovMode: number;
  29542. /**
  29543. * Rig mode of the camera.
  29544. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29545. * This is normally controlled byt the camera themselves as internal use.
  29546. */
  29547. cameraRigMode: number;
  29548. /**
  29549. * Defines the distance between both "eyes" in case of a RIG
  29550. */
  29551. interaxialDistance: number;
  29552. /**
  29553. * Defines if stereoscopic rendering is done side by side or over under.
  29554. */
  29555. isStereoscopicSideBySide: boolean;
  29556. /**
  29557. * 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
  29558. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29559. * else in the scene. (Eg. security camera)
  29560. *
  29561. * 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)
  29562. */
  29563. customRenderTargets: RenderTargetTexture[];
  29564. /**
  29565. * When set, the camera will render to this render target instead of the default canvas
  29566. *
  29567. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29568. */
  29569. outputRenderTarget: Nullable<RenderTargetTexture>;
  29570. /**
  29571. * Observable triggered when the camera view matrix has changed.
  29572. */
  29573. onViewMatrixChangedObservable: Observable<Camera>;
  29574. /**
  29575. * Observable triggered when the camera Projection matrix has changed.
  29576. */
  29577. onProjectionMatrixChangedObservable: Observable<Camera>;
  29578. /**
  29579. * Observable triggered when the inputs have been processed.
  29580. */
  29581. onAfterCheckInputsObservable: Observable<Camera>;
  29582. /**
  29583. * Observable triggered when reset has been called and applied to the camera.
  29584. */
  29585. onRestoreStateObservable: Observable<Camera>;
  29586. /**
  29587. * Is this camera a part of a rig system?
  29588. */
  29589. isRigCamera: boolean;
  29590. /**
  29591. * If isRigCamera set to true this will be set with the parent camera.
  29592. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29593. */
  29594. rigParent?: Camera;
  29595. /** @hidden */
  29596. _cameraRigParams: any;
  29597. /** @hidden */
  29598. _rigCameras: Camera[];
  29599. /** @hidden */
  29600. _rigPostProcess: Nullable<PostProcess>;
  29601. protected _webvrViewMatrix: Matrix;
  29602. /** @hidden */
  29603. _skipRendering: boolean;
  29604. /** @hidden */
  29605. _projectionMatrix: Matrix;
  29606. /** @hidden */
  29607. _postProcesses: Nullable<PostProcess>[];
  29608. /** @hidden */
  29609. _activeMeshes: SmartArray<AbstractMesh>;
  29610. protected _globalPosition: Vector3;
  29611. /** @hidden */
  29612. _computedViewMatrix: Matrix;
  29613. private _doNotComputeProjectionMatrix;
  29614. private _transformMatrix;
  29615. private _frustumPlanes;
  29616. private _refreshFrustumPlanes;
  29617. private _storedFov;
  29618. private _stateStored;
  29619. /**
  29620. * Instantiates a new camera object.
  29621. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29622. * @see https://doc.babylonjs.com/features/cameras
  29623. * @param name Defines the name of the camera in the scene
  29624. * @param position Defines the position of the camera
  29625. * @param scene Defines the scene the camera belongs too
  29626. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29627. */
  29628. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29629. /**
  29630. * Store current camera state (fov, position, etc..)
  29631. * @returns the camera
  29632. */
  29633. storeState(): Camera;
  29634. /**
  29635. * Restores the camera state values if it has been stored. You must call storeState() first
  29636. */
  29637. protected _restoreStateValues(): boolean;
  29638. /**
  29639. * Restored camera state. You must call storeState() first.
  29640. * @returns true if restored and false otherwise
  29641. */
  29642. restoreState(): boolean;
  29643. /**
  29644. * Gets the class name of the camera.
  29645. * @returns the class name
  29646. */
  29647. getClassName(): string;
  29648. /** @hidden */
  29649. readonly _isCamera: boolean;
  29650. /**
  29651. * Gets a string representation of the camera useful for debug purpose.
  29652. * @param fullDetails Defines that a more verboe level of logging is required
  29653. * @returns the string representation
  29654. */
  29655. toString(fullDetails?: boolean): string;
  29656. /**
  29657. * Gets the current world space position of the camera.
  29658. */
  29659. get globalPosition(): Vector3;
  29660. /**
  29661. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29662. * @returns the active meshe list
  29663. */
  29664. getActiveMeshes(): SmartArray<AbstractMesh>;
  29665. /**
  29666. * Check whether a mesh is part of the current active mesh list of the camera
  29667. * @param mesh Defines the mesh to check
  29668. * @returns true if active, false otherwise
  29669. */
  29670. isActiveMesh(mesh: Mesh): boolean;
  29671. /**
  29672. * Is this camera ready to be used/rendered
  29673. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29674. * @return true if the camera is ready
  29675. */
  29676. isReady(completeCheck?: boolean): boolean;
  29677. /** @hidden */
  29678. _initCache(): void;
  29679. /** @hidden */
  29680. _updateCache(ignoreParentClass?: boolean): void;
  29681. /** @hidden */
  29682. _isSynchronized(): boolean;
  29683. /** @hidden */
  29684. _isSynchronizedViewMatrix(): boolean;
  29685. /** @hidden */
  29686. _isSynchronizedProjectionMatrix(): boolean;
  29687. /**
  29688. * Attach the input controls to a specific dom element to get the input from.
  29689. * @param element Defines the element the controls should be listened from
  29690. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29691. */
  29692. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29693. /**
  29694. * Detach the current controls from the specified dom element.
  29695. * @param element Defines the element to stop listening the inputs from
  29696. */
  29697. detachControl(element: HTMLElement): void;
  29698. /**
  29699. * Update the camera state according to the different inputs gathered during the frame.
  29700. */
  29701. update(): void;
  29702. /** @hidden */
  29703. _checkInputs(): void;
  29704. /** @hidden */
  29705. get rigCameras(): Camera[];
  29706. /**
  29707. * Gets the post process used by the rig cameras
  29708. */
  29709. get rigPostProcess(): Nullable<PostProcess>;
  29710. /**
  29711. * Internal, gets the first post proces.
  29712. * @returns the first post process to be run on this camera.
  29713. */
  29714. _getFirstPostProcess(): Nullable<PostProcess>;
  29715. private _cascadePostProcessesToRigCams;
  29716. /**
  29717. * Attach a post process to the camera.
  29718. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29719. * @param postProcess The post process to attach to the camera
  29720. * @param insertAt The position of the post process in case several of them are in use in the scene
  29721. * @returns the position the post process has been inserted at
  29722. */
  29723. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29724. /**
  29725. * Detach a post process to the camera.
  29726. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29727. * @param postProcess The post process to detach from the camera
  29728. */
  29729. detachPostProcess(postProcess: PostProcess): void;
  29730. /**
  29731. * Gets the current world matrix of the camera
  29732. */
  29733. getWorldMatrix(): Matrix;
  29734. /** @hidden */
  29735. _getViewMatrix(): Matrix;
  29736. /**
  29737. * Gets the current view matrix of the camera.
  29738. * @param force forces the camera to recompute the matrix without looking at the cached state
  29739. * @returns the view matrix
  29740. */
  29741. getViewMatrix(force?: boolean): Matrix;
  29742. /**
  29743. * Freeze the projection matrix.
  29744. * It will prevent the cache check of the camera projection compute and can speed up perf
  29745. * if no parameter of the camera are meant to change
  29746. * @param projection Defines manually a projection if necessary
  29747. */
  29748. freezeProjectionMatrix(projection?: Matrix): void;
  29749. /**
  29750. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29751. */
  29752. unfreezeProjectionMatrix(): void;
  29753. /**
  29754. * Gets the current projection matrix of the camera.
  29755. * @param force forces the camera to recompute the matrix without looking at the cached state
  29756. * @returns the projection matrix
  29757. */
  29758. getProjectionMatrix(force?: boolean): Matrix;
  29759. /**
  29760. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29761. * @returns a Matrix
  29762. */
  29763. getTransformationMatrix(): Matrix;
  29764. private _updateFrustumPlanes;
  29765. /**
  29766. * Checks if a cullable object (mesh...) is in the camera frustum
  29767. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29768. * @param target The object to check
  29769. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29770. * @returns true if the object is in frustum otherwise false
  29771. */
  29772. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29773. /**
  29774. * Checks if a cullable object (mesh...) is in the camera frustum
  29775. * Unlike isInFrustum this cheks the full bounding box
  29776. * @param target The object to check
  29777. * @returns true if the object is in frustum otherwise false
  29778. */
  29779. isCompletelyInFrustum(target: ICullable): boolean;
  29780. /**
  29781. * Gets a ray in the forward direction from the camera.
  29782. * @param length Defines the length of the ray to create
  29783. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29784. * @param origin Defines the start point of the ray which defaults to the camera position
  29785. * @returns the forward ray
  29786. */
  29787. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29788. /**
  29789. * Gets a ray in the forward direction from the camera.
  29790. * @param refRay the ray to (re)use when setting the values
  29791. * @param length Defines the length of the ray to create
  29792. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29793. * @param origin Defines the start point of the ray which defaults to the camera position
  29794. * @returns the forward ray
  29795. */
  29796. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29797. /**
  29798. * Releases resources associated with this node.
  29799. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29800. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29801. */
  29802. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29803. /** @hidden */
  29804. _isLeftCamera: boolean;
  29805. /**
  29806. * Gets the left camera of a rig setup in case of Rigged Camera
  29807. */
  29808. get isLeftCamera(): boolean;
  29809. /** @hidden */
  29810. _isRightCamera: boolean;
  29811. /**
  29812. * Gets the right camera of a rig setup in case of Rigged Camera
  29813. */
  29814. get isRightCamera(): boolean;
  29815. /**
  29816. * Gets the left camera of a rig setup in case of Rigged Camera
  29817. */
  29818. get leftCamera(): Nullable<FreeCamera>;
  29819. /**
  29820. * Gets the right camera of a rig setup in case of Rigged Camera
  29821. */
  29822. get rightCamera(): Nullable<FreeCamera>;
  29823. /**
  29824. * Gets the left camera target of a rig setup in case of Rigged Camera
  29825. * @returns the target position
  29826. */
  29827. getLeftTarget(): Nullable<Vector3>;
  29828. /**
  29829. * Gets the right camera target of a rig setup in case of Rigged Camera
  29830. * @returns the target position
  29831. */
  29832. getRightTarget(): Nullable<Vector3>;
  29833. /**
  29834. * @hidden
  29835. */
  29836. setCameraRigMode(mode: number, rigParams: any): void;
  29837. /** @hidden */
  29838. static _setStereoscopicRigMode(camera: Camera): void;
  29839. /** @hidden */
  29840. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29841. /** @hidden */
  29842. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29843. /** @hidden */
  29844. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29845. /** @hidden */
  29846. _getVRProjectionMatrix(): Matrix;
  29847. protected _updateCameraRotationMatrix(): void;
  29848. protected _updateWebVRCameraRotationMatrix(): void;
  29849. /**
  29850. * This function MUST be overwritten by the different WebVR cameras available.
  29851. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29852. * @hidden
  29853. */
  29854. _getWebVRProjectionMatrix(): Matrix;
  29855. /**
  29856. * This function MUST be overwritten by the different WebVR cameras available.
  29857. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29858. * @hidden
  29859. */
  29860. _getWebVRViewMatrix(): Matrix;
  29861. /** @hidden */
  29862. setCameraRigParameter(name: string, value: any): void;
  29863. /**
  29864. * needs to be overridden by children so sub has required properties to be copied
  29865. * @hidden
  29866. */
  29867. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29868. /**
  29869. * May need to be overridden by children
  29870. * @hidden
  29871. */
  29872. _updateRigCameras(): void;
  29873. /** @hidden */
  29874. _setupInputs(): void;
  29875. /**
  29876. * Serialiaze the camera setup to a json represention
  29877. * @returns the JSON representation
  29878. */
  29879. serialize(): any;
  29880. /**
  29881. * Clones the current camera.
  29882. * @param name The cloned camera name
  29883. * @returns the cloned camera
  29884. */
  29885. clone(name: string): Camera;
  29886. /**
  29887. * Gets the direction of the camera relative to a given local axis.
  29888. * @param localAxis Defines the reference axis to provide a relative direction.
  29889. * @return the direction
  29890. */
  29891. getDirection(localAxis: Vector3): Vector3;
  29892. /**
  29893. * Returns the current camera absolute rotation
  29894. */
  29895. get absoluteRotation(): Quaternion;
  29896. /**
  29897. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29898. * @param localAxis Defines the reference axis to provide a relative direction.
  29899. * @param result Defines the vector to store the result in
  29900. */
  29901. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29902. /**
  29903. * Gets a camera constructor for a given camera type
  29904. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29905. * @param name The name of the camera the result will be able to instantiate
  29906. * @param scene The scene the result will construct the camera in
  29907. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29908. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29909. * @returns a factory method to construc the camera
  29910. */
  29911. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29912. /**
  29913. * Compute the world matrix of the camera.
  29914. * @returns the camera world matrix
  29915. */
  29916. computeWorldMatrix(): Matrix;
  29917. /**
  29918. * Parse a JSON and creates the camera from the parsed information
  29919. * @param parsedCamera The JSON to parse
  29920. * @param scene The scene to instantiate the camera in
  29921. * @returns the newly constructed camera
  29922. */
  29923. static Parse(parsedCamera: any, scene: Scene): Camera;
  29924. }
  29925. }
  29926. declare module BABYLON {
  29927. /**
  29928. * Class containing static functions to help procedurally build meshes
  29929. */
  29930. export class DiscBuilder {
  29931. /**
  29932. * Creates a plane polygonal mesh. By default, this is a disc
  29933. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29934. * * 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
  29935. * * 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
  29936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29937. * * 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
  29938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29939. * @param name defines the name of the mesh
  29940. * @param options defines the options used to create the mesh
  29941. * @param scene defines the hosting scene
  29942. * @returns the plane polygonal mesh
  29943. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29944. */
  29945. static CreateDisc(name: string, options: {
  29946. radius?: number;
  29947. tessellation?: number;
  29948. arc?: number;
  29949. updatable?: boolean;
  29950. sideOrientation?: number;
  29951. frontUVs?: Vector4;
  29952. backUVs?: Vector4;
  29953. }, scene?: Nullable<Scene>): Mesh;
  29954. }
  29955. }
  29956. declare module BABYLON {
  29957. /**
  29958. * Options to be used when creating a FresnelParameters.
  29959. */
  29960. export type IFresnelParametersCreationOptions = {
  29961. /**
  29962. * Define the color used on edges (grazing angle)
  29963. */
  29964. leftColor?: Color3;
  29965. /**
  29966. * Define the color used on center
  29967. */
  29968. rightColor?: Color3;
  29969. /**
  29970. * Define bias applied to computed fresnel term
  29971. */
  29972. bias?: number;
  29973. /**
  29974. * Defined the power exponent applied to fresnel term
  29975. */
  29976. power?: number;
  29977. /**
  29978. * Define if the fresnel effect is enable or not.
  29979. */
  29980. isEnabled?: boolean;
  29981. };
  29982. /**
  29983. * Serialized format for FresnelParameters.
  29984. */
  29985. export type IFresnelParametersSerialized = {
  29986. /**
  29987. * Define the color used on edges (grazing angle) [as an array]
  29988. */
  29989. leftColor: number[];
  29990. /**
  29991. * Define the color used on center [as an array]
  29992. */
  29993. rightColor: number[];
  29994. /**
  29995. * Define bias applied to computed fresnel term
  29996. */
  29997. bias: number;
  29998. /**
  29999. * Defined the power exponent applied to fresnel term
  30000. */
  30001. power?: number;
  30002. /**
  30003. * Define if the fresnel effect is enable or not.
  30004. */
  30005. isEnabled: boolean;
  30006. };
  30007. /**
  30008. * This represents all the required information to add a fresnel effect on a material:
  30009. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30010. */
  30011. export class FresnelParameters {
  30012. private _isEnabled;
  30013. /**
  30014. * Define if the fresnel effect is enable or not.
  30015. */
  30016. get isEnabled(): boolean;
  30017. set isEnabled(value: boolean);
  30018. /**
  30019. * Define the color used on edges (grazing angle)
  30020. */
  30021. leftColor: Color3;
  30022. /**
  30023. * Define the color used on center
  30024. */
  30025. rightColor: Color3;
  30026. /**
  30027. * Define bias applied to computed fresnel term
  30028. */
  30029. bias: number;
  30030. /**
  30031. * Defined the power exponent applied to fresnel term
  30032. */
  30033. power: number;
  30034. /**
  30035. * Creates a new FresnelParameters object.
  30036. *
  30037. * @param options provide your own settings to optionally to override defaults
  30038. */
  30039. constructor(options?: IFresnelParametersCreationOptions);
  30040. /**
  30041. * Clones the current fresnel and its valuues
  30042. * @returns a clone fresnel configuration
  30043. */
  30044. clone(): FresnelParameters;
  30045. /**
  30046. * Determines equality between FresnelParameters objects
  30047. * @param otherFresnelParameters defines the second operand
  30048. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  30049. */
  30050. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  30051. /**
  30052. * Serializes the current fresnel parameters to a JSON representation.
  30053. * @return the JSON serialization
  30054. */
  30055. serialize(): IFresnelParametersSerialized;
  30056. /**
  30057. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30058. * @param parsedFresnelParameters Define the JSON representation
  30059. * @returns the parsed parameters
  30060. */
  30061. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  30062. }
  30063. }
  30064. declare module BABYLON {
  30065. /**
  30066. * This groups all the flags used to control the materials channel.
  30067. */
  30068. export class MaterialFlags {
  30069. private static _DiffuseTextureEnabled;
  30070. /**
  30071. * Are diffuse textures enabled in the application.
  30072. */
  30073. static get DiffuseTextureEnabled(): boolean;
  30074. static set DiffuseTextureEnabled(value: boolean);
  30075. private static _DetailTextureEnabled;
  30076. /**
  30077. * Are detail textures enabled in the application.
  30078. */
  30079. static get DetailTextureEnabled(): boolean;
  30080. static set DetailTextureEnabled(value: boolean);
  30081. private static _AmbientTextureEnabled;
  30082. /**
  30083. * Are ambient textures enabled in the application.
  30084. */
  30085. static get AmbientTextureEnabled(): boolean;
  30086. static set AmbientTextureEnabled(value: boolean);
  30087. private static _OpacityTextureEnabled;
  30088. /**
  30089. * Are opacity textures enabled in the application.
  30090. */
  30091. static get OpacityTextureEnabled(): boolean;
  30092. static set OpacityTextureEnabled(value: boolean);
  30093. private static _ReflectionTextureEnabled;
  30094. /**
  30095. * Are reflection textures enabled in the application.
  30096. */
  30097. static get ReflectionTextureEnabled(): boolean;
  30098. static set ReflectionTextureEnabled(value: boolean);
  30099. private static _EmissiveTextureEnabled;
  30100. /**
  30101. * Are emissive textures enabled in the application.
  30102. */
  30103. static get EmissiveTextureEnabled(): boolean;
  30104. static set EmissiveTextureEnabled(value: boolean);
  30105. private static _SpecularTextureEnabled;
  30106. /**
  30107. * Are specular textures enabled in the application.
  30108. */
  30109. static get SpecularTextureEnabled(): boolean;
  30110. static set SpecularTextureEnabled(value: boolean);
  30111. private static _BumpTextureEnabled;
  30112. /**
  30113. * Are bump textures enabled in the application.
  30114. */
  30115. static get BumpTextureEnabled(): boolean;
  30116. static set BumpTextureEnabled(value: boolean);
  30117. private static _LightmapTextureEnabled;
  30118. /**
  30119. * Are lightmap textures enabled in the application.
  30120. */
  30121. static get LightmapTextureEnabled(): boolean;
  30122. static set LightmapTextureEnabled(value: boolean);
  30123. private static _RefractionTextureEnabled;
  30124. /**
  30125. * Are refraction textures enabled in the application.
  30126. */
  30127. static get RefractionTextureEnabled(): boolean;
  30128. static set RefractionTextureEnabled(value: boolean);
  30129. private static _ColorGradingTextureEnabled;
  30130. /**
  30131. * Are color grading textures enabled in the application.
  30132. */
  30133. static get ColorGradingTextureEnabled(): boolean;
  30134. static set ColorGradingTextureEnabled(value: boolean);
  30135. private static _FresnelEnabled;
  30136. /**
  30137. * Are fresnels enabled in the application.
  30138. */
  30139. static get FresnelEnabled(): boolean;
  30140. static set FresnelEnabled(value: boolean);
  30141. private static _ClearCoatTextureEnabled;
  30142. /**
  30143. * Are clear coat textures enabled in the application.
  30144. */
  30145. static get ClearCoatTextureEnabled(): boolean;
  30146. static set ClearCoatTextureEnabled(value: boolean);
  30147. private static _ClearCoatBumpTextureEnabled;
  30148. /**
  30149. * Are clear coat bump textures enabled in the application.
  30150. */
  30151. static get ClearCoatBumpTextureEnabled(): boolean;
  30152. static set ClearCoatBumpTextureEnabled(value: boolean);
  30153. private static _ClearCoatTintTextureEnabled;
  30154. /**
  30155. * Are clear coat tint textures enabled in the application.
  30156. */
  30157. static get ClearCoatTintTextureEnabled(): boolean;
  30158. static set ClearCoatTintTextureEnabled(value: boolean);
  30159. private static _SheenTextureEnabled;
  30160. /**
  30161. * Are sheen textures enabled in the application.
  30162. */
  30163. static get SheenTextureEnabled(): boolean;
  30164. static set SheenTextureEnabled(value: boolean);
  30165. private static _AnisotropicTextureEnabled;
  30166. /**
  30167. * Are anisotropic textures enabled in the application.
  30168. */
  30169. static get AnisotropicTextureEnabled(): boolean;
  30170. static set AnisotropicTextureEnabled(value: boolean);
  30171. private static _ThicknessTextureEnabled;
  30172. /**
  30173. * Are thickness textures enabled in the application.
  30174. */
  30175. static get ThicknessTextureEnabled(): boolean;
  30176. static set ThicknessTextureEnabled(value: boolean);
  30177. }
  30178. }
  30179. declare module BABYLON {
  30180. /** @hidden */
  30181. export var defaultFragmentDeclaration: {
  30182. name: string;
  30183. shader: string;
  30184. };
  30185. }
  30186. declare module BABYLON {
  30187. /** @hidden */
  30188. export var defaultUboDeclaration: {
  30189. name: string;
  30190. shader: string;
  30191. };
  30192. }
  30193. declare module BABYLON {
  30194. /** @hidden */
  30195. export var prePassDeclaration: {
  30196. name: string;
  30197. shader: string;
  30198. };
  30199. }
  30200. declare module BABYLON {
  30201. /** @hidden */
  30202. export var lightFragmentDeclaration: {
  30203. name: string;
  30204. shader: string;
  30205. };
  30206. }
  30207. declare module BABYLON {
  30208. /** @hidden */
  30209. export var lightUboDeclaration: {
  30210. name: string;
  30211. shader: string;
  30212. };
  30213. }
  30214. declare module BABYLON {
  30215. /** @hidden */
  30216. export var lightsFragmentFunctions: {
  30217. name: string;
  30218. shader: string;
  30219. };
  30220. }
  30221. declare module BABYLON {
  30222. /** @hidden */
  30223. export var shadowsFragmentFunctions: {
  30224. name: string;
  30225. shader: string;
  30226. };
  30227. }
  30228. declare module BABYLON {
  30229. /** @hidden */
  30230. export var fresnelFunction: {
  30231. name: string;
  30232. shader: string;
  30233. };
  30234. }
  30235. declare module BABYLON {
  30236. /** @hidden */
  30237. export var bumpFragmentMainFunctions: {
  30238. name: string;
  30239. shader: string;
  30240. };
  30241. }
  30242. declare module BABYLON {
  30243. /** @hidden */
  30244. export var bumpFragmentFunctions: {
  30245. name: string;
  30246. shader: string;
  30247. };
  30248. }
  30249. declare module BABYLON {
  30250. /** @hidden */
  30251. export var logDepthDeclaration: {
  30252. name: string;
  30253. shader: string;
  30254. };
  30255. }
  30256. declare module BABYLON {
  30257. /** @hidden */
  30258. export var bumpFragment: {
  30259. name: string;
  30260. shader: string;
  30261. };
  30262. }
  30263. declare module BABYLON {
  30264. /** @hidden */
  30265. export var depthPrePass: {
  30266. name: string;
  30267. shader: string;
  30268. };
  30269. }
  30270. declare module BABYLON {
  30271. /** @hidden */
  30272. export var lightFragment: {
  30273. name: string;
  30274. shader: string;
  30275. };
  30276. }
  30277. declare module BABYLON {
  30278. /** @hidden */
  30279. export var logDepthFragment: {
  30280. name: string;
  30281. shader: string;
  30282. };
  30283. }
  30284. declare module BABYLON {
  30285. /** @hidden */
  30286. export var defaultPixelShader: {
  30287. name: string;
  30288. shader: string;
  30289. };
  30290. }
  30291. declare module BABYLON {
  30292. /** @hidden */
  30293. export var defaultVertexDeclaration: {
  30294. name: string;
  30295. shader: string;
  30296. };
  30297. }
  30298. declare module BABYLON {
  30299. /** @hidden */
  30300. export var bumpVertexDeclaration: {
  30301. name: string;
  30302. shader: string;
  30303. };
  30304. }
  30305. declare module BABYLON {
  30306. /** @hidden */
  30307. export var bumpVertex: {
  30308. name: string;
  30309. shader: string;
  30310. };
  30311. }
  30312. declare module BABYLON {
  30313. /** @hidden */
  30314. export var fogVertex: {
  30315. name: string;
  30316. shader: string;
  30317. };
  30318. }
  30319. declare module BABYLON {
  30320. /** @hidden */
  30321. export var shadowsVertex: {
  30322. name: string;
  30323. shader: string;
  30324. };
  30325. }
  30326. declare module BABYLON {
  30327. /** @hidden */
  30328. export var pointCloudVertex: {
  30329. name: string;
  30330. shader: string;
  30331. };
  30332. }
  30333. declare module BABYLON {
  30334. /** @hidden */
  30335. export var logDepthVertex: {
  30336. name: string;
  30337. shader: string;
  30338. };
  30339. }
  30340. declare module BABYLON {
  30341. /** @hidden */
  30342. export var defaultVertexShader: {
  30343. name: string;
  30344. shader: string;
  30345. };
  30346. }
  30347. declare module BABYLON {
  30348. /**
  30349. * @hidden
  30350. */
  30351. export interface IMaterialDetailMapDefines {
  30352. DETAIL: boolean;
  30353. DETAILDIRECTUV: number;
  30354. DETAIL_NORMALBLENDMETHOD: number;
  30355. /** @hidden */
  30356. _areTexturesDirty: boolean;
  30357. }
  30358. /**
  30359. * Define the code related to the detail map parameters of a material
  30360. *
  30361. * Inspired from:
  30362. * 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
  30363. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30364. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30365. */
  30366. export class DetailMapConfiguration {
  30367. private _texture;
  30368. /**
  30369. * The detail texture of the material.
  30370. */
  30371. texture: Nullable<BaseTexture>;
  30372. /**
  30373. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30374. * Bigger values mean stronger blending
  30375. */
  30376. diffuseBlendLevel: number;
  30377. /**
  30378. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30379. * Bigger values mean stronger blending. Only used with PBR materials
  30380. */
  30381. roughnessBlendLevel: number;
  30382. /**
  30383. * Defines how strong the bump effect from the detail map is
  30384. * Bigger values mean stronger effect
  30385. */
  30386. bumpLevel: number;
  30387. private _normalBlendMethod;
  30388. /**
  30389. * The method used to blend the bump and detail normals together
  30390. */
  30391. normalBlendMethod: number;
  30392. private _isEnabled;
  30393. /**
  30394. * Enable or disable the detail map on this material
  30395. */
  30396. isEnabled: boolean;
  30397. /** @hidden */
  30398. private _internalMarkAllSubMeshesAsTexturesDirty;
  30399. /** @hidden */
  30400. _markAllSubMeshesAsTexturesDirty(): void;
  30401. /**
  30402. * Instantiate a new detail map
  30403. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30404. */
  30405. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30406. /**
  30407. * Gets whether the submesh is ready to be used or not.
  30408. * @param defines the list of "defines" to update.
  30409. * @param scene defines the scene the material belongs to.
  30410. * @returns - boolean indicating that the submesh is ready or not.
  30411. */
  30412. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30413. /**
  30414. * Update the defines for detail map usage
  30415. * @param defines the list of "defines" to update.
  30416. * @param scene defines the scene the material belongs to.
  30417. */
  30418. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30419. /**
  30420. * Binds the material data.
  30421. * @param uniformBuffer defines the Uniform buffer to fill in.
  30422. * @param scene defines the scene the material belongs to.
  30423. * @param isFrozen defines whether the material is frozen or not.
  30424. */
  30425. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30426. /**
  30427. * Checks to see if a texture is used in the material.
  30428. * @param texture - Base texture to use.
  30429. * @returns - Boolean specifying if a texture is used in the material.
  30430. */
  30431. hasTexture(texture: BaseTexture): boolean;
  30432. /**
  30433. * Returns an array of the actively used textures.
  30434. * @param activeTextures Array of BaseTextures
  30435. */
  30436. getActiveTextures(activeTextures: BaseTexture[]): void;
  30437. /**
  30438. * Returns the animatable textures.
  30439. * @param animatables Array of animatable textures.
  30440. */
  30441. getAnimatables(animatables: IAnimatable[]): void;
  30442. /**
  30443. * Disposes the resources of the material.
  30444. * @param forceDisposeTextures - Forces the disposal of all textures.
  30445. */
  30446. dispose(forceDisposeTextures?: boolean): void;
  30447. /**
  30448. * Get the current class name useful for serialization or dynamic coding.
  30449. * @returns "DetailMap"
  30450. */
  30451. getClassName(): string;
  30452. /**
  30453. * Add the required uniforms to the current list.
  30454. * @param uniforms defines the current uniform list.
  30455. */
  30456. static AddUniforms(uniforms: string[]): void;
  30457. /**
  30458. * Add the required samplers to the current list.
  30459. * @param samplers defines the current sampler list.
  30460. */
  30461. static AddSamplers(samplers: string[]): void;
  30462. /**
  30463. * Add the required uniforms to the current buffer.
  30464. * @param uniformBuffer defines the current uniform buffer.
  30465. */
  30466. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30467. /**
  30468. * Makes a duplicate of the current instance into another one.
  30469. * @param detailMap define the instance where to copy the info
  30470. */
  30471. copyTo(detailMap: DetailMapConfiguration): void;
  30472. /**
  30473. * Serializes this detail map instance
  30474. * @returns - An object with the serialized instance.
  30475. */
  30476. serialize(): any;
  30477. /**
  30478. * Parses a detail map setting from a serialized object.
  30479. * @param source - Serialized object.
  30480. * @param scene Defines the scene we are parsing for
  30481. * @param rootUrl Defines the rootUrl to load from
  30482. */
  30483. parse(source: any, scene: Scene, rootUrl: string): void;
  30484. }
  30485. }
  30486. declare module BABYLON {
  30487. /** @hidden */
  30488. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30489. MAINUV1: boolean;
  30490. MAINUV2: boolean;
  30491. DIFFUSE: boolean;
  30492. DIFFUSEDIRECTUV: number;
  30493. DETAIL: boolean;
  30494. DETAILDIRECTUV: number;
  30495. DETAIL_NORMALBLENDMETHOD: number;
  30496. AMBIENT: boolean;
  30497. AMBIENTDIRECTUV: number;
  30498. OPACITY: boolean;
  30499. OPACITYDIRECTUV: number;
  30500. OPACITYRGB: boolean;
  30501. REFLECTION: boolean;
  30502. EMISSIVE: boolean;
  30503. EMISSIVEDIRECTUV: number;
  30504. SPECULAR: boolean;
  30505. SPECULARDIRECTUV: number;
  30506. BUMP: boolean;
  30507. BUMPDIRECTUV: number;
  30508. PARALLAX: boolean;
  30509. PARALLAXOCCLUSION: boolean;
  30510. SPECULAROVERALPHA: boolean;
  30511. CLIPPLANE: boolean;
  30512. CLIPPLANE2: boolean;
  30513. CLIPPLANE3: boolean;
  30514. CLIPPLANE4: boolean;
  30515. CLIPPLANE5: boolean;
  30516. CLIPPLANE6: boolean;
  30517. ALPHATEST: boolean;
  30518. DEPTHPREPASS: boolean;
  30519. ALPHAFROMDIFFUSE: boolean;
  30520. POINTSIZE: boolean;
  30521. FOG: boolean;
  30522. SPECULARTERM: boolean;
  30523. DIFFUSEFRESNEL: boolean;
  30524. OPACITYFRESNEL: boolean;
  30525. REFLECTIONFRESNEL: boolean;
  30526. REFRACTIONFRESNEL: boolean;
  30527. EMISSIVEFRESNEL: boolean;
  30528. FRESNEL: boolean;
  30529. NORMAL: boolean;
  30530. UV1: boolean;
  30531. UV2: boolean;
  30532. VERTEXCOLOR: boolean;
  30533. VERTEXALPHA: boolean;
  30534. NUM_BONE_INFLUENCERS: number;
  30535. BonesPerMesh: number;
  30536. BONETEXTURE: boolean;
  30537. INSTANCES: boolean;
  30538. THIN_INSTANCES: boolean;
  30539. GLOSSINESS: boolean;
  30540. ROUGHNESS: boolean;
  30541. EMISSIVEASILLUMINATION: boolean;
  30542. LINKEMISSIVEWITHDIFFUSE: boolean;
  30543. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30544. LIGHTMAP: boolean;
  30545. LIGHTMAPDIRECTUV: number;
  30546. OBJECTSPACE_NORMALMAP: boolean;
  30547. USELIGHTMAPASSHADOWMAP: boolean;
  30548. REFLECTIONMAP_3D: boolean;
  30549. REFLECTIONMAP_SPHERICAL: boolean;
  30550. REFLECTIONMAP_PLANAR: boolean;
  30551. REFLECTIONMAP_CUBIC: boolean;
  30552. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30553. REFLECTIONMAP_PROJECTION: boolean;
  30554. REFLECTIONMAP_SKYBOX: boolean;
  30555. REFLECTIONMAP_EXPLICIT: boolean;
  30556. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30557. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30558. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30559. INVERTCUBICMAP: boolean;
  30560. LOGARITHMICDEPTH: boolean;
  30561. REFRACTION: boolean;
  30562. REFRACTIONMAP_3D: boolean;
  30563. REFLECTIONOVERALPHA: boolean;
  30564. TWOSIDEDLIGHTING: boolean;
  30565. SHADOWFLOAT: boolean;
  30566. MORPHTARGETS: boolean;
  30567. MORPHTARGETS_NORMAL: boolean;
  30568. MORPHTARGETS_TANGENT: boolean;
  30569. MORPHTARGETS_UV: boolean;
  30570. NUM_MORPH_INFLUENCERS: number;
  30571. NONUNIFORMSCALING: boolean;
  30572. PREMULTIPLYALPHA: boolean;
  30573. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30574. ALPHABLEND: boolean;
  30575. PREPASS: boolean;
  30576. PREPASS_IRRADIANCE: boolean;
  30577. PREPASS_IRRADIANCE_INDEX: number;
  30578. PREPASS_ALBEDO: boolean;
  30579. PREPASS_ALBEDO_INDEX: number;
  30580. PREPASS_DEPTHNORMAL: boolean;
  30581. PREPASS_DEPTHNORMAL_INDEX: number;
  30582. SCENE_MRT_COUNT: number;
  30583. RGBDLIGHTMAP: boolean;
  30584. RGBDREFLECTION: boolean;
  30585. RGBDREFRACTION: boolean;
  30586. IMAGEPROCESSING: boolean;
  30587. VIGNETTE: boolean;
  30588. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30589. VIGNETTEBLENDMODEOPAQUE: boolean;
  30590. TONEMAPPING: boolean;
  30591. TONEMAPPING_ACES: boolean;
  30592. CONTRAST: boolean;
  30593. COLORCURVES: boolean;
  30594. COLORGRADING: boolean;
  30595. COLORGRADING3D: boolean;
  30596. SAMPLER3DGREENDEPTH: boolean;
  30597. SAMPLER3DBGRMAP: boolean;
  30598. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30599. MULTIVIEW: boolean;
  30600. /**
  30601. * If the reflection texture on this material is in linear color space
  30602. * @hidden
  30603. */
  30604. IS_REFLECTION_LINEAR: boolean;
  30605. /**
  30606. * If the refraction texture on this material is in linear color space
  30607. * @hidden
  30608. */
  30609. IS_REFRACTION_LINEAR: boolean;
  30610. EXPOSURE: boolean;
  30611. constructor();
  30612. setReflectionMode(modeToEnable: string): void;
  30613. }
  30614. /**
  30615. * This is the default material used in Babylon. It is the best trade off between quality
  30616. * and performances.
  30617. * @see https://doc.babylonjs.com/babylon101/materials
  30618. */
  30619. export class StandardMaterial extends PushMaterial {
  30620. private _diffuseTexture;
  30621. /**
  30622. * The basic texture of the material as viewed under a light.
  30623. */
  30624. diffuseTexture: Nullable<BaseTexture>;
  30625. private _ambientTexture;
  30626. /**
  30627. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30628. */
  30629. ambientTexture: Nullable<BaseTexture>;
  30630. private _opacityTexture;
  30631. /**
  30632. * Define the transparency of the material from a texture.
  30633. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30634. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30635. */
  30636. opacityTexture: Nullable<BaseTexture>;
  30637. private _reflectionTexture;
  30638. /**
  30639. * Define the texture used to display the reflection.
  30640. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30641. */
  30642. reflectionTexture: Nullable<BaseTexture>;
  30643. private _emissiveTexture;
  30644. /**
  30645. * Define texture of the material as if self lit.
  30646. * This will be mixed in the final result even in the absence of light.
  30647. */
  30648. emissiveTexture: Nullable<BaseTexture>;
  30649. private _specularTexture;
  30650. /**
  30651. * Define how the color and intensity of the highlight given by the light in the material.
  30652. */
  30653. specularTexture: Nullable<BaseTexture>;
  30654. private _bumpTexture;
  30655. /**
  30656. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30657. * 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.
  30658. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30659. */
  30660. bumpTexture: Nullable<BaseTexture>;
  30661. private _lightmapTexture;
  30662. /**
  30663. * Complex lighting can be computationally expensive to compute at runtime.
  30664. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30665. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30666. */
  30667. lightmapTexture: Nullable<BaseTexture>;
  30668. private _refractionTexture;
  30669. /**
  30670. * Define the texture used to display the refraction.
  30671. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30672. */
  30673. refractionTexture: Nullable<BaseTexture>;
  30674. /**
  30675. * The color of the material lit by the environmental background lighting.
  30676. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30677. */
  30678. ambientColor: Color3;
  30679. /**
  30680. * The basic color of the material as viewed under a light.
  30681. */
  30682. diffuseColor: Color3;
  30683. /**
  30684. * Define how the color and intensity of the highlight given by the light in the material.
  30685. */
  30686. specularColor: Color3;
  30687. /**
  30688. * Define the color of the material as if self lit.
  30689. * This will be mixed in the final result even in the absence of light.
  30690. */
  30691. emissiveColor: Color3;
  30692. /**
  30693. * Defines how sharp are the highlights in the material.
  30694. * The bigger the value the sharper giving a more glossy feeling to the result.
  30695. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30696. */
  30697. specularPower: number;
  30698. private _useAlphaFromDiffuseTexture;
  30699. /**
  30700. * Does the transparency come from the diffuse texture alpha channel.
  30701. */
  30702. useAlphaFromDiffuseTexture: boolean;
  30703. private _useEmissiveAsIllumination;
  30704. /**
  30705. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30706. */
  30707. useEmissiveAsIllumination: boolean;
  30708. private _linkEmissiveWithDiffuse;
  30709. /**
  30710. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30711. * the emissive level when the final color is close to one.
  30712. */
  30713. linkEmissiveWithDiffuse: boolean;
  30714. private _useSpecularOverAlpha;
  30715. /**
  30716. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30717. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30718. */
  30719. useSpecularOverAlpha: boolean;
  30720. private _useReflectionOverAlpha;
  30721. /**
  30722. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30723. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30724. */
  30725. useReflectionOverAlpha: boolean;
  30726. private _disableLighting;
  30727. /**
  30728. * Does lights from the scene impacts this material.
  30729. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30730. */
  30731. disableLighting: boolean;
  30732. private _useObjectSpaceNormalMap;
  30733. /**
  30734. * Allows using an object space normal map (instead of tangent space).
  30735. */
  30736. useObjectSpaceNormalMap: boolean;
  30737. private _useParallax;
  30738. /**
  30739. * Is parallax enabled or not.
  30740. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30741. */
  30742. useParallax: boolean;
  30743. private _useParallaxOcclusion;
  30744. /**
  30745. * Is parallax occlusion enabled or not.
  30746. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30747. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30748. */
  30749. useParallaxOcclusion: boolean;
  30750. /**
  30751. * 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.
  30752. */
  30753. parallaxScaleBias: number;
  30754. private _roughness;
  30755. /**
  30756. * Helps to define how blurry the reflections should appears in the material.
  30757. */
  30758. roughness: number;
  30759. /**
  30760. * In case of refraction, define the value of the index of refraction.
  30761. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30762. */
  30763. indexOfRefraction: number;
  30764. /**
  30765. * Invert the refraction texture alongside the y axis.
  30766. * It can be useful with procedural textures or probe for instance.
  30767. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30768. */
  30769. invertRefractionY: boolean;
  30770. /**
  30771. * Defines the alpha limits in alpha test mode.
  30772. */
  30773. alphaCutOff: number;
  30774. private _useLightmapAsShadowmap;
  30775. /**
  30776. * In case of light mapping, define whether the map contains light or shadow informations.
  30777. */
  30778. useLightmapAsShadowmap: boolean;
  30779. private _diffuseFresnelParameters;
  30780. /**
  30781. * Define the diffuse fresnel parameters of the material.
  30782. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30783. */
  30784. diffuseFresnelParameters: FresnelParameters;
  30785. private _opacityFresnelParameters;
  30786. /**
  30787. * Define the opacity fresnel parameters of the material.
  30788. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30789. */
  30790. opacityFresnelParameters: FresnelParameters;
  30791. private _reflectionFresnelParameters;
  30792. /**
  30793. * Define the reflection fresnel parameters of the material.
  30794. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30795. */
  30796. reflectionFresnelParameters: FresnelParameters;
  30797. private _refractionFresnelParameters;
  30798. /**
  30799. * Define the refraction fresnel parameters of the material.
  30800. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30801. */
  30802. refractionFresnelParameters: FresnelParameters;
  30803. private _emissiveFresnelParameters;
  30804. /**
  30805. * Define the emissive fresnel parameters of the material.
  30806. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30807. */
  30808. emissiveFresnelParameters: FresnelParameters;
  30809. private _useReflectionFresnelFromSpecular;
  30810. /**
  30811. * If true automatically deducts the fresnels values from the material specularity.
  30812. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30813. */
  30814. useReflectionFresnelFromSpecular: boolean;
  30815. private _useGlossinessFromSpecularMapAlpha;
  30816. /**
  30817. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30818. */
  30819. useGlossinessFromSpecularMapAlpha: boolean;
  30820. private _maxSimultaneousLights;
  30821. /**
  30822. * Defines the maximum number of lights that can be used in the material
  30823. */
  30824. maxSimultaneousLights: number;
  30825. private _invertNormalMapX;
  30826. /**
  30827. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30828. */
  30829. invertNormalMapX: boolean;
  30830. private _invertNormalMapY;
  30831. /**
  30832. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30833. */
  30834. invertNormalMapY: boolean;
  30835. private _twoSidedLighting;
  30836. /**
  30837. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30838. */
  30839. twoSidedLighting: boolean;
  30840. /**
  30841. * Default configuration related to image processing available in the standard Material.
  30842. */
  30843. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30844. /**
  30845. * Gets the image processing configuration used either in this material.
  30846. */
  30847. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30848. /**
  30849. * Sets the Default image processing configuration used either in the this material.
  30850. *
  30851. * If sets to null, the scene one is in use.
  30852. */
  30853. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30854. /**
  30855. * Keep track of the image processing observer to allow dispose and replace.
  30856. */
  30857. private _imageProcessingObserver;
  30858. /**
  30859. * Attaches a new image processing configuration to the Standard Material.
  30860. * @param configuration
  30861. */
  30862. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30863. /**
  30864. * Gets wether the color curves effect is enabled.
  30865. */
  30866. get cameraColorCurvesEnabled(): boolean;
  30867. /**
  30868. * Sets wether the color curves effect is enabled.
  30869. */
  30870. set cameraColorCurvesEnabled(value: boolean);
  30871. /**
  30872. * Gets wether the color grading effect is enabled.
  30873. */
  30874. get cameraColorGradingEnabled(): boolean;
  30875. /**
  30876. * Gets wether the color grading effect is enabled.
  30877. */
  30878. set cameraColorGradingEnabled(value: boolean);
  30879. /**
  30880. * Gets wether tonemapping is enabled or not.
  30881. */
  30882. get cameraToneMappingEnabled(): boolean;
  30883. /**
  30884. * Sets wether tonemapping is enabled or not
  30885. */
  30886. set cameraToneMappingEnabled(value: boolean);
  30887. /**
  30888. * The camera exposure used on this material.
  30889. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30890. * This corresponds to a photographic exposure.
  30891. */
  30892. get cameraExposure(): number;
  30893. /**
  30894. * The camera exposure used on this material.
  30895. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30896. * This corresponds to a photographic exposure.
  30897. */
  30898. set cameraExposure(value: number);
  30899. /**
  30900. * Gets The camera contrast used on this material.
  30901. */
  30902. get cameraContrast(): number;
  30903. /**
  30904. * Sets The camera contrast used on this material.
  30905. */
  30906. set cameraContrast(value: number);
  30907. /**
  30908. * Gets the Color Grading 2D Lookup Texture.
  30909. */
  30910. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30911. /**
  30912. * Sets the Color Grading 2D Lookup Texture.
  30913. */
  30914. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30915. /**
  30916. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30917. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30918. * 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;
  30919. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30920. */
  30921. get cameraColorCurves(): Nullable<ColorCurves>;
  30922. /**
  30923. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30924. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30925. * 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;
  30926. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30927. */
  30928. set cameraColorCurves(value: Nullable<ColorCurves>);
  30929. /**
  30930. * Can this material render to several textures at once
  30931. */
  30932. get canRenderToMRT(): boolean;
  30933. /**
  30934. * Defines the detail map parameters for the material.
  30935. */
  30936. readonly detailMap: DetailMapConfiguration;
  30937. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30938. protected _worldViewProjectionMatrix: Matrix;
  30939. protected _globalAmbientColor: Color3;
  30940. protected _useLogarithmicDepth: boolean;
  30941. protected _rebuildInParallel: boolean;
  30942. /**
  30943. * Instantiates a new standard material.
  30944. * This is the default material used in Babylon. It is the best trade off between quality
  30945. * and performances.
  30946. * @see https://doc.babylonjs.com/babylon101/materials
  30947. * @param name Define the name of the material in the scene
  30948. * @param scene Define the scene the material belong to
  30949. */
  30950. constructor(name: string, scene: Scene);
  30951. /**
  30952. * Gets a boolean indicating that current material needs to register RTT
  30953. */
  30954. get hasRenderTargetTextures(): boolean;
  30955. /**
  30956. * Gets the current class name of the material e.g. "StandardMaterial"
  30957. * Mainly use in serialization.
  30958. * @returns the class name
  30959. */
  30960. getClassName(): string;
  30961. /**
  30962. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30963. * You can try switching to logarithmic depth.
  30964. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30965. */
  30966. get useLogarithmicDepth(): boolean;
  30967. set useLogarithmicDepth(value: boolean);
  30968. /**
  30969. * Specifies if the material will require alpha blending
  30970. * @returns a boolean specifying if alpha blending is needed
  30971. */
  30972. needAlphaBlending(): boolean;
  30973. /**
  30974. * Specifies if this material should be rendered in alpha test mode
  30975. * @returns a boolean specifying if an alpha test is needed.
  30976. */
  30977. needAlphaTesting(): boolean;
  30978. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30979. /**
  30980. * Get the texture used for alpha test purpose.
  30981. * @returns the diffuse texture in case of the standard material.
  30982. */
  30983. getAlphaTestTexture(): Nullable<BaseTexture>;
  30984. /**
  30985. * Get if the submesh is ready to be used and all its information available.
  30986. * Child classes can use it to update shaders
  30987. * @param mesh defines the mesh to check
  30988. * @param subMesh defines which submesh to check
  30989. * @param useInstances specifies that instances should be used
  30990. * @returns a boolean indicating that the submesh is ready or not
  30991. */
  30992. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30993. /**
  30994. * Builds the material UBO layouts.
  30995. * Used internally during the effect preparation.
  30996. */
  30997. buildUniformLayout(): void;
  30998. /**
  30999. * Unbinds the material from the mesh
  31000. */
  31001. unbind(): void;
  31002. /**
  31003. * Binds the submesh to this material by preparing the effect and shader to draw
  31004. * @param world defines the world transformation matrix
  31005. * @param mesh defines the mesh containing the submesh
  31006. * @param subMesh defines the submesh to bind the material to
  31007. */
  31008. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31009. /**
  31010. * Get the list of animatables in the material.
  31011. * @returns the list of animatables object used in the material
  31012. */
  31013. getAnimatables(): IAnimatable[];
  31014. /**
  31015. * Gets the active textures from the material
  31016. * @returns an array of textures
  31017. */
  31018. getActiveTextures(): BaseTexture[];
  31019. /**
  31020. * Specifies if the material uses a texture
  31021. * @param texture defines the texture to check against the material
  31022. * @returns a boolean specifying if the material uses the texture
  31023. */
  31024. hasTexture(texture: BaseTexture): boolean;
  31025. /**
  31026. * Disposes the material
  31027. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31028. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31029. */
  31030. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31031. /**
  31032. * Makes a duplicate of the material, and gives it a new name
  31033. * @param name defines the new name for the duplicated material
  31034. * @returns the cloned material
  31035. */
  31036. clone(name: string): StandardMaterial;
  31037. /**
  31038. * Serializes this material in a JSON representation
  31039. * @returns the serialized material object
  31040. */
  31041. serialize(): any;
  31042. /**
  31043. * Creates a standard material from parsed material data
  31044. * @param source defines the JSON representation of the material
  31045. * @param scene defines the hosting scene
  31046. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  31047. * @returns a new standard material
  31048. */
  31049. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  31050. /**
  31051. * Are diffuse textures enabled in the application.
  31052. */
  31053. static get DiffuseTextureEnabled(): boolean;
  31054. static set DiffuseTextureEnabled(value: boolean);
  31055. /**
  31056. * Are detail textures enabled in the application.
  31057. */
  31058. static get DetailTextureEnabled(): boolean;
  31059. static set DetailTextureEnabled(value: boolean);
  31060. /**
  31061. * Are ambient textures enabled in the application.
  31062. */
  31063. static get AmbientTextureEnabled(): boolean;
  31064. static set AmbientTextureEnabled(value: boolean);
  31065. /**
  31066. * Are opacity textures enabled in the application.
  31067. */
  31068. static get OpacityTextureEnabled(): boolean;
  31069. static set OpacityTextureEnabled(value: boolean);
  31070. /**
  31071. * Are reflection textures enabled in the application.
  31072. */
  31073. static get ReflectionTextureEnabled(): boolean;
  31074. static set ReflectionTextureEnabled(value: boolean);
  31075. /**
  31076. * Are emissive textures enabled in the application.
  31077. */
  31078. static get EmissiveTextureEnabled(): boolean;
  31079. static set EmissiveTextureEnabled(value: boolean);
  31080. /**
  31081. * Are specular textures enabled in the application.
  31082. */
  31083. static get SpecularTextureEnabled(): boolean;
  31084. static set SpecularTextureEnabled(value: boolean);
  31085. /**
  31086. * Are bump textures enabled in the application.
  31087. */
  31088. static get BumpTextureEnabled(): boolean;
  31089. static set BumpTextureEnabled(value: boolean);
  31090. /**
  31091. * Are lightmap textures enabled in the application.
  31092. */
  31093. static get LightmapTextureEnabled(): boolean;
  31094. static set LightmapTextureEnabled(value: boolean);
  31095. /**
  31096. * Are refraction textures enabled in the application.
  31097. */
  31098. static get RefractionTextureEnabled(): boolean;
  31099. static set RefractionTextureEnabled(value: boolean);
  31100. /**
  31101. * Are color grading textures enabled in the application.
  31102. */
  31103. static get ColorGradingTextureEnabled(): boolean;
  31104. static set ColorGradingTextureEnabled(value: boolean);
  31105. /**
  31106. * Are fresnels enabled in the application.
  31107. */
  31108. static get FresnelEnabled(): boolean;
  31109. static set FresnelEnabled(value: boolean);
  31110. }
  31111. }
  31112. declare module BABYLON {
  31113. /**
  31114. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31115. *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.
  31116. * The SPS is also a particle system. It provides some methods to manage the particles.
  31117. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31118. *
  31119. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  31120. */
  31121. export class SolidParticleSystem implements IDisposable {
  31122. /**
  31123. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31124. * Example : var p = SPS.particles[i];
  31125. */
  31126. particles: SolidParticle[];
  31127. /**
  31128. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31129. */
  31130. nbParticles: number;
  31131. /**
  31132. * If the particles must ever face the camera (default false). Useful for planar particles.
  31133. */
  31134. billboard: boolean;
  31135. /**
  31136. * Recompute normals when adding a shape
  31137. */
  31138. recomputeNormals: boolean;
  31139. /**
  31140. * This a counter ofr your own usage. It's not set by any SPS functions.
  31141. */
  31142. counter: number;
  31143. /**
  31144. * The SPS name. This name is also given to the underlying mesh.
  31145. */
  31146. name: string;
  31147. /**
  31148. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31149. */
  31150. mesh: Mesh;
  31151. /**
  31152. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31153. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31154. */
  31155. vars: any;
  31156. /**
  31157. * This array is populated when the SPS is set as 'pickable'.
  31158. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31159. * Each element of this array is an object `{idx: int, faceId: int}`.
  31160. * `idx` is the picked particle index in the `SPS.particles` array
  31161. * `faceId` is the picked face index counted within this particle.
  31162. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31163. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31164. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31165. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31166. */
  31167. pickedParticles: {
  31168. idx: number;
  31169. faceId: number;
  31170. }[];
  31171. /**
  31172. * This array is populated when the SPS is set as 'pickable'
  31173. * Each key of this array is a submesh index.
  31174. * Each element of this array is a second array defined like this :
  31175. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31176. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31177. * `idx` is the picked particle index in the `SPS.particles` array
  31178. * `faceId` is the picked face index counted within this particle.
  31179. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31180. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31181. */
  31182. pickedBySubMesh: {
  31183. idx: number;
  31184. faceId: number;
  31185. }[][];
  31186. /**
  31187. * This array is populated when `enableDepthSort` is set to true.
  31188. * Each element of this array is an instance of the class DepthSortedParticle.
  31189. */
  31190. depthSortedParticles: DepthSortedParticle[];
  31191. /**
  31192. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31193. * @hidden
  31194. */
  31195. _bSphereOnly: boolean;
  31196. /**
  31197. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31198. * @hidden
  31199. */
  31200. _bSphereRadiusFactor: number;
  31201. private _scene;
  31202. private _positions;
  31203. private _indices;
  31204. private _normals;
  31205. private _colors;
  31206. private _uvs;
  31207. private _indices32;
  31208. private _positions32;
  31209. private _normals32;
  31210. private _fixedNormal32;
  31211. private _colors32;
  31212. private _uvs32;
  31213. private _index;
  31214. private _updatable;
  31215. private _pickable;
  31216. private _isVisibilityBoxLocked;
  31217. private _alwaysVisible;
  31218. private _depthSort;
  31219. private _expandable;
  31220. private _shapeCounter;
  31221. private _copy;
  31222. private _color;
  31223. private _computeParticleColor;
  31224. private _computeParticleTexture;
  31225. private _computeParticleRotation;
  31226. private _computeParticleVertex;
  31227. private _computeBoundingBox;
  31228. private _depthSortParticles;
  31229. private _camera;
  31230. private _mustUnrotateFixedNormals;
  31231. private _particlesIntersect;
  31232. private _needs32Bits;
  31233. private _isNotBuilt;
  31234. private _lastParticleId;
  31235. private _idxOfId;
  31236. private _multimaterialEnabled;
  31237. private _useModelMaterial;
  31238. private _indicesByMaterial;
  31239. private _materialIndexes;
  31240. private _depthSortFunction;
  31241. private _materialSortFunction;
  31242. private _materials;
  31243. private _multimaterial;
  31244. private _materialIndexesById;
  31245. private _defaultMaterial;
  31246. private _autoUpdateSubMeshes;
  31247. private _tmpVertex;
  31248. /**
  31249. * Creates a SPS (Solid Particle System) object.
  31250. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31251. * @param scene (Scene) is the scene in which the SPS is added.
  31252. * @param options defines the options of the sps e.g.
  31253. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31254. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31255. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31256. * * 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.
  31257. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31258. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31259. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31260. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31261. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31262. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31263. */
  31264. constructor(name: string, scene: Scene, options?: {
  31265. updatable?: boolean;
  31266. isPickable?: boolean;
  31267. enableDepthSort?: boolean;
  31268. particleIntersection?: boolean;
  31269. boundingSphereOnly?: boolean;
  31270. bSphereRadiusFactor?: number;
  31271. expandable?: boolean;
  31272. useModelMaterial?: boolean;
  31273. enableMultiMaterial?: boolean;
  31274. });
  31275. /**
  31276. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31277. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31278. * @returns the created mesh
  31279. */
  31280. buildMesh(): Mesh;
  31281. /**
  31282. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31283. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31284. * Thus the particles generated from `digest()` have their property `position` set yet.
  31285. * @param mesh ( Mesh ) is the mesh to be digested
  31286. * @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
  31287. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31288. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31289. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31290. * @returns the current SPS
  31291. */
  31292. digest(mesh: Mesh, options?: {
  31293. facetNb?: number;
  31294. number?: number;
  31295. delta?: number;
  31296. storage?: [];
  31297. }): SolidParticleSystem;
  31298. /**
  31299. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31300. * @hidden
  31301. */
  31302. private _unrotateFixedNormals;
  31303. /**
  31304. * Resets the temporary working copy particle
  31305. * @hidden
  31306. */
  31307. private _resetCopy;
  31308. /**
  31309. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31310. * @param p the current index in the positions array to be updated
  31311. * @param ind the current index in the indices array
  31312. * @param shape a Vector3 array, the shape geometry
  31313. * @param positions the positions array to be updated
  31314. * @param meshInd the shape indices array
  31315. * @param indices the indices array to be updated
  31316. * @param meshUV the shape uv array
  31317. * @param uvs the uv array to be updated
  31318. * @param meshCol the shape color array
  31319. * @param colors the color array to be updated
  31320. * @param meshNor the shape normals array
  31321. * @param normals the normals array to be updated
  31322. * @param idx the particle index
  31323. * @param idxInShape the particle index in its shape
  31324. * @param options the addShape() method passed options
  31325. * @model the particle model
  31326. * @hidden
  31327. */
  31328. private _meshBuilder;
  31329. /**
  31330. * Returns a shape Vector3 array from positions float array
  31331. * @param positions float array
  31332. * @returns a vector3 array
  31333. * @hidden
  31334. */
  31335. private _posToShape;
  31336. /**
  31337. * Returns a shapeUV array from a float uvs (array deep copy)
  31338. * @param uvs as a float array
  31339. * @returns a shapeUV array
  31340. * @hidden
  31341. */
  31342. private _uvsToShapeUV;
  31343. /**
  31344. * Adds a new particle object in the particles array
  31345. * @param idx particle index in particles array
  31346. * @param id particle id
  31347. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31348. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31349. * @param model particle ModelShape object
  31350. * @param shapeId model shape identifier
  31351. * @param idxInShape index of the particle in the current model
  31352. * @param bInfo model bounding info object
  31353. * @param storage target storage array, if any
  31354. * @hidden
  31355. */
  31356. private _addParticle;
  31357. /**
  31358. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31359. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31360. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31361. * @param nb (positive integer) the number of particles to be created from this model
  31362. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31363. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31364. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31365. * @returns the number of shapes in the system
  31366. */
  31367. addShape(mesh: Mesh, nb: number, options?: {
  31368. positionFunction?: any;
  31369. vertexFunction?: any;
  31370. storage?: [];
  31371. }): number;
  31372. /**
  31373. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31374. * @hidden
  31375. */
  31376. private _rebuildParticle;
  31377. /**
  31378. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31379. * @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.
  31380. * @returns the SPS.
  31381. */
  31382. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31383. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31384. * Returns an array with the removed particles.
  31385. * 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.
  31386. * The SPS can't be empty so at least one particle needs to remain in place.
  31387. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31388. * @param start index of the first particle to remove
  31389. * @param end index of the last particle to remove (included)
  31390. * @returns an array populated with the removed particles
  31391. */
  31392. removeParticles(start: number, end: number): SolidParticle[];
  31393. /**
  31394. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31395. * @param solidParticleArray an array populated with Solid Particles objects
  31396. * @returns the SPS
  31397. */
  31398. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31399. /**
  31400. * Creates a new particle and modifies the SPS mesh geometry :
  31401. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31402. * - calls _addParticle() to populate the particle array
  31403. * factorized code from addShape() and insertParticlesFromArray()
  31404. * @param idx particle index in the particles array
  31405. * @param i particle index in its shape
  31406. * @param modelShape particle ModelShape object
  31407. * @param shape shape vertex array
  31408. * @param meshInd shape indices array
  31409. * @param meshUV shape uv array
  31410. * @param meshCol shape color array
  31411. * @param meshNor shape normals array
  31412. * @param bbInfo shape bounding info
  31413. * @param storage target particle storage
  31414. * @options addShape() passed options
  31415. * @hidden
  31416. */
  31417. private _insertNewParticle;
  31418. /**
  31419. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31420. * This method calls `updateParticle()` for each particle of the SPS.
  31421. * For an animated SPS, it is usually called within the render loop.
  31422. * 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.
  31423. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31424. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31425. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31426. * @returns the SPS.
  31427. */
  31428. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31429. /**
  31430. * Disposes the SPS.
  31431. */
  31432. dispose(): void;
  31433. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31434. * idx is the particle index in the SPS
  31435. * faceId is the picked face index counted within this particle.
  31436. * Returns null if the pickInfo can't identify a picked particle.
  31437. * @param pickingInfo (PickingInfo object)
  31438. * @returns {idx: number, faceId: number} or null
  31439. */
  31440. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31441. idx: number;
  31442. faceId: number;
  31443. }>;
  31444. /**
  31445. * Returns a SolidParticle object from its identifier : particle.id
  31446. * @param id (integer) the particle Id
  31447. * @returns the searched particle or null if not found in the SPS.
  31448. */
  31449. getParticleById(id: number): Nullable<SolidParticle>;
  31450. /**
  31451. * Returns a new array populated with the particles having the passed shapeId.
  31452. * @param shapeId (integer) the shape identifier
  31453. * @returns a new solid particle array
  31454. */
  31455. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31456. /**
  31457. * Populates the passed array "ref" with the particles having the passed shapeId.
  31458. * @param shapeId the shape identifier
  31459. * @returns the SPS
  31460. * @param ref
  31461. */
  31462. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31463. /**
  31464. * Computes the required SubMeshes according the materials assigned to the particles.
  31465. * @returns the solid particle system.
  31466. * Does nothing if called before the SPS mesh is built.
  31467. */
  31468. computeSubMeshes(): SolidParticleSystem;
  31469. /**
  31470. * Sorts the solid particles by material when MultiMaterial is enabled.
  31471. * Updates the indices32 array.
  31472. * Updates the indicesByMaterial array.
  31473. * Updates the mesh indices array.
  31474. * @returns the SPS
  31475. * @hidden
  31476. */
  31477. private _sortParticlesByMaterial;
  31478. /**
  31479. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31480. * @hidden
  31481. */
  31482. private _setMaterialIndexesById;
  31483. /**
  31484. * Returns an array with unique values of Materials from the passed array
  31485. * @param array the material array to be checked and filtered
  31486. * @hidden
  31487. */
  31488. private _filterUniqueMaterialId;
  31489. /**
  31490. * Sets a new Standard Material as _defaultMaterial if not already set.
  31491. * @hidden
  31492. */
  31493. private _setDefaultMaterial;
  31494. /**
  31495. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31496. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31497. * @returns the SPS.
  31498. */
  31499. refreshVisibleSize(): SolidParticleSystem;
  31500. /**
  31501. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31502. * @param size the size (float) of the visibility box
  31503. * note : this doesn't lock the SPS mesh bounding box.
  31504. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31505. */
  31506. setVisibilityBox(size: number): void;
  31507. /**
  31508. * Gets whether the SPS as always visible or not
  31509. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31510. */
  31511. get isAlwaysVisible(): boolean;
  31512. /**
  31513. * Sets the SPS as always visible or not
  31514. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31515. */
  31516. set isAlwaysVisible(val: boolean);
  31517. /**
  31518. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31519. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31520. */
  31521. set isVisibilityBoxLocked(val: boolean);
  31522. /**
  31523. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31524. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31525. */
  31526. get isVisibilityBoxLocked(): boolean;
  31527. /**
  31528. * Tells to `setParticles()` to compute the particle rotations or not.
  31529. * Default value : true. The SPS is faster when it's set to false.
  31530. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31531. */
  31532. set computeParticleRotation(val: boolean);
  31533. /**
  31534. * Tells to `setParticles()` to compute the particle colors or not.
  31535. * Default value : true. The SPS is faster when it's set to false.
  31536. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31537. */
  31538. set computeParticleColor(val: boolean);
  31539. set computeParticleTexture(val: boolean);
  31540. /**
  31541. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31542. * Default value : false. The SPS is faster when it's set to false.
  31543. * Note : the particle custom vertex positions aren't stored values.
  31544. */
  31545. set computeParticleVertex(val: boolean);
  31546. /**
  31547. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31548. */
  31549. set computeBoundingBox(val: boolean);
  31550. /**
  31551. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31552. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31553. * Default : `true`
  31554. */
  31555. set depthSortParticles(val: boolean);
  31556. /**
  31557. * Gets if `setParticles()` computes the particle rotations or not.
  31558. * Default value : true. The SPS is faster when it's set to false.
  31559. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31560. */
  31561. get computeParticleRotation(): boolean;
  31562. /**
  31563. * Gets if `setParticles()` computes the particle colors or not.
  31564. * Default value : true. The SPS is faster when it's set to false.
  31565. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31566. */
  31567. get computeParticleColor(): boolean;
  31568. /**
  31569. * Gets if `setParticles()` computes the particle textures or not.
  31570. * Default value : true. The SPS is faster when it's set to false.
  31571. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31572. */
  31573. get computeParticleTexture(): boolean;
  31574. /**
  31575. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31576. * Default value : false. The SPS is faster when it's set to false.
  31577. * Note : the particle custom vertex positions aren't stored values.
  31578. */
  31579. get computeParticleVertex(): boolean;
  31580. /**
  31581. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31582. */
  31583. get computeBoundingBox(): boolean;
  31584. /**
  31585. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31586. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31587. * Default : `true`
  31588. */
  31589. get depthSortParticles(): boolean;
  31590. /**
  31591. * Gets if the SPS is created as expandable at construction time.
  31592. * Default : `false`
  31593. */
  31594. get expandable(): boolean;
  31595. /**
  31596. * Gets if the SPS supports the Multi Materials
  31597. */
  31598. get multimaterialEnabled(): boolean;
  31599. /**
  31600. * Gets if the SPS uses the model materials for its own multimaterial.
  31601. */
  31602. get useModelMaterial(): boolean;
  31603. /**
  31604. * The SPS used material array.
  31605. */
  31606. get materials(): Material[];
  31607. /**
  31608. * Sets the SPS MultiMaterial from the passed materials.
  31609. * Note : the passed array is internally copied and not used then by reference.
  31610. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31611. */
  31612. setMultiMaterial(materials: Material[]): void;
  31613. /**
  31614. * The SPS computed multimaterial object
  31615. */
  31616. get multimaterial(): MultiMaterial;
  31617. set multimaterial(mm: MultiMaterial);
  31618. /**
  31619. * If the subMeshes must be updated on the next call to setParticles()
  31620. */
  31621. get autoUpdateSubMeshes(): boolean;
  31622. set autoUpdateSubMeshes(val: boolean);
  31623. /**
  31624. * This function does nothing. It may be overwritten to set all the particle first values.
  31625. * The SPS doesn't call this function, you may have to call it by your own.
  31626. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31627. */
  31628. initParticles(): void;
  31629. /**
  31630. * This function does nothing. It may be overwritten to recycle a particle.
  31631. * The SPS doesn't call this function, you may have to call it by your own.
  31632. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31633. * @param particle The particle to recycle
  31634. * @returns the recycled particle
  31635. */
  31636. recycleParticle(particle: SolidParticle): SolidParticle;
  31637. /**
  31638. * Updates a particle : this function should be overwritten by the user.
  31639. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31640. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31641. * @example : just set a particle position or velocity and recycle conditions
  31642. * @param particle The particle to update
  31643. * @returns the updated particle
  31644. */
  31645. updateParticle(particle: SolidParticle): SolidParticle;
  31646. /**
  31647. * Updates a vertex of a particle : it can be overwritten by the user.
  31648. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31649. * @param particle the current particle
  31650. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31651. * @param pt the index of the current vertex in the particle shape
  31652. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31653. * @example : just set a vertex particle position or color
  31654. * @returns the sps
  31655. */
  31656. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31657. /**
  31658. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31659. * This does nothing and may be overwritten by the user.
  31660. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31661. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31662. * @param update the boolean update value actually passed to setParticles()
  31663. */
  31664. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31665. /**
  31666. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31667. * This will be passed three parameters.
  31668. * This does nothing and may be overwritten by the user.
  31669. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31670. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31671. * @param update the boolean update value actually passed to setParticles()
  31672. */
  31673. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31674. }
  31675. }
  31676. declare module BABYLON {
  31677. /**
  31678. * Represents one particle of a solid particle system.
  31679. */
  31680. export class SolidParticle {
  31681. /**
  31682. * particle global index
  31683. */
  31684. idx: number;
  31685. /**
  31686. * particle identifier
  31687. */
  31688. id: number;
  31689. /**
  31690. * The color of the particle
  31691. */
  31692. color: Nullable<Color4>;
  31693. /**
  31694. * The world space position of the particle.
  31695. */
  31696. position: Vector3;
  31697. /**
  31698. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31699. */
  31700. rotation: Vector3;
  31701. /**
  31702. * The world space rotation quaternion of the particle.
  31703. */
  31704. rotationQuaternion: Nullable<Quaternion>;
  31705. /**
  31706. * The scaling of the particle.
  31707. */
  31708. scaling: Vector3;
  31709. /**
  31710. * The uvs of the particle.
  31711. */
  31712. uvs: Vector4;
  31713. /**
  31714. * The current speed of the particle.
  31715. */
  31716. velocity: Vector3;
  31717. /**
  31718. * The pivot point in the particle local space.
  31719. */
  31720. pivot: Vector3;
  31721. /**
  31722. * Must the particle be translated from its pivot point in its local space ?
  31723. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31724. * Default : false
  31725. */
  31726. translateFromPivot: boolean;
  31727. /**
  31728. * Is the particle active or not ?
  31729. */
  31730. alive: boolean;
  31731. /**
  31732. * Is the particle visible or not ?
  31733. */
  31734. isVisible: boolean;
  31735. /**
  31736. * Index of this particle in the global "positions" array (Internal use)
  31737. * @hidden
  31738. */
  31739. _pos: number;
  31740. /**
  31741. * @hidden Index of this particle in the global "indices" array (Internal use)
  31742. */
  31743. _ind: number;
  31744. /**
  31745. * @hidden ModelShape of this particle (Internal use)
  31746. */
  31747. _model: ModelShape;
  31748. /**
  31749. * ModelShape id of this particle
  31750. */
  31751. shapeId: number;
  31752. /**
  31753. * Index of the particle in its shape id
  31754. */
  31755. idxInShape: number;
  31756. /**
  31757. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31758. */
  31759. _modelBoundingInfo: BoundingInfo;
  31760. /**
  31761. * @hidden Particle BoundingInfo object (Internal use)
  31762. */
  31763. _boundingInfo: BoundingInfo;
  31764. /**
  31765. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31766. */
  31767. _sps: SolidParticleSystem;
  31768. /**
  31769. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31770. */
  31771. _stillInvisible: boolean;
  31772. /**
  31773. * @hidden Last computed particle rotation matrix
  31774. */
  31775. _rotationMatrix: number[];
  31776. /**
  31777. * Parent particle Id, if any.
  31778. * Default null.
  31779. */
  31780. parentId: Nullable<number>;
  31781. /**
  31782. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31783. */
  31784. materialIndex: Nullable<number>;
  31785. /**
  31786. * Custom object or properties.
  31787. */
  31788. props: Nullable<any>;
  31789. /**
  31790. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31791. * The possible values are :
  31792. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31793. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31794. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31795. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31796. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31797. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31798. * */
  31799. cullingStrategy: number;
  31800. /**
  31801. * @hidden Internal global position in the SPS.
  31802. */
  31803. _globalPosition: Vector3;
  31804. /**
  31805. * Creates a Solid Particle object.
  31806. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31807. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31808. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31809. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31810. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31811. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31812. * @param shapeId (integer) is the model shape identifier in the SPS.
  31813. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31814. * @param sps defines the sps it is associated to
  31815. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31816. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31817. */
  31818. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31819. /**
  31820. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31821. * @param target the particle target
  31822. * @returns the current particle
  31823. */
  31824. copyToRef(target: SolidParticle): SolidParticle;
  31825. /**
  31826. * Legacy support, changed scale to scaling
  31827. */
  31828. get scale(): Vector3;
  31829. /**
  31830. * Legacy support, changed scale to scaling
  31831. */
  31832. set scale(scale: Vector3);
  31833. /**
  31834. * Legacy support, changed quaternion to rotationQuaternion
  31835. */
  31836. get quaternion(): Nullable<Quaternion>;
  31837. /**
  31838. * Legacy support, changed quaternion to rotationQuaternion
  31839. */
  31840. set quaternion(q: Nullable<Quaternion>);
  31841. /**
  31842. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31843. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31844. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31845. * @returns true if it intersects
  31846. */
  31847. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31848. /**
  31849. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31850. * A particle is in the frustum if its bounding box intersects the frustum
  31851. * @param frustumPlanes defines the frustum to test
  31852. * @returns true if the particle is in the frustum planes
  31853. */
  31854. isInFrustum(frustumPlanes: Plane[]): boolean;
  31855. /**
  31856. * get the rotation matrix of the particle
  31857. * @hidden
  31858. */
  31859. getRotationMatrix(m: Matrix): void;
  31860. }
  31861. /**
  31862. * Represents the shape of the model used by one particle of a solid particle system.
  31863. * SPS internal tool, don't use it manually.
  31864. */
  31865. export class ModelShape {
  31866. /**
  31867. * The shape id
  31868. * @hidden
  31869. */
  31870. shapeID: number;
  31871. /**
  31872. * flat array of model positions (internal use)
  31873. * @hidden
  31874. */
  31875. _shape: Vector3[];
  31876. /**
  31877. * flat array of model UVs (internal use)
  31878. * @hidden
  31879. */
  31880. _shapeUV: number[];
  31881. /**
  31882. * color array of the model
  31883. * @hidden
  31884. */
  31885. _shapeColors: number[];
  31886. /**
  31887. * indices array of the model
  31888. * @hidden
  31889. */
  31890. _indices: number[];
  31891. /**
  31892. * normals array of the model
  31893. * @hidden
  31894. */
  31895. _normals: number[];
  31896. /**
  31897. * length of the shape in the model indices array (internal use)
  31898. * @hidden
  31899. */
  31900. _indicesLength: number;
  31901. /**
  31902. * Custom position function (internal use)
  31903. * @hidden
  31904. */
  31905. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31906. /**
  31907. * Custom vertex function (internal use)
  31908. * @hidden
  31909. */
  31910. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31911. /**
  31912. * Model material (internal use)
  31913. * @hidden
  31914. */
  31915. _material: Nullable<Material>;
  31916. /**
  31917. * 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.
  31918. * SPS internal tool, don't use it manually.
  31919. * @hidden
  31920. */
  31921. 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>);
  31922. }
  31923. /**
  31924. * Represents a Depth Sorted Particle in the solid particle system.
  31925. * @hidden
  31926. */
  31927. export class DepthSortedParticle {
  31928. /**
  31929. * Particle index
  31930. */
  31931. idx: number;
  31932. /**
  31933. * Index of the particle in the "indices" array
  31934. */
  31935. ind: number;
  31936. /**
  31937. * Length of the particle shape in the "indices" array
  31938. */
  31939. indicesLength: number;
  31940. /**
  31941. * Squared distance from the particle to the camera
  31942. */
  31943. sqDistance: number;
  31944. /**
  31945. * Material index when used with MultiMaterials
  31946. */
  31947. materialIndex: number;
  31948. /**
  31949. * Creates a new sorted particle
  31950. * @param materialIndex
  31951. */
  31952. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31953. }
  31954. /**
  31955. * Represents a solid particle vertex
  31956. */
  31957. export class SolidParticleVertex {
  31958. /**
  31959. * Vertex position
  31960. */
  31961. position: Vector3;
  31962. /**
  31963. * Vertex color
  31964. */
  31965. color: Color4;
  31966. /**
  31967. * Vertex UV
  31968. */
  31969. uv: Vector2;
  31970. /**
  31971. * Creates a new solid particle vertex
  31972. */
  31973. constructor();
  31974. /** Vertex x coordinate */
  31975. get x(): number;
  31976. set x(val: number);
  31977. /** Vertex y coordinate */
  31978. get y(): number;
  31979. set y(val: number);
  31980. /** Vertex z coordinate */
  31981. get z(): number;
  31982. set z(val: number);
  31983. }
  31984. }
  31985. declare module BABYLON {
  31986. /**
  31987. * @hidden
  31988. */
  31989. export class _MeshCollisionData {
  31990. _checkCollisions: boolean;
  31991. _collisionMask: number;
  31992. _collisionGroup: number;
  31993. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31994. _collider: Nullable<Collider>;
  31995. _oldPositionForCollisions: Vector3;
  31996. _diffPositionForCollisions: Vector3;
  31997. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31998. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31999. _collisionResponse: boolean;
  32000. }
  32001. }
  32002. declare module BABYLON {
  32003. /** @hidden */
  32004. class _FacetDataStorage {
  32005. facetPositions: Vector3[];
  32006. facetNormals: Vector3[];
  32007. facetPartitioning: number[][];
  32008. facetNb: number;
  32009. partitioningSubdivisions: number;
  32010. partitioningBBoxRatio: number;
  32011. facetDataEnabled: boolean;
  32012. facetParameters: any;
  32013. bbSize: Vector3;
  32014. subDiv: {
  32015. max: number;
  32016. X: number;
  32017. Y: number;
  32018. Z: number;
  32019. };
  32020. facetDepthSort: boolean;
  32021. facetDepthSortEnabled: boolean;
  32022. depthSortedIndices: IndicesArray;
  32023. depthSortedFacets: {
  32024. ind: number;
  32025. sqDistance: number;
  32026. }[];
  32027. facetDepthSortFunction: (f1: {
  32028. ind: number;
  32029. sqDistance: number;
  32030. }, f2: {
  32031. ind: number;
  32032. sqDistance: number;
  32033. }) => number;
  32034. facetDepthSortFrom: Vector3;
  32035. facetDepthSortOrigin: Vector3;
  32036. invertedMatrix: Matrix;
  32037. }
  32038. /**
  32039. * @hidden
  32040. **/
  32041. class _InternalAbstractMeshDataInfo {
  32042. _hasVertexAlpha: boolean;
  32043. _useVertexColors: boolean;
  32044. _numBoneInfluencers: number;
  32045. _applyFog: boolean;
  32046. _receiveShadows: boolean;
  32047. _facetData: _FacetDataStorage;
  32048. _visibility: number;
  32049. _skeleton: Nullable<Skeleton>;
  32050. _layerMask: number;
  32051. _computeBonesUsingShaders: boolean;
  32052. _isActive: boolean;
  32053. _onlyForInstances: boolean;
  32054. _isActiveIntermediate: boolean;
  32055. _onlyForInstancesIntermediate: boolean;
  32056. _actAsRegularMesh: boolean;
  32057. }
  32058. /**
  32059. * Class used to store all common mesh properties
  32060. */
  32061. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  32062. /** No occlusion */
  32063. static OCCLUSION_TYPE_NONE: number;
  32064. /** Occlusion set to optimisitic */
  32065. static OCCLUSION_TYPE_OPTIMISTIC: number;
  32066. /** Occlusion set to strict */
  32067. static OCCLUSION_TYPE_STRICT: number;
  32068. /** Use an accurante occlusion algorithm */
  32069. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  32070. /** Use a conservative occlusion algorithm */
  32071. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  32072. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  32073. * Test order :
  32074. * Is the bounding sphere outside the frustum ?
  32075. * If not, are the bounding box vertices outside the frustum ?
  32076. * It not, then the cullable object is in the frustum.
  32077. */
  32078. static readonly CULLINGSTRATEGY_STANDARD: number;
  32079. /** Culling strategy : Bounding Sphere Only.
  32080. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  32081. * It's also less accurate than the standard because some not visible objects can still be selected.
  32082. * Test : is the bounding sphere outside the frustum ?
  32083. * If not, then the cullable object is in the frustum.
  32084. */
  32085. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  32086. /** Culling strategy : Optimistic Inclusion.
  32087. * This in an inclusion test first, then the standard exclusion test.
  32088. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  32089. * 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.
  32090. * Anyway, it's as accurate as the standard strategy.
  32091. * Test :
  32092. * Is the cullable object bounding sphere center in the frustum ?
  32093. * If not, apply the default culling strategy.
  32094. */
  32095. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32096. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32097. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32098. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32099. * 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.
  32100. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32101. * Test :
  32102. * Is the cullable object bounding sphere center in the frustum ?
  32103. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32104. */
  32105. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32106. /**
  32107. * No billboard
  32108. */
  32109. static get BILLBOARDMODE_NONE(): number;
  32110. /** Billboard on X axis */
  32111. static get BILLBOARDMODE_X(): number;
  32112. /** Billboard on Y axis */
  32113. static get BILLBOARDMODE_Y(): number;
  32114. /** Billboard on Z axis */
  32115. static get BILLBOARDMODE_Z(): number;
  32116. /** Billboard on all axes */
  32117. static get BILLBOARDMODE_ALL(): number;
  32118. /** Billboard on using position instead of orientation */
  32119. static get BILLBOARDMODE_USE_POSITION(): number;
  32120. /** @hidden */
  32121. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32122. /**
  32123. * The culling strategy to use to check whether the mesh must be rendered or not.
  32124. * This value can be changed at any time and will be used on the next render mesh selection.
  32125. * The possible values are :
  32126. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32127. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32128. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32129. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32130. * Please read each static variable documentation to get details about the culling process.
  32131. * */
  32132. cullingStrategy: number;
  32133. /**
  32134. * Gets the number of facets in the mesh
  32135. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32136. */
  32137. get facetNb(): number;
  32138. /**
  32139. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32140. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32141. */
  32142. get partitioningSubdivisions(): number;
  32143. set partitioningSubdivisions(nb: number);
  32144. /**
  32145. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32146. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32147. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32148. */
  32149. get partitioningBBoxRatio(): number;
  32150. set partitioningBBoxRatio(ratio: number);
  32151. /**
  32152. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32153. * Works only for updatable meshes.
  32154. * Doesn't work with multi-materials
  32155. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32156. */
  32157. get mustDepthSortFacets(): boolean;
  32158. set mustDepthSortFacets(sort: boolean);
  32159. /**
  32160. * The location (Vector3) where the facet depth sort must be computed from.
  32161. * By default, the active camera position.
  32162. * Used only when facet depth sort is enabled
  32163. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32164. */
  32165. get facetDepthSortFrom(): Vector3;
  32166. set facetDepthSortFrom(location: Vector3);
  32167. /**
  32168. * gets a boolean indicating if facetData is enabled
  32169. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32170. */
  32171. get isFacetDataEnabled(): boolean;
  32172. /** @hidden */
  32173. _updateNonUniformScalingState(value: boolean): boolean;
  32174. /**
  32175. * An event triggered when this mesh collides with another one
  32176. */
  32177. onCollideObservable: Observable<AbstractMesh>;
  32178. /** Set a function to call when this mesh collides with another one */
  32179. set onCollide(callback: () => void);
  32180. /**
  32181. * An event triggered when the collision's position changes
  32182. */
  32183. onCollisionPositionChangeObservable: Observable<Vector3>;
  32184. /** Set a function to call when the collision's position changes */
  32185. set onCollisionPositionChange(callback: () => void);
  32186. /**
  32187. * An event triggered when material is changed
  32188. */
  32189. onMaterialChangedObservable: Observable<AbstractMesh>;
  32190. /**
  32191. * Gets or sets the orientation for POV movement & rotation
  32192. */
  32193. definedFacingForward: boolean;
  32194. /** @hidden */
  32195. _occlusionQuery: Nullable<WebGLQuery>;
  32196. /** @hidden */
  32197. _renderingGroup: Nullable<RenderingGroup>;
  32198. /**
  32199. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32200. */
  32201. get visibility(): number;
  32202. /**
  32203. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32204. */
  32205. set visibility(value: number);
  32206. /** Gets or sets the alpha index used to sort transparent meshes
  32207. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32208. */
  32209. alphaIndex: number;
  32210. /**
  32211. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32212. */
  32213. isVisible: boolean;
  32214. /**
  32215. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32216. */
  32217. isPickable: boolean;
  32218. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32219. showSubMeshesBoundingBox: boolean;
  32220. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32221. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32222. */
  32223. isBlocker: boolean;
  32224. /**
  32225. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32226. */
  32227. enablePointerMoveEvents: boolean;
  32228. private _renderingGroupId;
  32229. /**
  32230. * Specifies the rendering group id for this mesh (0 by default)
  32231. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32232. */
  32233. get renderingGroupId(): number;
  32234. set renderingGroupId(value: number);
  32235. private _material;
  32236. /** Gets or sets current material */
  32237. get material(): Nullable<Material>;
  32238. set material(value: Nullable<Material>);
  32239. /**
  32240. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32241. * @see https://doc.babylonjs.com/babylon101/shadows
  32242. */
  32243. get receiveShadows(): boolean;
  32244. set receiveShadows(value: boolean);
  32245. /** Defines color to use when rendering outline */
  32246. outlineColor: Color3;
  32247. /** Define width to use when rendering outline */
  32248. outlineWidth: number;
  32249. /** Defines color to use when rendering overlay */
  32250. overlayColor: Color3;
  32251. /** Defines alpha to use when rendering overlay */
  32252. overlayAlpha: number;
  32253. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32254. get hasVertexAlpha(): boolean;
  32255. set hasVertexAlpha(value: boolean);
  32256. /** 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) */
  32257. get useVertexColors(): boolean;
  32258. set useVertexColors(value: boolean);
  32259. /**
  32260. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32261. */
  32262. get computeBonesUsingShaders(): boolean;
  32263. set computeBonesUsingShaders(value: boolean);
  32264. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32265. get numBoneInfluencers(): number;
  32266. set numBoneInfluencers(value: number);
  32267. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32268. get applyFog(): boolean;
  32269. set applyFog(value: boolean);
  32270. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32271. useOctreeForRenderingSelection: boolean;
  32272. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32273. useOctreeForPicking: boolean;
  32274. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32275. useOctreeForCollisions: boolean;
  32276. /**
  32277. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32278. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32279. */
  32280. get layerMask(): number;
  32281. set layerMask(value: number);
  32282. /**
  32283. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32284. */
  32285. alwaysSelectAsActiveMesh: boolean;
  32286. /**
  32287. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32288. */
  32289. doNotSyncBoundingInfo: boolean;
  32290. /**
  32291. * Gets or sets the current action manager
  32292. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32293. */
  32294. actionManager: Nullable<AbstractActionManager>;
  32295. private _meshCollisionData;
  32296. /**
  32297. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32298. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32299. */
  32300. ellipsoid: Vector3;
  32301. /**
  32302. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32303. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32304. */
  32305. ellipsoidOffset: Vector3;
  32306. /**
  32307. * Gets or sets a collision mask used to mask collisions (default is -1).
  32308. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32309. */
  32310. get collisionMask(): number;
  32311. set collisionMask(mask: number);
  32312. /**
  32313. * Gets or sets a collision response flag (default is true).
  32314. * when collisionResponse is false, events are still triggered but colliding entity has no response
  32315. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  32316. * to respond to the collision.
  32317. */
  32318. get collisionResponse(): boolean;
  32319. set collisionResponse(response: boolean);
  32320. /**
  32321. * Gets or sets the current collision group mask (-1 by default).
  32322. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32323. */
  32324. get collisionGroup(): number;
  32325. set collisionGroup(mask: number);
  32326. /**
  32327. * Gets or sets current surrounding meshes (null by default).
  32328. *
  32329. * By default collision detection is tested against every mesh in the scene.
  32330. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32331. * meshes will be tested for the collision.
  32332. *
  32333. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32334. */
  32335. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32336. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32337. /**
  32338. * Defines edge width used when edgesRenderer is enabled
  32339. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32340. */
  32341. edgesWidth: number;
  32342. /**
  32343. * Defines edge color used when edgesRenderer is enabled
  32344. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32345. */
  32346. edgesColor: Color4;
  32347. /** @hidden */
  32348. _edgesRenderer: Nullable<IEdgesRenderer>;
  32349. /** @hidden */
  32350. _masterMesh: Nullable<AbstractMesh>;
  32351. /** @hidden */
  32352. _boundingInfo: Nullable<BoundingInfo>;
  32353. /** @hidden */
  32354. _renderId: number;
  32355. /**
  32356. * Gets or sets the list of subMeshes
  32357. * @see https://doc.babylonjs.com/how_to/multi_materials
  32358. */
  32359. subMeshes: SubMesh[];
  32360. /** @hidden */
  32361. _intersectionsInProgress: AbstractMesh[];
  32362. /** @hidden */
  32363. _unIndexed: boolean;
  32364. /** @hidden */
  32365. _lightSources: Light[];
  32366. /** Gets the list of lights affecting that mesh */
  32367. get lightSources(): Light[];
  32368. /** @hidden */
  32369. get _positions(): Nullable<Vector3[]>;
  32370. /** @hidden */
  32371. _waitingData: {
  32372. lods: Nullable<any>;
  32373. actions: Nullable<any>;
  32374. freezeWorldMatrix: Nullable<boolean>;
  32375. };
  32376. /** @hidden */
  32377. _bonesTransformMatrices: Nullable<Float32Array>;
  32378. /** @hidden */
  32379. _transformMatrixTexture: Nullable<RawTexture>;
  32380. /**
  32381. * Gets or sets a skeleton to apply skining transformations
  32382. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32383. */
  32384. set skeleton(value: Nullable<Skeleton>);
  32385. get skeleton(): Nullable<Skeleton>;
  32386. /**
  32387. * An event triggered when the mesh is rebuilt.
  32388. */
  32389. onRebuildObservable: Observable<AbstractMesh>;
  32390. /**
  32391. * Creates a new AbstractMesh
  32392. * @param name defines the name of the mesh
  32393. * @param scene defines the hosting scene
  32394. */
  32395. constructor(name: string, scene?: Nullable<Scene>);
  32396. /**
  32397. * Returns the string "AbstractMesh"
  32398. * @returns "AbstractMesh"
  32399. */
  32400. getClassName(): string;
  32401. /**
  32402. * Gets a string representation of the current mesh
  32403. * @param fullDetails defines a boolean indicating if full details must be included
  32404. * @returns a string representation of the current mesh
  32405. */
  32406. toString(fullDetails?: boolean): string;
  32407. /**
  32408. * @hidden
  32409. */
  32410. protected _getEffectiveParent(): Nullable<Node>;
  32411. /** @hidden */
  32412. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32413. /** @hidden */
  32414. _rebuild(): void;
  32415. /** @hidden */
  32416. _resyncLightSources(): void;
  32417. /** @hidden */
  32418. _resyncLightSource(light: Light): void;
  32419. /** @hidden */
  32420. _unBindEffect(): void;
  32421. /** @hidden */
  32422. _removeLightSource(light: Light, dispose: boolean): void;
  32423. private _markSubMeshesAsDirty;
  32424. /** @hidden */
  32425. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32426. /** @hidden */
  32427. _markSubMeshesAsAttributesDirty(): void;
  32428. /** @hidden */
  32429. _markSubMeshesAsMiscDirty(): void;
  32430. /**
  32431. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32432. */
  32433. get scaling(): Vector3;
  32434. set scaling(newScaling: Vector3);
  32435. /**
  32436. * Returns true if the mesh is blocked. Implemented by child classes
  32437. */
  32438. get isBlocked(): boolean;
  32439. /**
  32440. * Returns the mesh itself by default. Implemented by child classes
  32441. * @param camera defines the camera to use to pick the right LOD level
  32442. * @returns the currentAbstractMesh
  32443. */
  32444. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32445. /**
  32446. * Returns 0 by default. Implemented by child classes
  32447. * @returns an integer
  32448. */
  32449. getTotalVertices(): number;
  32450. /**
  32451. * Returns a positive integer : the total number of indices in this mesh geometry.
  32452. * @returns the numner of indices or zero if the mesh has no geometry.
  32453. */
  32454. getTotalIndices(): number;
  32455. /**
  32456. * Returns null by default. Implemented by child classes
  32457. * @returns null
  32458. */
  32459. getIndices(): Nullable<IndicesArray>;
  32460. /**
  32461. * Returns the array of the requested vertex data kind. Implemented by child classes
  32462. * @param kind defines the vertex data kind to use
  32463. * @returns null
  32464. */
  32465. getVerticesData(kind: string): Nullable<FloatArray>;
  32466. /**
  32467. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32468. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32469. * Note that a new underlying VertexBuffer object is created each call.
  32470. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32471. * @param kind defines vertex data kind:
  32472. * * VertexBuffer.PositionKind
  32473. * * VertexBuffer.UVKind
  32474. * * VertexBuffer.UV2Kind
  32475. * * VertexBuffer.UV3Kind
  32476. * * VertexBuffer.UV4Kind
  32477. * * VertexBuffer.UV5Kind
  32478. * * VertexBuffer.UV6Kind
  32479. * * VertexBuffer.ColorKind
  32480. * * VertexBuffer.MatricesIndicesKind
  32481. * * VertexBuffer.MatricesIndicesExtraKind
  32482. * * VertexBuffer.MatricesWeightsKind
  32483. * * VertexBuffer.MatricesWeightsExtraKind
  32484. * @param data defines the data source
  32485. * @param updatable defines if the data must be flagged as updatable (or static)
  32486. * @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
  32487. * @returns the current mesh
  32488. */
  32489. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32490. /**
  32491. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32492. * If the mesh has no geometry, it is simply returned as it is.
  32493. * @param kind defines vertex data kind:
  32494. * * VertexBuffer.PositionKind
  32495. * * VertexBuffer.UVKind
  32496. * * VertexBuffer.UV2Kind
  32497. * * VertexBuffer.UV3Kind
  32498. * * VertexBuffer.UV4Kind
  32499. * * VertexBuffer.UV5Kind
  32500. * * VertexBuffer.UV6Kind
  32501. * * VertexBuffer.ColorKind
  32502. * * VertexBuffer.MatricesIndicesKind
  32503. * * VertexBuffer.MatricesIndicesExtraKind
  32504. * * VertexBuffer.MatricesWeightsKind
  32505. * * VertexBuffer.MatricesWeightsExtraKind
  32506. * @param data defines the data source
  32507. * @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
  32508. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32509. * @returns the current mesh
  32510. */
  32511. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32512. /**
  32513. * Sets the mesh indices,
  32514. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32515. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32516. * @param totalVertices Defines the total number of vertices
  32517. * @returns the current mesh
  32518. */
  32519. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32520. /**
  32521. * Gets a boolean indicating if specific vertex data is present
  32522. * @param kind defines the vertex data kind to use
  32523. * @returns true is data kind is present
  32524. */
  32525. isVerticesDataPresent(kind: string): boolean;
  32526. /**
  32527. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32528. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32529. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32530. * @returns a BoundingInfo
  32531. */
  32532. getBoundingInfo(): BoundingInfo;
  32533. /**
  32534. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32535. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32536. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32537. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32538. * @returns the current mesh
  32539. */
  32540. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32541. /**
  32542. * Overwrite the current bounding info
  32543. * @param boundingInfo defines the new bounding info
  32544. * @returns the current mesh
  32545. */
  32546. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32547. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32548. get useBones(): boolean;
  32549. /** @hidden */
  32550. _preActivate(): void;
  32551. /** @hidden */
  32552. _preActivateForIntermediateRendering(renderId: number): void;
  32553. /** @hidden */
  32554. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32555. /** @hidden */
  32556. _postActivate(): void;
  32557. /** @hidden */
  32558. _freeze(): void;
  32559. /** @hidden */
  32560. _unFreeze(): void;
  32561. /**
  32562. * Gets the current world matrix
  32563. * @returns a Matrix
  32564. */
  32565. getWorldMatrix(): Matrix;
  32566. /** @hidden */
  32567. _getWorldMatrixDeterminant(): number;
  32568. /**
  32569. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32570. */
  32571. get isAnInstance(): boolean;
  32572. /**
  32573. * Gets a boolean indicating if this mesh has instances
  32574. */
  32575. get hasInstances(): boolean;
  32576. /**
  32577. * Gets a boolean indicating if this mesh has thin instances
  32578. */
  32579. get hasThinInstances(): boolean;
  32580. /**
  32581. * Perform relative position change from the point of view of behind the front of the mesh.
  32582. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32583. * Supports definition of mesh facing forward or backward
  32584. * @param amountRight defines the distance on the right axis
  32585. * @param amountUp defines the distance on the up axis
  32586. * @param amountForward defines the distance on the forward axis
  32587. * @returns the current mesh
  32588. */
  32589. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32590. /**
  32591. * Calculate relative position change from the point of view of behind the front of the mesh.
  32592. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32593. * Supports definition of mesh facing forward or backward
  32594. * @param amountRight defines the distance on the right axis
  32595. * @param amountUp defines the distance on the up axis
  32596. * @param amountForward defines the distance on the forward axis
  32597. * @returns the new displacement vector
  32598. */
  32599. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32600. /**
  32601. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32602. * Supports definition of mesh facing forward or backward
  32603. * @param flipBack defines the flip
  32604. * @param twirlClockwise defines the twirl
  32605. * @param tiltRight defines the tilt
  32606. * @returns the current mesh
  32607. */
  32608. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32609. /**
  32610. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32611. * Supports definition of mesh facing forward or backward.
  32612. * @param flipBack defines the flip
  32613. * @param twirlClockwise defines the twirl
  32614. * @param tiltRight defines the tilt
  32615. * @returns the new rotation vector
  32616. */
  32617. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32618. /**
  32619. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32620. * This means the mesh underlying bounding box and sphere are recomputed.
  32621. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32622. * @returns the current mesh
  32623. */
  32624. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32625. /** @hidden */
  32626. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32627. /** @hidden */
  32628. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32629. /** @hidden */
  32630. _updateBoundingInfo(): AbstractMesh;
  32631. /** @hidden */
  32632. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32633. /** @hidden */
  32634. protected _afterComputeWorldMatrix(): void;
  32635. /** @hidden */
  32636. get _effectiveMesh(): AbstractMesh;
  32637. /**
  32638. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32639. * A mesh is in the frustum if its bounding box intersects the frustum
  32640. * @param frustumPlanes defines the frustum to test
  32641. * @returns true if the mesh is in the frustum planes
  32642. */
  32643. isInFrustum(frustumPlanes: Plane[]): boolean;
  32644. /**
  32645. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32646. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32647. * @param frustumPlanes defines the frustum to test
  32648. * @returns true if the mesh is completely in the frustum planes
  32649. */
  32650. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32651. /**
  32652. * True if the mesh intersects another mesh or a SolidParticle object
  32653. * @param mesh defines a target mesh or SolidParticle to test
  32654. * @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)
  32655. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32656. * @returns true if there is an intersection
  32657. */
  32658. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32659. /**
  32660. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32661. * @param point defines the point to test
  32662. * @returns true if there is an intersection
  32663. */
  32664. intersectsPoint(point: Vector3): boolean;
  32665. /**
  32666. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32667. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32668. */
  32669. get checkCollisions(): boolean;
  32670. set checkCollisions(collisionEnabled: boolean);
  32671. /**
  32672. * Gets Collider object used to compute collisions (not physics)
  32673. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32674. */
  32675. get collider(): Nullable<Collider>;
  32676. /**
  32677. * Move the mesh using collision engine
  32678. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32679. * @param displacement defines the requested displacement vector
  32680. * @returns the current mesh
  32681. */
  32682. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32683. private _onCollisionPositionChange;
  32684. /** @hidden */
  32685. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32686. /** @hidden */
  32687. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32688. /** @hidden */
  32689. _checkCollision(collider: Collider): AbstractMesh;
  32690. /** @hidden */
  32691. _generatePointsArray(): boolean;
  32692. /**
  32693. * Checks if the passed Ray intersects with the mesh
  32694. * @param ray defines the ray to use
  32695. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32696. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32697. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32698. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  32699. * @returns the picking info
  32700. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32701. */
  32702. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  32703. /**
  32704. * Clones the current mesh
  32705. * @param name defines the mesh name
  32706. * @param newParent defines the new mesh parent
  32707. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32708. * @returns the new mesh
  32709. */
  32710. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32711. /**
  32712. * Disposes all the submeshes of the current meshnp
  32713. * @returns the current mesh
  32714. */
  32715. releaseSubMeshes(): AbstractMesh;
  32716. /**
  32717. * Releases resources associated with this abstract mesh.
  32718. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32719. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32720. */
  32721. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32722. /**
  32723. * Adds the passed mesh as a child to the current mesh
  32724. * @param mesh defines the child mesh
  32725. * @returns the current mesh
  32726. */
  32727. addChild(mesh: AbstractMesh): AbstractMesh;
  32728. /**
  32729. * Removes the passed mesh from the current mesh children list
  32730. * @param mesh defines the child mesh
  32731. * @returns the current mesh
  32732. */
  32733. removeChild(mesh: AbstractMesh): AbstractMesh;
  32734. /** @hidden */
  32735. private _initFacetData;
  32736. /**
  32737. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32738. * This method can be called within the render loop.
  32739. * 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
  32740. * @returns the current mesh
  32741. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32742. */
  32743. updateFacetData(): AbstractMesh;
  32744. /**
  32745. * Returns the facetLocalNormals array.
  32746. * The normals are expressed in the mesh local spac
  32747. * @returns an array of Vector3
  32748. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32749. */
  32750. getFacetLocalNormals(): Vector3[];
  32751. /**
  32752. * Returns the facetLocalPositions array.
  32753. * The facet positions are expressed in the mesh local space
  32754. * @returns an array of Vector3
  32755. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32756. */
  32757. getFacetLocalPositions(): Vector3[];
  32758. /**
  32759. * Returns the facetLocalPartioning array
  32760. * @returns an array of array of numbers
  32761. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32762. */
  32763. getFacetLocalPartitioning(): number[][];
  32764. /**
  32765. * Returns the i-th facet position in the world system.
  32766. * This method allocates a new Vector3 per call
  32767. * @param i defines the facet index
  32768. * @returns a new Vector3
  32769. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32770. */
  32771. getFacetPosition(i: number): Vector3;
  32772. /**
  32773. * Sets the reference Vector3 with the i-th facet position in the world system
  32774. * @param i defines the facet index
  32775. * @param ref defines the target vector
  32776. * @returns the current mesh
  32777. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32778. */
  32779. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32780. /**
  32781. * Returns the i-th facet normal in the world system.
  32782. * This method allocates a new Vector3 per call
  32783. * @param i defines the facet index
  32784. * @returns a new Vector3
  32785. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32786. */
  32787. getFacetNormal(i: number): Vector3;
  32788. /**
  32789. * Sets the reference Vector3 with the i-th facet normal in the world system
  32790. * @param i defines the facet index
  32791. * @param ref defines the target vector
  32792. * @returns the current mesh
  32793. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32794. */
  32795. getFacetNormalToRef(i: number, ref: Vector3): this;
  32796. /**
  32797. * 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)
  32798. * @param x defines x coordinate
  32799. * @param y defines y coordinate
  32800. * @param z defines z coordinate
  32801. * @returns the array of facet indexes
  32802. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32803. */
  32804. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32805. /**
  32806. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32807. * @param projected sets as the (x,y,z) world projection on the facet
  32808. * @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
  32809. * @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
  32810. * @param x defines x coordinate
  32811. * @param y defines y coordinate
  32812. * @param z defines z coordinate
  32813. * @returns the face index if found (or null instead)
  32814. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32815. */
  32816. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32817. /**
  32818. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32819. * @param projected sets as the (x,y,z) local projection on the facet
  32820. * @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
  32821. * @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
  32822. * @param x defines x coordinate
  32823. * @param y defines y coordinate
  32824. * @param z defines z coordinate
  32825. * @returns the face index if found (or null instead)
  32826. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32827. */
  32828. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32829. /**
  32830. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32831. * @returns the parameters
  32832. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32833. */
  32834. getFacetDataParameters(): any;
  32835. /**
  32836. * Disables the feature FacetData and frees the related memory
  32837. * @returns the current mesh
  32838. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32839. */
  32840. disableFacetData(): AbstractMesh;
  32841. /**
  32842. * Updates the AbstractMesh indices array
  32843. * @param indices defines the data source
  32844. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32845. * @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)
  32846. * @returns the current mesh
  32847. */
  32848. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32849. /**
  32850. * Creates new normals data for the mesh
  32851. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32852. * @returns the current mesh
  32853. */
  32854. createNormals(updatable: boolean): AbstractMesh;
  32855. /**
  32856. * Align the mesh with a normal
  32857. * @param normal defines the normal to use
  32858. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32859. * @returns the current mesh
  32860. */
  32861. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32862. /** @hidden */
  32863. _checkOcclusionQuery(): boolean;
  32864. /**
  32865. * Disables the mesh edge rendering mode
  32866. * @returns the currentAbstractMesh
  32867. */
  32868. disableEdgesRendering(): AbstractMesh;
  32869. /**
  32870. * Enables the edge rendering mode on the mesh.
  32871. * This mode makes the mesh edges visible
  32872. * @param epsilon defines the maximal distance between two angles to detect a face
  32873. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32874. * @returns the currentAbstractMesh
  32875. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32876. */
  32877. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32878. /**
  32879. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32880. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32881. */
  32882. getConnectedParticleSystems(): IParticleSystem[];
  32883. }
  32884. }
  32885. declare module BABYLON {
  32886. /**
  32887. * Interface used to define ActionEvent
  32888. */
  32889. export interface IActionEvent {
  32890. /** The mesh or sprite that triggered the action */
  32891. source: any;
  32892. /** The X mouse cursor position at the time of the event */
  32893. pointerX: number;
  32894. /** The Y mouse cursor position at the time of the event */
  32895. pointerY: number;
  32896. /** The mesh that is currently pointed at (can be null) */
  32897. meshUnderPointer: Nullable<AbstractMesh>;
  32898. /** the original (browser) event that triggered the ActionEvent */
  32899. sourceEvent?: any;
  32900. /** additional data for the event */
  32901. additionalData?: any;
  32902. }
  32903. /**
  32904. * ActionEvent is the event being sent when an action is triggered.
  32905. */
  32906. export class ActionEvent implements IActionEvent {
  32907. /** The mesh or sprite that triggered the action */
  32908. source: any;
  32909. /** The X mouse cursor position at the time of the event */
  32910. pointerX: number;
  32911. /** The Y mouse cursor position at the time of the event */
  32912. pointerY: number;
  32913. /** The mesh that is currently pointed at (can be null) */
  32914. meshUnderPointer: Nullable<AbstractMesh>;
  32915. /** the original (browser) event that triggered the ActionEvent */
  32916. sourceEvent?: any;
  32917. /** additional data for the event */
  32918. additionalData?: any;
  32919. /**
  32920. * Creates a new ActionEvent
  32921. * @param source The mesh or sprite that triggered the action
  32922. * @param pointerX The X mouse cursor position at the time of the event
  32923. * @param pointerY The Y mouse cursor position at the time of the event
  32924. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32925. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32926. * @param additionalData additional data for the event
  32927. */
  32928. constructor(
  32929. /** The mesh or sprite that triggered the action */
  32930. source: any,
  32931. /** The X mouse cursor position at the time of the event */
  32932. pointerX: number,
  32933. /** The Y mouse cursor position at the time of the event */
  32934. pointerY: number,
  32935. /** The mesh that is currently pointed at (can be null) */
  32936. meshUnderPointer: Nullable<AbstractMesh>,
  32937. /** the original (browser) event that triggered the ActionEvent */
  32938. sourceEvent?: any,
  32939. /** additional data for the event */
  32940. additionalData?: any);
  32941. /**
  32942. * Helper function to auto-create an ActionEvent from a source mesh.
  32943. * @param source The source mesh that triggered the event
  32944. * @param evt The original (browser) event
  32945. * @param additionalData additional data for the event
  32946. * @returns the new ActionEvent
  32947. */
  32948. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32949. /**
  32950. * Helper function to auto-create an ActionEvent from a source sprite
  32951. * @param source The source sprite that triggered the event
  32952. * @param scene Scene associated with the sprite
  32953. * @param evt The original (browser) event
  32954. * @param additionalData additional data for the event
  32955. * @returns the new ActionEvent
  32956. */
  32957. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32958. /**
  32959. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32960. * @param scene the scene where the event occurred
  32961. * @param evt The original (browser) event
  32962. * @returns the new ActionEvent
  32963. */
  32964. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32965. /**
  32966. * Helper function to auto-create an ActionEvent from a primitive
  32967. * @param prim defines the target primitive
  32968. * @param pointerPos defines the pointer position
  32969. * @param evt The original (browser) event
  32970. * @param additionalData additional data for the event
  32971. * @returns the new ActionEvent
  32972. */
  32973. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32974. }
  32975. }
  32976. declare module BABYLON {
  32977. /**
  32978. * Abstract class used to decouple action Manager from scene and meshes.
  32979. * Do not instantiate.
  32980. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32981. */
  32982. export abstract class AbstractActionManager implements IDisposable {
  32983. /** Gets the list of active triggers */
  32984. static Triggers: {
  32985. [key: string]: number;
  32986. };
  32987. /** Gets the cursor to use when hovering items */
  32988. hoverCursor: string;
  32989. /** Gets the list of actions */
  32990. actions: IAction[];
  32991. /**
  32992. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32993. */
  32994. isRecursive: boolean;
  32995. /**
  32996. * Releases all associated resources
  32997. */
  32998. abstract dispose(): void;
  32999. /**
  33000. * Does this action manager has pointer triggers
  33001. */
  33002. abstract get hasPointerTriggers(): boolean;
  33003. /**
  33004. * Does this action manager has pick triggers
  33005. */
  33006. abstract get hasPickTriggers(): boolean;
  33007. /**
  33008. * Process a specific trigger
  33009. * @param trigger defines the trigger to process
  33010. * @param evt defines the event details to be processed
  33011. */
  33012. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  33013. /**
  33014. * Does this action manager handles actions of any of the given triggers
  33015. * @param triggers defines the triggers to be tested
  33016. * @return a boolean indicating whether one (or more) of the triggers is handled
  33017. */
  33018. abstract hasSpecificTriggers(triggers: number[]): boolean;
  33019. /**
  33020. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  33021. * speed.
  33022. * @param triggerA defines the trigger to be tested
  33023. * @param triggerB defines the trigger to be tested
  33024. * @return a boolean indicating whether one (or more) of the triggers is handled
  33025. */
  33026. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  33027. /**
  33028. * Does this action manager handles actions of a given trigger
  33029. * @param trigger defines the trigger to be tested
  33030. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  33031. * @return whether the trigger is handled
  33032. */
  33033. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  33034. /**
  33035. * Serialize this manager to a JSON object
  33036. * @param name defines the property name to store this manager
  33037. * @returns a JSON representation of this manager
  33038. */
  33039. abstract serialize(name: string): any;
  33040. /**
  33041. * Registers an action to this action manager
  33042. * @param action defines the action to be registered
  33043. * @return the action amended (prepared) after registration
  33044. */
  33045. abstract registerAction(action: IAction): Nullable<IAction>;
  33046. /**
  33047. * Unregisters an action to this action manager
  33048. * @param action defines the action to be unregistered
  33049. * @return a boolean indicating whether the action has been unregistered
  33050. */
  33051. abstract unregisterAction(action: IAction): Boolean;
  33052. /**
  33053. * Does exist one action manager with at least one trigger
  33054. **/
  33055. static get HasTriggers(): boolean;
  33056. /**
  33057. * Does exist one action manager with at least one pick trigger
  33058. **/
  33059. static get HasPickTriggers(): boolean;
  33060. /**
  33061. * Does exist one action manager that handles actions of a given trigger
  33062. * @param trigger defines the trigger to be tested
  33063. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  33064. **/
  33065. static HasSpecificTrigger(trigger: number): boolean;
  33066. }
  33067. }
  33068. declare module BABYLON {
  33069. /**
  33070. * Defines how a node can be built from a string name.
  33071. */
  33072. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  33073. /**
  33074. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  33075. */
  33076. export class Node implements IBehaviorAware<Node> {
  33077. /** @hidden */
  33078. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  33079. private static _NodeConstructors;
  33080. /**
  33081. * Add a new node constructor
  33082. * @param type defines the type name of the node to construct
  33083. * @param constructorFunc defines the constructor function
  33084. */
  33085. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  33086. /**
  33087. * Returns a node constructor based on type name
  33088. * @param type defines the type name
  33089. * @param name defines the new node name
  33090. * @param scene defines the hosting scene
  33091. * @param options defines optional options to transmit to constructors
  33092. * @returns the new constructor or null
  33093. */
  33094. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  33095. /**
  33096. * Gets or sets the name of the node
  33097. */
  33098. name: string;
  33099. /**
  33100. * Gets or sets the id of the node
  33101. */
  33102. id: string;
  33103. /**
  33104. * Gets or sets the unique id of the node
  33105. */
  33106. uniqueId: number;
  33107. /**
  33108. * Gets or sets a string used to store user defined state for the node
  33109. */
  33110. state: string;
  33111. /**
  33112. * Gets or sets an object used to store user defined information for the node
  33113. */
  33114. metadata: any;
  33115. /**
  33116. * For internal use only. Please do not use.
  33117. */
  33118. reservedDataStore: any;
  33119. /**
  33120. * List of inspectable custom properties (used by the Inspector)
  33121. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33122. */
  33123. inspectableCustomProperties: IInspectable[];
  33124. private _doNotSerialize;
  33125. /**
  33126. * Gets or sets a boolean used to define if the node must be serialized
  33127. */
  33128. get doNotSerialize(): boolean;
  33129. set doNotSerialize(value: boolean);
  33130. /** @hidden */
  33131. _isDisposed: boolean;
  33132. /**
  33133. * Gets a list of Animations associated with the node
  33134. */
  33135. animations: Animation[];
  33136. protected _ranges: {
  33137. [name: string]: Nullable<AnimationRange>;
  33138. };
  33139. /**
  33140. * Callback raised when the node is ready to be used
  33141. */
  33142. onReady: Nullable<(node: Node) => void>;
  33143. private _isEnabled;
  33144. private _isParentEnabled;
  33145. private _isReady;
  33146. /** @hidden */
  33147. _currentRenderId: number;
  33148. private _parentUpdateId;
  33149. /** @hidden */
  33150. _childUpdateId: number;
  33151. /** @hidden */
  33152. _waitingParentId: Nullable<string>;
  33153. /** @hidden */
  33154. _scene: Scene;
  33155. /** @hidden */
  33156. _cache: any;
  33157. private _parentNode;
  33158. private _children;
  33159. /** @hidden */
  33160. _worldMatrix: Matrix;
  33161. /** @hidden */
  33162. _worldMatrixDeterminant: number;
  33163. /** @hidden */
  33164. _worldMatrixDeterminantIsDirty: boolean;
  33165. /** @hidden */
  33166. private _sceneRootNodesIndex;
  33167. /**
  33168. * Gets a boolean indicating if the node has been disposed
  33169. * @returns true if the node was disposed
  33170. */
  33171. isDisposed(): boolean;
  33172. /**
  33173. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33174. * @see https://doc.babylonjs.com/how_to/parenting
  33175. */
  33176. set parent(parent: Nullable<Node>);
  33177. get parent(): Nullable<Node>;
  33178. /** @hidden */
  33179. _addToSceneRootNodes(): void;
  33180. /** @hidden */
  33181. _removeFromSceneRootNodes(): void;
  33182. private _animationPropertiesOverride;
  33183. /**
  33184. * Gets or sets the animation properties override
  33185. */
  33186. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33187. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33188. /**
  33189. * Gets a string identifying the name of the class
  33190. * @returns "Node" string
  33191. */
  33192. getClassName(): string;
  33193. /** @hidden */
  33194. readonly _isNode: boolean;
  33195. /**
  33196. * An event triggered when the mesh is disposed
  33197. */
  33198. onDisposeObservable: Observable<Node>;
  33199. private _onDisposeObserver;
  33200. /**
  33201. * Sets a callback that will be raised when the node will be disposed
  33202. */
  33203. set onDispose(callback: () => void);
  33204. /**
  33205. * Creates a new Node
  33206. * @param name the name and id to be given to this node
  33207. * @param scene the scene this node will be added to
  33208. */
  33209. constructor(name: string, scene?: Nullable<Scene>);
  33210. /**
  33211. * Gets the scene of the node
  33212. * @returns a scene
  33213. */
  33214. getScene(): Scene;
  33215. /**
  33216. * Gets the engine of the node
  33217. * @returns a Engine
  33218. */
  33219. getEngine(): Engine;
  33220. private _behaviors;
  33221. /**
  33222. * Attach a behavior to the node
  33223. * @see https://doc.babylonjs.com/features/behaviour
  33224. * @param behavior defines the behavior to attach
  33225. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33226. * @returns the current Node
  33227. */
  33228. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33229. /**
  33230. * Remove an attached behavior
  33231. * @see https://doc.babylonjs.com/features/behaviour
  33232. * @param behavior defines the behavior to attach
  33233. * @returns the current Node
  33234. */
  33235. removeBehavior(behavior: Behavior<Node>): Node;
  33236. /**
  33237. * Gets the list of attached behaviors
  33238. * @see https://doc.babylonjs.com/features/behaviour
  33239. */
  33240. get behaviors(): Behavior<Node>[];
  33241. /**
  33242. * Gets an attached behavior by name
  33243. * @param name defines the name of the behavior to look for
  33244. * @see https://doc.babylonjs.com/features/behaviour
  33245. * @returns null if behavior was not found else the requested behavior
  33246. */
  33247. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33248. /**
  33249. * Returns the latest update of the World matrix
  33250. * @returns a Matrix
  33251. */
  33252. getWorldMatrix(): Matrix;
  33253. /** @hidden */
  33254. _getWorldMatrixDeterminant(): number;
  33255. /**
  33256. * Returns directly the latest state of the mesh World matrix.
  33257. * A Matrix is returned.
  33258. */
  33259. get worldMatrixFromCache(): Matrix;
  33260. /** @hidden */
  33261. _initCache(): void;
  33262. /** @hidden */
  33263. updateCache(force?: boolean): void;
  33264. /** @hidden */
  33265. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33266. /** @hidden */
  33267. _updateCache(ignoreParentClass?: boolean): void;
  33268. /** @hidden */
  33269. _isSynchronized(): boolean;
  33270. /** @hidden */
  33271. _markSyncedWithParent(): void;
  33272. /** @hidden */
  33273. isSynchronizedWithParent(): boolean;
  33274. /** @hidden */
  33275. isSynchronized(): boolean;
  33276. /**
  33277. * Is this node ready to be used/rendered
  33278. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33279. * @return true if the node is ready
  33280. */
  33281. isReady(completeCheck?: boolean): boolean;
  33282. /**
  33283. * Is this node enabled?
  33284. * 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
  33285. * @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
  33286. * @return whether this node (and its parent) is enabled
  33287. */
  33288. isEnabled(checkAncestors?: boolean): boolean;
  33289. /** @hidden */
  33290. protected _syncParentEnabledState(): void;
  33291. /**
  33292. * Set the enabled state of this node
  33293. * @param value defines the new enabled state
  33294. */
  33295. setEnabled(value: boolean): void;
  33296. /**
  33297. * Is this node a descendant of the given node?
  33298. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33299. * @param ancestor defines the parent node to inspect
  33300. * @returns a boolean indicating if this node is a descendant of the given node
  33301. */
  33302. isDescendantOf(ancestor: Node): boolean;
  33303. /** @hidden */
  33304. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33305. /**
  33306. * Will return all nodes that have this node as ascendant
  33307. * @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
  33308. * @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
  33309. * @return all children nodes of all types
  33310. */
  33311. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33312. /**
  33313. * Get all child-meshes of this node
  33314. * @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)
  33315. * @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
  33316. * @returns an array of AbstractMesh
  33317. */
  33318. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33319. /**
  33320. * Get all direct children of this node
  33321. * @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
  33322. * @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)
  33323. * @returns an array of Node
  33324. */
  33325. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33326. /** @hidden */
  33327. _setReady(state: boolean): void;
  33328. /**
  33329. * Get an animation by name
  33330. * @param name defines the name of the animation to look for
  33331. * @returns null if not found else the requested animation
  33332. */
  33333. getAnimationByName(name: string): Nullable<Animation>;
  33334. /**
  33335. * Creates an animation range for this node
  33336. * @param name defines the name of the range
  33337. * @param from defines the starting key
  33338. * @param to defines the end key
  33339. */
  33340. createAnimationRange(name: string, from: number, to: number): void;
  33341. /**
  33342. * Delete a specific animation range
  33343. * @param name defines the name of the range to delete
  33344. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33345. */
  33346. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33347. /**
  33348. * Get an animation range by name
  33349. * @param name defines the name of the animation range to look for
  33350. * @returns null if not found else the requested animation range
  33351. */
  33352. getAnimationRange(name: string): Nullable<AnimationRange>;
  33353. /**
  33354. * Gets the list of all animation ranges defined on this node
  33355. * @returns an array
  33356. */
  33357. getAnimationRanges(): Nullable<AnimationRange>[];
  33358. /**
  33359. * Will start the animation sequence
  33360. * @param name defines the range frames for animation sequence
  33361. * @param loop defines if the animation should loop (false by default)
  33362. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33363. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33364. * @returns the object created for this animation. If range does not exist, it will return null
  33365. */
  33366. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33367. /**
  33368. * Serialize animation ranges into a JSON compatible object
  33369. * @returns serialization object
  33370. */
  33371. serializeAnimationRanges(): any;
  33372. /**
  33373. * Computes the world matrix of the node
  33374. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33375. * @returns the world matrix
  33376. */
  33377. computeWorldMatrix(force?: boolean): Matrix;
  33378. /**
  33379. * Releases resources associated with this node.
  33380. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33381. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33382. */
  33383. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33384. /**
  33385. * Parse animation range data from a serialization object and store them into a given node
  33386. * @param node defines where to store the animation ranges
  33387. * @param parsedNode defines the serialization object to read data from
  33388. * @param scene defines the hosting scene
  33389. */
  33390. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33391. /**
  33392. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33393. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33394. * @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
  33395. * @returns the new bounding vectors
  33396. */
  33397. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33398. min: Vector3;
  33399. max: Vector3;
  33400. };
  33401. }
  33402. }
  33403. declare module BABYLON {
  33404. /**
  33405. * @hidden
  33406. */
  33407. export class _IAnimationState {
  33408. key: number;
  33409. repeatCount: number;
  33410. workValue?: any;
  33411. loopMode?: number;
  33412. offsetValue?: any;
  33413. highLimitValue?: any;
  33414. }
  33415. /**
  33416. * Class used to store any kind of animation
  33417. */
  33418. export class Animation {
  33419. /**Name of the animation */
  33420. name: string;
  33421. /**Property to animate */
  33422. targetProperty: string;
  33423. /**The frames per second of the animation */
  33424. framePerSecond: number;
  33425. /**The data type of the animation */
  33426. dataType: number;
  33427. /**The loop mode of the animation */
  33428. loopMode?: number | undefined;
  33429. /**Specifies if blending should be enabled */
  33430. enableBlending?: boolean | undefined;
  33431. /**
  33432. * Use matrix interpolation instead of using direct key value when animating matrices
  33433. */
  33434. static AllowMatricesInterpolation: boolean;
  33435. /**
  33436. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33437. */
  33438. static AllowMatrixDecomposeForInterpolation: boolean;
  33439. /** Define the Url to load snippets */
  33440. static SnippetUrl: string;
  33441. /** Snippet ID if the animation was created from the snippet server */
  33442. snippetId: string;
  33443. /**
  33444. * Stores the key frames of the animation
  33445. */
  33446. private _keys;
  33447. /**
  33448. * Stores the easing function of the animation
  33449. */
  33450. private _easingFunction;
  33451. /**
  33452. * @hidden Internal use only
  33453. */
  33454. _runtimeAnimations: RuntimeAnimation[];
  33455. /**
  33456. * The set of event that will be linked to this animation
  33457. */
  33458. private _events;
  33459. /**
  33460. * Stores an array of target property paths
  33461. */
  33462. targetPropertyPath: string[];
  33463. /**
  33464. * Stores the blending speed of the animation
  33465. */
  33466. blendingSpeed: number;
  33467. /**
  33468. * Stores the animation ranges for the animation
  33469. */
  33470. private _ranges;
  33471. /**
  33472. * @hidden Internal use
  33473. */
  33474. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33475. /**
  33476. * Sets up an animation
  33477. * @param property The property to animate
  33478. * @param animationType The animation type to apply
  33479. * @param framePerSecond The frames per second of the animation
  33480. * @param easingFunction The easing function used in the animation
  33481. * @returns The created animation
  33482. */
  33483. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33484. /**
  33485. * Create and start an animation on a node
  33486. * @param name defines the name of the global animation that will be run on all nodes
  33487. * @param node defines the root node where the animation will take place
  33488. * @param targetProperty defines property to animate
  33489. * @param framePerSecond defines the number of frame per second yo use
  33490. * @param totalFrame defines the number of frames in total
  33491. * @param from defines the initial value
  33492. * @param to defines the final value
  33493. * @param loopMode defines which loop mode you want to use (off by default)
  33494. * @param easingFunction defines the easing function to use (linear by default)
  33495. * @param onAnimationEnd defines the callback to call when animation end
  33496. * @returns the animatable created for this animation
  33497. */
  33498. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33499. /**
  33500. * Create and start an animation on a node and its descendants
  33501. * @param name defines the name of the global animation that will be run on all nodes
  33502. * @param node defines the root node where the animation will take place
  33503. * @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
  33504. * @param targetProperty defines property to animate
  33505. * @param framePerSecond defines the number of frame per second to use
  33506. * @param totalFrame defines the number of frames in total
  33507. * @param from defines the initial value
  33508. * @param to defines the final value
  33509. * @param loopMode defines which loop mode you want to use (off by default)
  33510. * @param easingFunction defines the easing function to use (linear by default)
  33511. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33512. * @returns the list of animatables created for all nodes
  33513. * @example https://www.babylonjs-playground.com/#MH0VLI
  33514. */
  33515. 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[]>;
  33516. /**
  33517. * Creates a new animation, merges it with the existing animations and starts it
  33518. * @param name Name of the animation
  33519. * @param node Node which contains the scene that begins the animations
  33520. * @param targetProperty Specifies which property to animate
  33521. * @param framePerSecond The frames per second of the animation
  33522. * @param totalFrame The total number of frames
  33523. * @param from The frame at the beginning of the animation
  33524. * @param to The frame at the end of the animation
  33525. * @param loopMode Specifies the loop mode of the animation
  33526. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33527. * @param onAnimationEnd Callback to run once the animation is complete
  33528. * @returns Nullable animation
  33529. */
  33530. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33531. /**
  33532. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33533. * @param sourceAnimation defines the Animation containing keyframes to convert
  33534. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33535. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33536. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33537. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33538. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33539. */
  33540. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33541. /**
  33542. * Transition property of an host to the target Value
  33543. * @param property The property to transition
  33544. * @param targetValue The target Value of the property
  33545. * @param host The object where the property to animate belongs
  33546. * @param scene Scene used to run the animation
  33547. * @param frameRate Framerate (in frame/s) to use
  33548. * @param transition The transition type we want to use
  33549. * @param duration The duration of the animation, in milliseconds
  33550. * @param onAnimationEnd Callback trigger at the end of the animation
  33551. * @returns Nullable animation
  33552. */
  33553. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33554. /**
  33555. * Return the array of runtime animations currently using this animation
  33556. */
  33557. get runtimeAnimations(): RuntimeAnimation[];
  33558. /**
  33559. * Specifies if any of the runtime animations are currently running
  33560. */
  33561. get hasRunningRuntimeAnimations(): boolean;
  33562. /**
  33563. * Initializes the animation
  33564. * @param name Name of the animation
  33565. * @param targetProperty Property to animate
  33566. * @param framePerSecond The frames per second of the animation
  33567. * @param dataType The data type of the animation
  33568. * @param loopMode The loop mode of the animation
  33569. * @param enableBlending Specifies if blending should be enabled
  33570. */
  33571. constructor(
  33572. /**Name of the animation */
  33573. name: string,
  33574. /**Property to animate */
  33575. targetProperty: string,
  33576. /**The frames per second of the animation */
  33577. framePerSecond: number,
  33578. /**The data type of the animation */
  33579. dataType: number,
  33580. /**The loop mode of the animation */
  33581. loopMode?: number | undefined,
  33582. /**Specifies if blending should be enabled */
  33583. enableBlending?: boolean | undefined);
  33584. /**
  33585. * Converts the animation to a string
  33586. * @param fullDetails support for multiple levels of logging within scene loading
  33587. * @returns String form of the animation
  33588. */
  33589. toString(fullDetails?: boolean): string;
  33590. /**
  33591. * Add an event to this animation
  33592. * @param event Event to add
  33593. */
  33594. addEvent(event: AnimationEvent): void;
  33595. /**
  33596. * Remove all events found at the given frame
  33597. * @param frame The frame to remove events from
  33598. */
  33599. removeEvents(frame: number): void;
  33600. /**
  33601. * Retrieves all the events from the animation
  33602. * @returns Events from the animation
  33603. */
  33604. getEvents(): AnimationEvent[];
  33605. /**
  33606. * Creates an animation range
  33607. * @param name Name of the animation range
  33608. * @param from Starting frame of the animation range
  33609. * @param to Ending frame of the animation
  33610. */
  33611. createRange(name: string, from: number, to: number): void;
  33612. /**
  33613. * Deletes an animation range by name
  33614. * @param name Name of the animation range to delete
  33615. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33616. */
  33617. deleteRange(name: string, deleteFrames?: boolean): void;
  33618. /**
  33619. * Gets the animation range by name, or null if not defined
  33620. * @param name Name of the animation range
  33621. * @returns Nullable animation range
  33622. */
  33623. getRange(name: string): Nullable<AnimationRange>;
  33624. /**
  33625. * Gets the key frames from the animation
  33626. * @returns The key frames of the animation
  33627. */
  33628. getKeys(): Array<IAnimationKey>;
  33629. /**
  33630. * Gets the highest frame rate of the animation
  33631. * @returns Highest frame rate of the animation
  33632. */
  33633. getHighestFrame(): number;
  33634. /**
  33635. * Gets the easing function of the animation
  33636. * @returns Easing function of the animation
  33637. */
  33638. getEasingFunction(): IEasingFunction;
  33639. /**
  33640. * Sets the easing function of the animation
  33641. * @param easingFunction A custom mathematical formula for animation
  33642. */
  33643. setEasingFunction(easingFunction: EasingFunction): void;
  33644. /**
  33645. * Interpolates a scalar linearly
  33646. * @param startValue Start value of the animation curve
  33647. * @param endValue End value of the animation curve
  33648. * @param gradient Scalar amount to interpolate
  33649. * @returns Interpolated scalar value
  33650. */
  33651. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33652. /**
  33653. * Interpolates a scalar cubically
  33654. * @param startValue Start value of the animation curve
  33655. * @param outTangent End tangent of the animation
  33656. * @param endValue End value of the animation curve
  33657. * @param inTangent Start tangent of the animation curve
  33658. * @param gradient Scalar amount to interpolate
  33659. * @returns Interpolated scalar value
  33660. */
  33661. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33662. /**
  33663. * Interpolates a quaternion using a spherical linear interpolation
  33664. * @param startValue Start value of the animation curve
  33665. * @param endValue End value of the animation curve
  33666. * @param gradient Scalar amount to interpolate
  33667. * @returns Interpolated quaternion value
  33668. */
  33669. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33670. /**
  33671. * Interpolates a quaternion cubically
  33672. * @param startValue Start value of the animation curve
  33673. * @param outTangent End tangent of the animation curve
  33674. * @param endValue End value of the animation curve
  33675. * @param inTangent Start tangent of the animation curve
  33676. * @param gradient Scalar amount to interpolate
  33677. * @returns Interpolated quaternion value
  33678. */
  33679. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33680. /**
  33681. * Interpolates a Vector3 linearl
  33682. * @param startValue Start value of the animation curve
  33683. * @param endValue End value of the animation curve
  33684. * @param gradient Scalar amount to interpolate
  33685. * @returns Interpolated scalar value
  33686. */
  33687. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33688. /**
  33689. * Interpolates a Vector3 cubically
  33690. * @param startValue Start value of the animation curve
  33691. * @param outTangent End tangent of the animation
  33692. * @param endValue End value of the animation curve
  33693. * @param inTangent Start tangent of the animation curve
  33694. * @param gradient Scalar amount to interpolate
  33695. * @returns InterpolatedVector3 value
  33696. */
  33697. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33698. /**
  33699. * Interpolates a Vector2 linearly
  33700. * @param startValue Start value of the animation curve
  33701. * @param endValue End value of the animation curve
  33702. * @param gradient Scalar amount to interpolate
  33703. * @returns Interpolated Vector2 value
  33704. */
  33705. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33706. /**
  33707. * Interpolates a Vector2 cubically
  33708. * @param startValue Start value of the animation curve
  33709. * @param outTangent End tangent of the animation
  33710. * @param endValue End value of the animation curve
  33711. * @param inTangent Start tangent of the animation curve
  33712. * @param gradient Scalar amount to interpolate
  33713. * @returns Interpolated Vector2 value
  33714. */
  33715. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33716. /**
  33717. * Interpolates a size linearly
  33718. * @param startValue Start value of the animation curve
  33719. * @param endValue End value of the animation curve
  33720. * @param gradient Scalar amount to interpolate
  33721. * @returns Interpolated Size value
  33722. */
  33723. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33724. /**
  33725. * Interpolates a Color3 linearly
  33726. * @param startValue Start value of the animation curve
  33727. * @param endValue End value of the animation curve
  33728. * @param gradient Scalar amount to interpolate
  33729. * @returns Interpolated Color3 value
  33730. */
  33731. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33732. /**
  33733. * Interpolates a Color4 linearly
  33734. * @param startValue Start value of the animation curve
  33735. * @param endValue End value of the animation curve
  33736. * @param gradient Scalar amount to interpolate
  33737. * @returns Interpolated Color3 value
  33738. */
  33739. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33740. /**
  33741. * @hidden Internal use only
  33742. */
  33743. _getKeyValue(value: any): any;
  33744. /**
  33745. * @hidden Internal use only
  33746. */
  33747. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33748. /**
  33749. * Defines the function to use to interpolate matrices
  33750. * @param startValue defines the start matrix
  33751. * @param endValue defines the end matrix
  33752. * @param gradient defines the gradient between both matrices
  33753. * @param result defines an optional target matrix where to store the interpolation
  33754. * @returns the interpolated matrix
  33755. */
  33756. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33757. /**
  33758. * Makes a copy of the animation
  33759. * @returns Cloned animation
  33760. */
  33761. clone(): Animation;
  33762. /**
  33763. * Sets the key frames of the animation
  33764. * @param values The animation key frames to set
  33765. */
  33766. setKeys(values: Array<IAnimationKey>): void;
  33767. /**
  33768. * Serializes the animation to an object
  33769. * @returns Serialized object
  33770. */
  33771. serialize(): any;
  33772. /**
  33773. * Float animation type
  33774. */
  33775. static readonly ANIMATIONTYPE_FLOAT: number;
  33776. /**
  33777. * Vector3 animation type
  33778. */
  33779. static readonly ANIMATIONTYPE_VECTOR3: number;
  33780. /**
  33781. * Quaternion animation type
  33782. */
  33783. static readonly ANIMATIONTYPE_QUATERNION: number;
  33784. /**
  33785. * Matrix animation type
  33786. */
  33787. static readonly ANIMATIONTYPE_MATRIX: number;
  33788. /**
  33789. * Color3 animation type
  33790. */
  33791. static readonly ANIMATIONTYPE_COLOR3: number;
  33792. /**
  33793. * Color3 animation type
  33794. */
  33795. static readonly ANIMATIONTYPE_COLOR4: number;
  33796. /**
  33797. * Vector2 animation type
  33798. */
  33799. static readonly ANIMATIONTYPE_VECTOR2: number;
  33800. /**
  33801. * Size animation type
  33802. */
  33803. static readonly ANIMATIONTYPE_SIZE: number;
  33804. /**
  33805. * Relative Loop Mode
  33806. */
  33807. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33808. /**
  33809. * Cycle Loop Mode
  33810. */
  33811. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33812. /**
  33813. * Constant Loop Mode
  33814. */
  33815. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33816. /** @hidden */
  33817. static _UniversalLerp(left: any, right: any, amount: number): any;
  33818. /**
  33819. * Parses an animation object and creates an animation
  33820. * @param parsedAnimation Parsed animation object
  33821. * @returns Animation object
  33822. */
  33823. static Parse(parsedAnimation: any): Animation;
  33824. /**
  33825. * Appends the serialized animations from the source animations
  33826. * @param source Source containing the animations
  33827. * @param destination Target to store the animations
  33828. */
  33829. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33830. /**
  33831. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33832. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33833. * @param url defines the url to load from
  33834. * @returns a promise that will resolve to the new animation or an array of animations
  33835. */
  33836. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33837. /**
  33838. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33839. * @param snippetId defines the snippet to load
  33840. * @returns a promise that will resolve to the new animation or a new array of animations
  33841. */
  33842. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33843. }
  33844. }
  33845. declare module BABYLON {
  33846. /**
  33847. * Interface containing an array of animations
  33848. */
  33849. export interface IAnimatable {
  33850. /**
  33851. * Array of animations
  33852. */
  33853. animations: Nullable<Array<Animation>>;
  33854. }
  33855. }
  33856. declare module BABYLON {
  33857. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33858. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33859. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33860. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33861. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33862. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33863. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33864. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33865. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33866. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33867. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33868. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33869. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33870. /**
  33871. * Decorator used to define property that can be serialized as reference to a camera
  33872. * @param sourceName defines the name of the property to decorate
  33873. */
  33874. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33875. /**
  33876. * Class used to help serialization objects
  33877. */
  33878. export class SerializationHelper {
  33879. /** @hidden */
  33880. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33881. /** @hidden */
  33882. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33883. /** @hidden */
  33884. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33885. /** @hidden */
  33886. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33887. /**
  33888. * Appends the serialized animations from the source animations
  33889. * @param source Source containing the animations
  33890. * @param destination Target to store the animations
  33891. */
  33892. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33893. /**
  33894. * Static function used to serialized a specific entity
  33895. * @param entity defines the entity to serialize
  33896. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33897. * @returns a JSON compatible object representing the serialization of the entity
  33898. */
  33899. static Serialize<T>(entity: T, serializationObject?: any): any;
  33900. /**
  33901. * Creates a new entity from a serialization data object
  33902. * @param creationFunction defines a function used to instanciated the new entity
  33903. * @param source defines the source serialization data
  33904. * @param scene defines the hosting scene
  33905. * @param rootUrl defines the root url for resources
  33906. * @returns a new entity
  33907. */
  33908. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33909. /**
  33910. * Clones an object
  33911. * @param creationFunction defines the function used to instanciate the new object
  33912. * @param source defines the source object
  33913. * @returns the cloned object
  33914. */
  33915. static Clone<T>(creationFunction: () => T, source: T): T;
  33916. /**
  33917. * Instanciates a new object based on a source one (some data will be shared between both object)
  33918. * @param creationFunction defines the function used to instanciate the new object
  33919. * @param source defines the source object
  33920. * @returns the new object
  33921. */
  33922. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33923. }
  33924. }
  33925. declare module BABYLON {
  33926. /**
  33927. * Base class of all the textures in babylon.
  33928. * It groups all the common properties the materials, post process, lights... might need
  33929. * in order to make a correct use of the texture.
  33930. */
  33931. export class BaseTexture implements IAnimatable {
  33932. /**
  33933. * Default anisotropic filtering level for the application.
  33934. * It is set to 4 as a good tradeoff between perf and quality.
  33935. */
  33936. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33937. /**
  33938. * Gets or sets the unique id of the texture
  33939. */
  33940. uniqueId: number;
  33941. /**
  33942. * Define the name of the texture.
  33943. */
  33944. name: string;
  33945. /**
  33946. * Gets or sets an object used to store user defined information.
  33947. */
  33948. metadata: any;
  33949. /**
  33950. * For internal use only. Please do not use.
  33951. */
  33952. reservedDataStore: any;
  33953. private _hasAlpha;
  33954. /**
  33955. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33956. */
  33957. set hasAlpha(value: boolean);
  33958. get hasAlpha(): boolean;
  33959. /**
  33960. * Defines if the alpha value should be determined via the rgb values.
  33961. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33962. */
  33963. getAlphaFromRGB: boolean;
  33964. /**
  33965. * Intensity or strength of the texture.
  33966. * It is commonly used by materials to fine tune the intensity of the texture
  33967. */
  33968. level: number;
  33969. /**
  33970. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33971. * This is part of the texture as textures usually maps to one uv set.
  33972. */
  33973. coordinatesIndex: number;
  33974. protected _coordinatesMode: number;
  33975. /**
  33976. * How a texture is mapped.
  33977. *
  33978. * | Value | Type | Description |
  33979. * | ----- | ----------------------------------- | ----------- |
  33980. * | 0 | EXPLICIT_MODE | |
  33981. * | 1 | SPHERICAL_MODE | |
  33982. * | 2 | PLANAR_MODE | |
  33983. * | 3 | CUBIC_MODE | |
  33984. * | 4 | PROJECTION_MODE | |
  33985. * | 5 | SKYBOX_MODE | |
  33986. * | 6 | INVCUBIC_MODE | |
  33987. * | 7 | EQUIRECTANGULAR_MODE | |
  33988. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33989. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33990. */
  33991. set coordinatesMode(value: number);
  33992. get coordinatesMode(): number;
  33993. private _wrapU;
  33994. /**
  33995. * | Value | Type | Description |
  33996. * | ----- | ------------------ | ----------- |
  33997. * | 0 | CLAMP_ADDRESSMODE | |
  33998. * | 1 | WRAP_ADDRESSMODE | |
  33999. * | 2 | MIRROR_ADDRESSMODE | |
  34000. */
  34001. get wrapU(): number;
  34002. set wrapU(value: number);
  34003. private _wrapV;
  34004. /**
  34005. * | Value | Type | Description |
  34006. * | ----- | ------------------ | ----------- |
  34007. * | 0 | CLAMP_ADDRESSMODE | |
  34008. * | 1 | WRAP_ADDRESSMODE | |
  34009. * | 2 | MIRROR_ADDRESSMODE | |
  34010. */
  34011. get wrapV(): number;
  34012. set wrapV(value: number);
  34013. /**
  34014. * | Value | Type | Description |
  34015. * | ----- | ------------------ | ----------- |
  34016. * | 0 | CLAMP_ADDRESSMODE | |
  34017. * | 1 | WRAP_ADDRESSMODE | |
  34018. * | 2 | MIRROR_ADDRESSMODE | |
  34019. */
  34020. wrapR: number;
  34021. /**
  34022. * With compliant hardware and browser (supporting anisotropic filtering)
  34023. * this defines the level of anisotropic filtering in the texture.
  34024. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  34025. */
  34026. anisotropicFilteringLevel: number;
  34027. /**
  34028. * Define if the texture is a cube texture or if false a 2d texture.
  34029. */
  34030. get isCube(): boolean;
  34031. set isCube(value: boolean);
  34032. /**
  34033. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  34034. */
  34035. get is3D(): boolean;
  34036. set is3D(value: boolean);
  34037. /**
  34038. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  34039. */
  34040. get is2DArray(): boolean;
  34041. set is2DArray(value: boolean);
  34042. private _gammaSpace;
  34043. /**
  34044. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  34045. * HDR texture are usually stored in linear space.
  34046. * This only impacts the PBR and Background materials
  34047. */
  34048. get gammaSpace(): boolean;
  34049. set gammaSpace(gamma: boolean);
  34050. /**
  34051. * Gets or sets whether or not the texture contains RGBD data.
  34052. */
  34053. get isRGBD(): boolean;
  34054. set isRGBD(value: boolean);
  34055. /**
  34056. * Is Z inverted in the texture (useful in a cube texture).
  34057. */
  34058. invertZ: boolean;
  34059. /**
  34060. * Are mip maps generated for this texture or not.
  34061. */
  34062. get noMipmap(): boolean;
  34063. /**
  34064. * @hidden
  34065. */
  34066. lodLevelInAlpha: boolean;
  34067. /**
  34068. * With prefiltered texture, defined the offset used during the prefiltering steps.
  34069. */
  34070. get lodGenerationOffset(): number;
  34071. set lodGenerationOffset(value: number);
  34072. /**
  34073. * With prefiltered texture, defined the scale used during the prefiltering steps.
  34074. */
  34075. get lodGenerationScale(): number;
  34076. set lodGenerationScale(value: number);
  34077. /**
  34078. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  34079. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  34080. * average roughness values.
  34081. */
  34082. get linearSpecularLOD(): boolean;
  34083. set linearSpecularLOD(value: boolean);
  34084. /**
  34085. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  34086. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  34087. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  34088. */
  34089. get irradianceTexture(): Nullable<BaseTexture>;
  34090. set irradianceTexture(value: Nullable<BaseTexture>);
  34091. /**
  34092. * Define if the texture is a render target.
  34093. */
  34094. isRenderTarget: boolean;
  34095. /**
  34096. * Define the unique id of the texture in the scene.
  34097. */
  34098. get uid(): string;
  34099. /** @hidden */
  34100. _prefiltered: boolean;
  34101. /**
  34102. * Return a string representation of the texture.
  34103. * @returns the texture as a string
  34104. */
  34105. toString(): string;
  34106. /**
  34107. * Get the class name of the texture.
  34108. * @returns "BaseTexture"
  34109. */
  34110. getClassName(): string;
  34111. /**
  34112. * Define the list of animation attached to the texture.
  34113. */
  34114. animations: Animation[];
  34115. /**
  34116. * An event triggered when the texture is disposed.
  34117. */
  34118. onDisposeObservable: Observable<BaseTexture>;
  34119. private _onDisposeObserver;
  34120. /**
  34121. * Callback triggered when the texture has been disposed.
  34122. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34123. */
  34124. set onDispose(callback: () => void);
  34125. /**
  34126. * Define the current state of the loading sequence when in delayed load mode.
  34127. */
  34128. delayLoadState: number;
  34129. protected _scene: Nullable<Scene>;
  34130. protected _engine: Nullable<ThinEngine>;
  34131. /** @hidden */
  34132. _texture: Nullable<InternalTexture>;
  34133. private _uid;
  34134. /**
  34135. * Define if the texture is preventinga material to render or not.
  34136. * If not and the texture is not ready, the engine will use a default black texture instead.
  34137. */
  34138. get isBlocking(): boolean;
  34139. /**
  34140. * Instantiates a new BaseTexture.
  34141. * Base class of all the textures in babylon.
  34142. * It groups all the common properties the materials, post process, lights... might need
  34143. * in order to make a correct use of the texture.
  34144. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34145. */
  34146. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34147. /**
  34148. * Get the scene the texture belongs to.
  34149. * @returns the scene or null if undefined
  34150. */
  34151. getScene(): Nullable<Scene>;
  34152. /** @hidden */
  34153. protected _getEngine(): Nullable<ThinEngine>;
  34154. /**
  34155. * Get the texture transform matrix used to offset tile the texture for istance.
  34156. * @returns the transformation matrix
  34157. */
  34158. getTextureMatrix(): Matrix;
  34159. /**
  34160. * Get the texture reflection matrix used to rotate/transform the reflection.
  34161. * @returns the reflection matrix
  34162. */
  34163. getReflectionTextureMatrix(): Matrix;
  34164. /**
  34165. * Get the underlying lower level texture from Babylon.
  34166. * @returns the insternal texture
  34167. */
  34168. getInternalTexture(): Nullable<InternalTexture>;
  34169. /**
  34170. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34171. * @returns true if ready or not blocking
  34172. */
  34173. isReadyOrNotBlocking(): boolean;
  34174. /**
  34175. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34176. * @returns true if fully ready
  34177. */
  34178. isReady(): boolean;
  34179. private _cachedSize;
  34180. /**
  34181. * Get the size of the texture.
  34182. * @returns the texture size.
  34183. */
  34184. getSize(): ISize;
  34185. /**
  34186. * Get the base size of the texture.
  34187. * It can be different from the size if the texture has been resized for POT for instance
  34188. * @returns the base size
  34189. */
  34190. getBaseSize(): ISize;
  34191. /**
  34192. * Update the sampling mode of the texture.
  34193. * Default is Trilinear mode.
  34194. *
  34195. * | Value | Type | Description |
  34196. * | ----- | ------------------ | ----------- |
  34197. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34198. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34199. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34200. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34201. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34202. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34203. * | 7 | NEAREST_LINEAR | |
  34204. * | 8 | NEAREST_NEAREST | |
  34205. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34206. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34207. * | 11 | LINEAR_LINEAR | |
  34208. * | 12 | LINEAR_NEAREST | |
  34209. *
  34210. * > _mag_: magnification filter (close to the viewer)
  34211. * > _min_: minification filter (far from the viewer)
  34212. * > _mip_: filter used between mip map levels
  34213. *@param samplingMode Define the new sampling mode of the texture
  34214. */
  34215. updateSamplingMode(samplingMode: number): void;
  34216. /**
  34217. * Scales the texture if is `canRescale()`
  34218. * @param ratio the resize factor we want to use to rescale
  34219. */
  34220. scale(ratio: number): void;
  34221. /**
  34222. * Get if the texture can rescale.
  34223. */
  34224. get canRescale(): boolean;
  34225. /** @hidden */
  34226. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34227. /** @hidden */
  34228. _rebuild(): void;
  34229. /**
  34230. * Triggers the load sequence in delayed load mode.
  34231. */
  34232. delayLoad(): void;
  34233. /**
  34234. * Clones the texture.
  34235. * @returns the cloned texture
  34236. */
  34237. clone(): Nullable<BaseTexture>;
  34238. /**
  34239. * Get the texture underlying type (INT, FLOAT...)
  34240. */
  34241. get textureType(): number;
  34242. /**
  34243. * Get the texture underlying format (RGB, RGBA...)
  34244. */
  34245. get textureFormat(): number;
  34246. /**
  34247. * Indicates that textures need to be re-calculated for all materials
  34248. */
  34249. protected _markAllSubMeshesAsTexturesDirty(): void;
  34250. /**
  34251. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34252. * This will returns an RGBA array buffer containing either in values (0-255) or
  34253. * float values (0-1) depending of the underlying buffer type.
  34254. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34255. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34256. * @param buffer defines a user defined buffer to fill with data (can be null)
  34257. * @returns The Array buffer containing the pixels data.
  34258. */
  34259. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34260. /**
  34261. * Release and destroy the underlying lower level texture aka internalTexture.
  34262. */
  34263. releaseInternalTexture(): void;
  34264. /** @hidden */
  34265. get _lodTextureHigh(): Nullable<BaseTexture>;
  34266. /** @hidden */
  34267. get _lodTextureMid(): Nullable<BaseTexture>;
  34268. /** @hidden */
  34269. get _lodTextureLow(): Nullable<BaseTexture>;
  34270. /**
  34271. * Dispose the texture and release its associated resources.
  34272. */
  34273. dispose(): void;
  34274. /**
  34275. * Serialize the texture into a JSON representation that can be parsed later on.
  34276. * @returns the JSON representation of the texture
  34277. */
  34278. serialize(): any;
  34279. /**
  34280. * Helper function to be called back once a list of texture contains only ready textures.
  34281. * @param textures Define the list of textures to wait for
  34282. * @param callback Define the callback triggered once the entire list will be ready
  34283. */
  34284. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34285. private static _isScene;
  34286. }
  34287. }
  34288. declare module BABYLON {
  34289. /**
  34290. * Options to be used when creating an effect.
  34291. */
  34292. export interface IEffectCreationOptions {
  34293. /**
  34294. * Atrributes that will be used in the shader.
  34295. */
  34296. attributes: string[];
  34297. /**
  34298. * Uniform varible names that will be set in the shader.
  34299. */
  34300. uniformsNames: string[];
  34301. /**
  34302. * Uniform buffer variable names that will be set in the shader.
  34303. */
  34304. uniformBuffersNames: string[];
  34305. /**
  34306. * Sampler texture variable names that will be set in the shader.
  34307. */
  34308. samplers: string[];
  34309. /**
  34310. * Define statements that will be set in the shader.
  34311. */
  34312. defines: any;
  34313. /**
  34314. * Possible fallbacks for this effect to improve performance when needed.
  34315. */
  34316. fallbacks: Nullable<IEffectFallbacks>;
  34317. /**
  34318. * Callback that will be called when the shader is compiled.
  34319. */
  34320. onCompiled: Nullable<(effect: Effect) => void>;
  34321. /**
  34322. * Callback that will be called if an error occurs during shader compilation.
  34323. */
  34324. onError: Nullable<(effect: Effect, errors: string) => void>;
  34325. /**
  34326. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34327. */
  34328. indexParameters?: any;
  34329. /**
  34330. * Max number of lights that can be used in the shader.
  34331. */
  34332. maxSimultaneousLights?: number;
  34333. /**
  34334. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34335. */
  34336. transformFeedbackVaryings?: Nullable<string[]>;
  34337. /**
  34338. * 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
  34339. */
  34340. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34341. /**
  34342. * Is this effect rendering to several color attachments ?
  34343. */
  34344. multiTarget?: boolean;
  34345. }
  34346. /**
  34347. * Effect containing vertex and fragment shader that can be executed on an object.
  34348. */
  34349. export class Effect implements IDisposable {
  34350. /**
  34351. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34352. */
  34353. static ShadersRepository: string;
  34354. /**
  34355. * Enable logging of the shader code when a compilation error occurs
  34356. */
  34357. static LogShaderCodeOnCompilationError: boolean;
  34358. /**
  34359. * Name of the effect.
  34360. */
  34361. name: any;
  34362. /**
  34363. * String container all the define statements that should be set on the shader.
  34364. */
  34365. defines: string;
  34366. /**
  34367. * Callback that will be called when the shader is compiled.
  34368. */
  34369. onCompiled: Nullable<(effect: Effect) => void>;
  34370. /**
  34371. * Callback that will be called if an error occurs during shader compilation.
  34372. */
  34373. onError: Nullable<(effect: Effect, errors: string) => void>;
  34374. /**
  34375. * Callback that will be called when effect is bound.
  34376. */
  34377. onBind: Nullable<(effect: Effect) => void>;
  34378. /**
  34379. * Unique ID of the effect.
  34380. */
  34381. uniqueId: number;
  34382. /**
  34383. * Observable that will be called when the shader is compiled.
  34384. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34385. */
  34386. onCompileObservable: Observable<Effect>;
  34387. /**
  34388. * Observable that will be called if an error occurs during shader compilation.
  34389. */
  34390. onErrorObservable: Observable<Effect>;
  34391. /** @hidden */
  34392. _onBindObservable: Nullable<Observable<Effect>>;
  34393. /**
  34394. * @hidden
  34395. * Specifies if the effect was previously ready
  34396. */
  34397. _wasPreviouslyReady: boolean;
  34398. /**
  34399. * Observable that will be called when effect is bound.
  34400. */
  34401. get onBindObservable(): Observable<Effect>;
  34402. /** @hidden */
  34403. _bonesComputationForcedToCPU: boolean;
  34404. /** @hidden */
  34405. _multiTarget: boolean;
  34406. private static _uniqueIdSeed;
  34407. private _engine;
  34408. private _uniformBuffersNames;
  34409. private _uniformBuffersNamesList;
  34410. private _uniformsNames;
  34411. private _samplerList;
  34412. private _samplers;
  34413. private _isReady;
  34414. private _compilationError;
  34415. private _allFallbacksProcessed;
  34416. private _attributesNames;
  34417. private _attributes;
  34418. private _attributeLocationByName;
  34419. private _uniforms;
  34420. /**
  34421. * Key for the effect.
  34422. * @hidden
  34423. */
  34424. _key: string;
  34425. private _indexParameters;
  34426. private _fallbacks;
  34427. private _vertexSourceCode;
  34428. private _fragmentSourceCode;
  34429. private _vertexSourceCodeOverride;
  34430. private _fragmentSourceCodeOverride;
  34431. private _transformFeedbackVaryings;
  34432. /**
  34433. * Compiled shader to webGL program.
  34434. * @hidden
  34435. */
  34436. _pipelineContext: Nullable<IPipelineContext>;
  34437. private _valueCache;
  34438. private static _baseCache;
  34439. /**
  34440. * Instantiates an effect.
  34441. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34442. * @param baseName Name of the effect.
  34443. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34444. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34445. * @param samplers List of sampler variables that will be passed to the shader.
  34446. * @param engine Engine to be used to render the effect
  34447. * @param defines Define statements to be added to the shader.
  34448. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34449. * @param onCompiled Callback that will be called when the shader is compiled.
  34450. * @param onError Callback that will be called if an error occurs during shader compilation.
  34451. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34452. */
  34453. 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);
  34454. private _useFinalCode;
  34455. /**
  34456. * Unique key for this effect
  34457. */
  34458. get key(): string;
  34459. /**
  34460. * If the effect has been compiled and prepared.
  34461. * @returns if the effect is compiled and prepared.
  34462. */
  34463. isReady(): boolean;
  34464. private _isReadyInternal;
  34465. /**
  34466. * The engine the effect was initialized with.
  34467. * @returns the engine.
  34468. */
  34469. getEngine(): Engine;
  34470. /**
  34471. * The pipeline context for this effect
  34472. * @returns the associated pipeline context
  34473. */
  34474. getPipelineContext(): Nullable<IPipelineContext>;
  34475. /**
  34476. * The set of names of attribute variables for the shader.
  34477. * @returns An array of attribute names.
  34478. */
  34479. getAttributesNames(): string[];
  34480. /**
  34481. * Returns the attribute at the given index.
  34482. * @param index The index of the attribute.
  34483. * @returns The location of the attribute.
  34484. */
  34485. getAttributeLocation(index: number): number;
  34486. /**
  34487. * Returns the attribute based on the name of the variable.
  34488. * @param name of the attribute to look up.
  34489. * @returns the attribute location.
  34490. */
  34491. getAttributeLocationByName(name: string): number;
  34492. /**
  34493. * The number of attributes.
  34494. * @returns the numnber of attributes.
  34495. */
  34496. getAttributesCount(): number;
  34497. /**
  34498. * Gets the index of a uniform variable.
  34499. * @param uniformName of the uniform to look up.
  34500. * @returns the index.
  34501. */
  34502. getUniformIndex(uniformName: string): number;
  34503. /**
  34504. * Returns the attribute based on the name of the variable.
  34505. * @param uniformName of the uniform to look up.
  34506. * @returns the location of the uniform.
  34507. */
  34508. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34509. /**
  34510. * Returns an array of sampler variable names
  34511. * @returns The array of sampler variable names.
  34512. */
  34513. getSamplers(): string[];
  34514. /**
  34515. * Returns an array of uniform variable names
  34516. * @returns The array of uniform variable names.
  34517. */
  34518. getUniformNames(): string[];
  34519. /**
  34520. * Returns an array of uniform buffer variable names
  34521. * @returns The array of uniform buffer variable names.
  34522. */
  34523. getUniformBuffersNames(): string[];
  34524. /**
  34525. * Returns the index parameters used to create the effect
  34526. * @returns The index parameters object
  34527. */
  34528. getIndexParameters(): any;
  34529. /**
  34530. * The error from the last compilation.
  34531. * @returns the error string.
  34532. */
  34533. getCompilationError(): string;
  34534. /**
  34535. * Gets a boolean indicating that all fallbacks were used during compilation
  34536. * @returns true if all fallbacks were used
  34537. */
  34538. allFallbacksProcessed(): boolean;
  34539. /**
  34540. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34541. * @param func The callback to be used.
  34542. */
  34543. executeWhenCompiled(func: (effect: Effect) => void): void;
  34544. private _checkIsReady;
  34545. private _loadShader;
  34546. /**
  34547. * Gets the vertex shader source code of this effect
  34548. */
  34549. get vertexSourceCode(): string;
  34550. /**
  34551. * Gets the fragment shader source code of this effect
  34552. */
  34553. get fragmentSourceCode(): string;
  34554. /**
  34555. * Recompiles the webGL program
  34556. * @param vertexSourceCode The source code for the vertex shader.
  34557. * @param fragmentSourceCode The source code for the fragment shader.
  34558. * @param onCompiled Callback called when completed.
  34559. * @param onError Callback called on error.
  34560. * @hidden
  34561. */
  34562. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34563. /**
  34564. * Prepares the effect
  34565. * @hidden
  34566. */
  34567. _prepareEffect(): void;
  34568. private _getShaderCodeAndErrorLine;
  34569. private _processCompilationErrors;
  34570. /**
  34571. * Checks if the effect is supported. (Must be called after compilation)
  34572. */
  34573. get isSupported(): boolean;
  34574. /**
  34575. * Binds a texture to the engine to be used as output of the shader.
  34576. * @param channel Name of the output variable.
  34577. * @param texture Texture to bind.
  34578. * @hidden
  34579. */
  34580. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34581. /**
  34582. * Sets a texture on the engine to be used in the shader.
  34583. * @param channel Name of the sampler variable.
  34584. * @param texture Texture to set.
  34585. */
  34586. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34587. /**
  34588. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34589. * @param channel Name of the sampler variable.
  34590. * @param texture Texture to set.
  34591. */
  34592. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34593. /**
  34594. * Sets an array of textures on the engine to be used in the shader.
  34595. * @param channel Name of the variable.
  34596. * @param textures Textures to set.
  34597. */
  34598. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34599. /**
  34600. * 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)
  34601. * @param channel Name of the sampler variable.
  34602. * @param postProcess Post process to get the input texture from.
  34603. */
  34604. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34605. /**
  34606. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34607. * 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)
  34608. * @param channel Name of the sampler variable.
  34609. * @param postProcess Post process to get the output texture from.
  34610. */
  34611. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34612. /** @hidden */
  34613. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34614. /** @hidden */
  34615. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34616. /** @hidden */
  34617. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34618. /** @hidden */
  34619. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34620. /**
  34621. * Binds a buffer to a uniform.
  34622. * @param buffer Buffer to bind.
  34623. * @param name Name of the uniform variable to bind to.
  34624. */
  34625. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34626. /**
  34627. * Binds block to a uniform.
  34628. * @param blockName Name of the block to bind.
  34629. * @param index Index to bind.
  34630. */
  34631. bindUniformBlock(blockName: string, index: number): void;
  34632. /**
  34633. * Sets an interger value on a uniform variable.
  34634. * @param uniformName Name of the variable.
  34635. * @param value Value to be set.
  34636. * @returns this effect.
  34637. */
  34638. setInt(uniformName: string, value: number): Effect;
  34639. /**
  34640. * Sets an int array on a uniform variable.
  34641. * @param uniformName Name of the variable.
  34642. * @param array array to be set.
  34643. * @returns this effect.
  34644. */
  34645. setIntArray(uniformName: string, array: Int32Array): Effect;
  34646. /**
  34647. * 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)
  34648. * @param uniformName Name of the variable.
  34649. * @param array array to be set.
  34650. * @returns this effect.
  34651. */
  34652. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34653. /**
  34654. * 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)
  34655. * @param uniformName Name of the variable.
  34656. * @param array array to be set.
  34657. * @returns this effect.
  34658. */
  34659. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34660. /**
  34661. * 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)
  34662. * @param uniformName Name of the variable.
  34663. * @param array array to be set.
  34664. * @returns this effect.
  34665. */
  34666. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34667. /**
  34668. * Sets an float array on a uniform variable.
  34669. * @param uniformName Name of the variable.
  34670. * @param array array to be set.
  34671. * @returns this effect.
  34672. */
  34673. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34674. /**
  34675. * 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)
  34676. * @param uniformName Name of the variable.
  34677. * @param array array to be set.
  34678. * @returns this effect.
  34679. */
  34680. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34681. /**
  34682. * 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)
  34683. * @param uniformName Name of the variable.
  34684. * @param array array to be set.
  34685. * @returns this effect.
  34686. */
  34687. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34688. /**
  34689. * 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)
  34690. * @param uniformName Name of the variable.
  34691. * @param array array to be set.
  34692. * @returns this effect.
  34693. */
  34694. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34695. /**
  34696. * Sets an array on a uniform variable.
  34697. * @param uniformName Name of the variable.
  34698. * @param array array to be set.
  34699. * @returns this effect.
  34700. */
  34701. setArray(uniformName: string, array: number[]): Effect;
  34702. /**
  34703. * 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)
  34704. * @param uniformName Name of the variable.
  34705. * @param array array to be set.
  34706. * @returns this effect.
  34707. */
  34708. setArray2(uniformName: string, array: number[]): Effect;
  34709. /**
  34710. * 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)
  34711. * @param uniformName Name of the variable.
  34712. * @param array array to be set.
  34713. * @returns this effect.
  34714. */
  34715. setArray3(uniformName: string, array: number[]): Effect;
  34716. /**
  34717. * 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)
  34718. * @param uniformName Name of the variable.
  34719. * @param array array to be set.
  34720. * @returns this effect.
  34721. */
  34722. setArray4(uniformName: string, array: number[]): Effect;
  34723. /**
  34724. * Sets matrices on a uniform variable.
  34725. * @param uniformName Name of the variable.
  34726. * @param matrices matrices to be set.
  34727. * @returns this effect.
  34728. */
  34729. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  34730. /**
  34731. * Sets matrix on a uniform variable.
  34732. * @param uniformName Name of the variable.
  34733. * @param matrix matrix to be set.
  34734. * @returns this effect.
  34735. */
  34736. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34737. /**
  34738. * 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)
  34739. * @param uniformName Name of the variable.
  34740. * @param matrix matrix to be set.
  34741. * @returns this effect.
  34742. */
  34743. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34744. /**
  34745. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34746. * @param uniformName Name of the variable.
  34747. * @param matrix matrix to be set.
  34748. * @returns this effect.
  34749. */
  34750. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34751. /**
  34752. * Sets a float on a uniform variable.
  34753. * @param uniformName Name of the variable.
  34754. * @param value value to be set.
  34755. * @returns this effect.
  34756. */
  34757. setFloat(uniformName: string, value: number): Effect;
  34758. /**
  34759. * Sets a boolean on a uniform variable.
  34760. * @param uniformName Name of the variable.
  34761. * @param bool value to be set.
  34762. * @returns this effect.
  34763. */
  34764. setBool(uniformName: string, bool: boolean): Effect;
  34765. /**
  34766. * Sets a Vector2 on a uniform variable.
  34767. * @param uniformName Name of the variable.
  34768. * @param vector2 vector2 to be set.
  34769. * @returns this effect.
  34770. */
  34771. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34772. /**
  34773. * Sets a float2 on a uniform variable.
  34774. * @param uniformName Name of the variable.
  34775. * @param x First float in float2.
  34776. * @param y Second float in float2.
  34777. * @returns this effect.
  34778. */
  34779. setFloat2(uniformName: string, x: number, y: number): Effect;
  34780. /**
  34781. * Sets a Vector3 on a uniform variable.
  34782. * @param uniformName Name of the variable.
  34783. * @param vector3 Value to be set.
  34784. * @returns this effect.
  34785. */
  34786. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34787. /**
  34788. * Sets a float3 on a uniform variable.
  34789. * @param uniformName Name of the variable.
  34790. * @param x First float in float3.
  34791. * @param y Second float in float3.
  34792. * @param z Third float in float3.
  34793. * @returns this effect.
  34794. */
  34795. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34796. /**
  34797. * Sets a Vector4 on a uniform variable.
  34798. * @param uniformName Name of the variable.
  34799. * @param vector4 Value to be set.
  34800. * @returns this effect.
  34801. */
  34802. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34803. /**
  34804. * Sets a float4 on a uniform variable.
  34805. * @param uniformName Name of the variable.
  34806. * @param x First float in float4.
  34807. * @param y Second float in float4.
  34808. * @param z Third float in float4.
  34809. * @param w Fourth float in float4.
  34810. * @returns this effect.
  34811. */
  34812. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34813. /**
  34814. * Sets a Color3 on a uniform variable.
  34815. * @param uniformName Name of the variable.
  34816. * @param color3 Value to be set.
  34817. * @returns this effect.
  34818. */
  34819. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34820. /**
  34821. * Sets a Color4 on a uniform variable.
  34822. * @param uniformName Name of the variable.
  34823. * @param color3 Value to be set.
  34824. * @param alpha Alpha value to be set.
  34825. * @returns this effect.
  34826. */
  34827. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34828. /**
  34829. * Sets a Color4 on a uniform variable
  34830. * @param uniformName defines the name of the variable
  34831. * @param color4 defines the value to be set
  34832. * @returns this effect.
  34833. */
  34834. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34835. /** Release all associated resources */
  34836. dispose(): void;
  34837. /**
  34838. * This function will add a new shader to the shader store
  34839. * @param name the name of the shader
  34840. * @param pixelShader optional pixel shader content
  34841. * @param vertexShader optional vertex shader content
  34842. */
  34843. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34844. /**
  34845. * Store of each shader (The can be looked up using effect.key)
  34846. */
  34847. static ShadersStore: {
  34848. [key: string]: string;
  34849. };
  34850. /**
  34851. * Store of each included file for a shader (The can be looked up using effect.key)
  34852. */
  34853. static IncludesShadersStore: {
  34854. [key: string]: string;
  34855. };
  34856. /**
  34857. * Resets the cache of effects.
  34858. */
  34859. static ResetCache(): void;
  34860. }
  34861. }
  34862. declare module BABYLON {
  34863. /**
  34864. * Interface used to describe the capabilities of the engine relatively to the current browser
  34865. */
  34866. export interface EngineCapabilities {
  34867. /** Maximum textures units per fragment shader */
  34868. maxTexturesImageUnits: number;
  34869. /** Maximum texture units per vertex shader */
  34870. maxVertexTextureImageUnits: number;
  34871. /** Maximum textures units in the entire pipeline */
  34872. maxCombinedTexturesImageUnits: number;
  34873. /** Maximum texture size */
  34874. maxTextureSize: number;
  34875. /** Maximum texture samples */
  34876. maxSamples?: number;
  34877. /** Maximum cube texture size */
  34878. maxCubemapTextureSize: number;
  34879. /** Maximum render texture size */
  34880. maxRenderTextureSize: number;
  34881. /** Maximum number of vertex attributes */
  34882. maxVertexAttribs: number;
  34883. /** Maximum number of varyings */
  34884. maxVaryingVectors: number;
  34885. /** Maximum number of uniforms per vertex shader */
  34886. maxVertexUniformVectors: number;
  34887. /** Maximum number of uniforms per fragment shader */
  34888. maxFragmentUniformVectors: number;
  34889. /** Defines if standard derivates (dx/dy) are supported */
  34890. standardDerivatives: boolean;
  34891. /** Defines if s3tc texture compression is supported */
  34892. s3tc?: WEBGL_compressed_texture_s3tc;
  34893. /** Defines if pvrtc texture compression is supported */
  34894. pvrtc: any;
  34895. /** Defines if etc1 texture compression is supported */
  34896. etc1: any;
  34897. /** Defines if etc2 texture compression is supported */
  34898. etc2: any;
  34899. /** Defines if astc texture compression is supported */
  34900. astc: any;
  34901. /** Defines if bptc texture compression is supported */
  34902. bptc: any;
  34903. /** Defines if float textures are supported */
  34904. textureFloat: boolean;
  34905. /** Defines if vertex array objects are supported */
  34906. vertexArrayObject: boolean;
  34907. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34908. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34909. /** Gets the maximum level of anisotropy supported */
  34910. maxAnisotropy: number;
  34911. /** Defines if instancing is supported */
  34912. instancedArrays: boolean;
  34913. /** Defines if 32 bits indices are supported */
  34914. uintIndices: boolean;
  34915. /** Defines if high precision shaders are supported */
  34916. highPrecisionShaderSupported: boolean;
  34917. /** Defines if depth reading in the fragment shader is supported */
  34918. fragmentDepthSupported: boolean;
  34919. /** Defines if float texture linear filtering is supported*/
  34920. textureFloatLinearFiltering: boolean;
  34921. /** Defines if rendering to float textures is supported */
  34922. textureFloatRender: boolean;
  34923. /** Defines if half float textures are supported*/
  34924. textureHalfFloat: boolean;
  34925. /** Defines if half float texture linear filtering is supported*/
  34926. textureHalfFloatLinearFiltering: boolean;
  34927. /** Defines if rendering to half float textures is supported */
  34928. textureHalfFloatRender: boolean;
  34929. /** Defines if textureLOD shader command is supported */
  34930. textureLOD: boolean;
  34931. /** Defines if draw buffers extension is supported */
  34932. drawBuffersExtension: boolean;
  34933. /** Defines if depth textures are supported */
  34934. depthTextureExtension: boolean;
  34935. /** Defines if float color buffer are supported */
  34936. colorBufferFloat: boolean;
  34937. /** Gets disjoint timer query extension (null if not supported) */
  34938. timerQuery?: EXT_disjoint_timer_query;
  34939. /** Defines if timestamp can be used with timer query */
  34940. canUseTimestampForTimerQuery: boolean;
  34941. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34942. multiview?: any;
  34943. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34944. oculusMultiview?: any;
  34945. /** Function used to let the system compiles shaders in background */
  34946. parallelShaderCompile?: {
  34947. COMPLETION_STATUS_KHR: number;
  34948. };
  34949. /** Max number of texture samples for MSAA */
  34950. maxMSAASamples: number;
  34951. /** Defines if the blend min max extension is supported */
  34952. blendMinMax: boolean;
  34953. }
  34954. }
  34955. declare module BABYLON {
  34956. /**
  34957. * @hidden
  34958. **/
  34959. export class DepthCullingState {
  34960. private _isDepthTestDirty;
  34961. private _isDepthMaskDirty;
  34962. private _isDepthFuncDirty;
  34963. private _isCullFaceDirty;
  34964. private _isCullDirty;
  34965. private _isZOffsetDirty;
  34966. private _isFrontFaceDirty;
  34967. private _depthTest;
  34968. private _depthMask;
  34969. private _depthFunc;
  34970. private _cull;
  34971. private _cullFace;
  34972. private _zOffset;
  34973. private _frontFace;
  34974. /**
  34975. * Initializes the state.
  34976. */
  34977. constructor();
  34978. get isDirty(): boolean;
  34979. get zOffset(): number;
  34980. set zOffset(value: number);
  34981. get cullFace(): Nullable<number>;
  34982. set cullFace(value: Nullable<number>);
  34983. get cull(): Nullable<boolean>;
  34984. set cull(value: Nullable<boolean>);
  34985. get depthFunc(): Nullable<number>;
  34986. set depthFunc(value: Nullable<number>);
  34987. get depthMask(): boolean;
  34988. set depthMask(value: boolean);
  34989. get depthTest(): boolean;
  34990. set depthTest(value: boolean);
  34991. get frontFace(): Nullable<number>;
  34992. set frontFace(value: Nullable<number>);
  34993. reset(): void;
  34994. apply(gl: WebGLRenderingContext): void;
  34995. }
  34996. }
  34997. declare module BABYLON {
  34998. /**
  34999. * @hidden
  35000. **/
  35001. export class StencilState {
  35002. /** 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 */
  35003. static readonly ALWAYS: number;
  35004. /** Passed to stencilOperation to specify that stencil value must be kept */
  35005. static readonly KEEP: number;
  35006. /** Passed to stencilOperation to specify that stencil value must be replaced */
  35007. static readonly REPLACE: number;
  35008. private _isStencilTestDirty;
  35009. private _isStencilMaskDirty;
  35010. private _isStencilFuncDirty;
  35011. private _isStencilOpDirty;
  35012. private _stencilTest;
  35013. private _stencilMask;
  35014. private _stencilFunc;
  35015. private _stencilFuncRef;
  35016. private _stencilFuncMask;
  35017. private _stencilOpStencilFail;
  35018. private _stencilOpDepthFail;
  35019. private _stencilOpStencilDepthPass;
  35020. get isDirty(): boolean;
  35021. get stencilFunc(): number;
  35022. set stencilFunc(value: number);
  35023. get stencilFuncRef(): number;
  35024. set stencilFuncRef(value: number);
  35025. get stencilFuncMask(): number;
  35026. set stencilFuncMask(value: number);
  35027. get stencilOpStencilFail(): number;
  35028. set stencilOpStencilFail(value: number);
  35029. get stencilOpDepthFail(): number;
  35030. set stencilOpDepthFail(value: number);
  35031. get stencilOpStencilDepthPass(): number;
  35032. set stencilOpStencilDepthPass(value: number);
  35033. get stencilMask(): number;
  35034. set stencilMask(value: number);
  35035. get stencilTest(): boolean;
  35036. set stencilTest(value: boolean);
  35037. constructor();
  35038. reset(): void;
  35039. apply(gl: WebGLRenderingContext): void;
  35040. }
  35041. }
  35042. declare module BABYLON {
  35043. /**
  35044. * @hidden
  35045. **/
  35046. export class AlphaState {
  35047. private _isAlphaBlendDirty;
  35048. private _isBlendFunctionParametersDirty;
  35049. private _isBlendEquationParametersDirty;
  35050. private _isBlendConstantsDirty;
  35051. private _alphaBlend;
  35052. private _blendFunctionParameters;
  35053. private _blendEquationParameters;
  35054. private _blendConstants;
  35055. /**
  35056. * Initializes the state.
  35057. */
  35058. constructor();
  35059. get isDirty(): boolean;
  35060. get alphaBlend(): boolean;
  35061. set alphaBlend(value: boolean);
  35062. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  35063. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  35064. setAlphaEquationParameters(rgb: number, alpha: number): void;
  35065. reset(): void;
  35066. apply(gl: WebGLRenderingContext): void;
  35067. }
  35068. }
  35069. declare module BABYLON {
  35070. /** @hidden */
  35071. export class WebGL2ShaderProcessor implements IShaderProcessor {
  35072. attributeProcessor(attribute: string): string;
  35073. varyingProcessor(varying: string, isFragment: boolean): string;
  35074. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  35075. }
  35076. }
  35077. declare module BABYLON {
  35078. /**
  35079. * Interface for attribute information associated with buffer instanciation
  35080. */
  35081. export interface InstancingAttributeInfo {
  35082. /**
  35083. * Name of the GLSL attribute
  35084. * if attribute index is not specified, this is used to retrieve the index from the effect
  35085. */
  35086. attributeName: string;
  35087. /**
  35088. * Index/offset of the attribute in the vertex shader
  35089. * if not specified, this will be computes from the name.
  35090. */
  35091. index?: number;
  35092. /**
  35093. * size of the attribute, 1, 2, 3 or 4
  35094. */
  35095. attributeSize: number;
  35096. /**
  35097. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  35098. */
  35099. offset: number;
  35100. /**
  35101. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  35102. * default to 1
  35103. */
  35104. divisor?: number;
  35105. /**
  35106. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  35107. * default is FLOAT
  35108. */
  35109. attributeType?: number;
  35110. /**
  35111. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  35112. */
  35113. normalized?: boolean;
  35114. }
  35115. }
  35116. declare module BABYLON {
  35117. interface ThinEngine {
  35118. /**
  35119. * Update a video texture
  35120. * @param texture defines the texture to update
  35121. * @param video defines the video element to use
  35122. * @param invertY defines if data must be stored with Y axis inverted
  35123. */
  35124. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35125. }
  35126. }
  35127. declare module BABYLON {
  35128. interface ThinEngine {
  35129. /**
  35130. * Creates a dynamic texture
  35131. * @param width defines the width of the texture
  35132. * @param height defines the height of the texture
  35133. * @param generateMipMaps defines if the engine should generate the mip levels
  35134. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  35135. * @returns the dynamic texture inside an InternalTexture
  35136. */
  35137. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  35138. /**
  35139. * Update the content of a dynamic texture
  35140. * @param texture defines the texture to update
  35141. * @param canvas defines the canvas containing the source
  35142. * @param invertY defines if data must be stored with Y axis inverted
  35143. * @param premulAlpha defines if alpha is stored as premultiplied
  35144. * @param format defines the format of the data
  35145. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  35146. */
  35147. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  35148. }
  35149. }
  35150. declare module BABYLON {
  35151. /**
  35152. * Settings for finer control over video usage
  35153. */
  35154. export interface VideoTextureSettings {
  35155. /**
  35156. * Applies `autoplay` to video, if specified
  35157. */
  35158. autoPlay?: boolean;
  35159. /**
  35160. * Applies `loop` to video, if specified
  35161. */
  35162. loop?: boolean;
  35163. /**
  35164. * Automatically updates internal texture from video at every frame in the render loop
  35165. */
  35166. autoUpdateTexture: boolean;
  35167. /**
  35168. * Image src displayed during the video loading or until the user interacts with the video.
  35169. */
  35170. poster?: string;
  35171. }
  35172. /**
  35173. * If you want to display a video in your scene, this is the special texture for that.
  35174. * This special texture works similar to other textures, with the exception of a few parameters.
  35175. * @see https://doc.babylonjs.com/how_to/video_texture
  35176. */
  35177. export class VideoTexture extends Texture {
  35178. /**
  35179. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35180. */
  35181. readonly autoUpdateTexture: boolean;
  35182. /**
  35183. * The video instance used by the texture internally
  35184. */
  35185. readonly video: HTMLVideoElement;
  35186. private _onUserActionRequestedObservable;
  35187. /**
  35188. * Event triggerd when a dom action is required by the user to play the video.
  35189. * This happens due to recent changes in browser policies preventing video to auto start.
  35190. */
  35191. get onUserActionRequestedObservable(): Observable<Texture>;
  35192. private _generateMipMaps;
  35193. private _stillImageCaptured;
  35194. private _displayingPosterTexture;
  35195. private _settings;
  35196. private _createInternalTextureOnEvent;
  35197. private _frameId;
  35198. private _currentSrc;
  35199. /**
  35200. * Creates a video texture.
  35201. * If you want to display a video in your scene, this is the special texture for that.
  35202. * This special texture works similar to other textures, with the exception of a few parameters.
  35203. * @see https://doc.babylonjs.com/how_to/video_texture
  35204. * @param name optional name, will detect from video source, if not defined
  35205. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35206. * @param scene is obviously the current scene.
  35207. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35208. * @param invertY is false by default but can be used to invert video on Y axis
  35209. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35210. * @param settings allows finer control over video usage
  35211. */
  35212. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35213. private _getName;
  35214. private _getVideo;
  35215. private _createInternalTexture;
  35216. private reset;
  35217. /**
  35218. * @hidden Internal method to initiate `update`.
  35219. */
  35220. _rebuild(): void;
  35221. /**
  35222. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35223. */
  35224. update(): void;
  35225. /**
  35226. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35227. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35228. */
  35229. updateTexture(isVisible: boolean): void;
  35230. protected _updateInternalTexture: () => void;
  35231. /**
  35232. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35233. * @param url New url.
  35234. */
  35235. updateURL(url: string): void;
  35236. /**
  35237. * Clones the texture.
  35238. * @returns the cloned texture
  35239. */
  35240. clone(): VideoTexture;
  35241. /**
  35242. * Dispose the texture and release its associated resources.
  35243. */
  35244. dispose(): void;
  35245. /**
  35246. * Creates a video texture straight from a stream.
  35247. * @param scene Define the scene the texture should be created in
  35248. * @param stream Define the stream the texture should be created from
  35249. * @returns The created video texture as a promise
  35250. */
  35251. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35252. /**
  35253. * Creates a video texture straight from your WebCam video feed.
  35254. * @param scene Define the scene the texture should be created in
  35255. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35256. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35257. * @returns The created video texture as a promise
  35258. */
  35259. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35260. minWidth: number;
  35261. maxWidth: number;
  35262. minHeight: number;
  35263. maxHeight: number;
  35264. deviceId: string;
  35265. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35266. /**
  35267. * Creates a video texture straight from your WebCam video feed.
  35268. * @param scene Define the scene the texture should be created in
  35269. * @param onReady Define a callback to triggered once the texture will be ready
  35270. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35271. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35272. */
  35273. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35274. minWidth: number;
  35275. maxWidth: number;
  35276. minHeight: number;
  35277. maxHeight: number;
  35278. deviceId: string;
  35279. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35280. }
  35281. }
  35282. declare module BABYLON {
  35283. /**
  35284. * Defines the interface used by objects working like Scene
  35285. * @hidden
  35286. */
  35287. export interface ISceneLike {
  35288. _addPendingData(data: any): void;
  35289. _removePendingData(data: any): void;
  35290. offlineProvider: IOfflineProvider;
  35291. }
  35292. /**
  35293. * Information about the current host
  35294. */
  35295. export interface HostInformation {
  35296. /**
  35297. * Defines if the current host is a mobile
  35298. */
  35299. isMobile: boolean;
  35300. }
  35301. /** Interface defining initialization parameters for Engine class */
  35302. export interface EngineOptions extends WebGLContextAttributes {
  35303. /**
  35304. * Defines if the engine should no exceed a specified device ratio
  35305. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35306. */
  35307. limitDeviceRatio?: number;
  35308. /**
  35309. * Defines if webvr should be enabled automatically
  35310. * @see https://doc.babylonjs.com/how_to/webvr_camera
  35311. */
  35312. autoEnableWebVR?: boolean;
  35313. /**
  35314. * Defines if webgl2 should be turned off even if supported
  35315. * @see https://doc.babylonjs.com/features/webgl2
  35316. */
  35317. disableWebGL2Support?: boolean;
  35318. /**
  35319. * Defines if webaudio should be initialized as well
  35320. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35321. */
  35322. audioEngine?: boolean;
  35323. /**
  35324. * Defines if animations should run using a deterministic lock step
  35325. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35326. */
  35327. deterministicLockstep?: boolean;
  35328. /** Defines the maximum steps to use with deterministic lock step mode */
  35329. lockstepMaxSteps?: number;
  35330. /** Defines the seconds between each deterministic lock step */
  35331. timeStep?: number;
  35332. /**
  35333. * Defines that engine should ignore context lost events
  35334. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35335. */
  35336. doNotHandleContextLost?: boolean;
  35337. /**
  35338. * Defines that engine should ignore modifying touch action attribute and style
  35339. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35340. */
  35341. doNotHandleTouchAction?: boolean;
  35342. /**
  35343. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35344. */
  35345. useHighPrecisionFloats?: boolean;
  35346. /**
  35347. * Make the canvas XR Compatible for XR sessions
  35348. */
  35349. xrCompatible?: boolean;
  35350. /**
  35351. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  35352. */
  35353. useHighPrecisionMatrix?: boolean;
  35354. }
  35355. /**
  35356. * The base engine class (root of all engines)
  35357. */
  35358. export class ThinEngine {
  35359. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35360. static ExceptionList: ({
  35361. key: string;
  35362. capture: string;
  35363. captureConstraint: number;
  35364. targets: string[];
  35365. } | {
  35366. key: string;
  35367. capture: null;
  35368. captureConstraint: null;
  35369. targets: string[];
  35370. })[];
  35371. /** @hidden */
  35372. static _TextureLoaders: IInternalTextureLoader[];
  35373. /**
  35374. * Returns the current npm package of the sdk
  35375. */
  35376. static get NpmPackage(): string;
  35377. /**
  35378. * Returns the current version of the framework
  35379. */
  35380. static get Version(): string;
  35381. /**
  35382. * Returns a string describing the current engine
  35383. */
  35384. get description(): string;
  35385. /**
  35386. * Gets or sets the epsilon value used by collision engine
  35387. */
  35388. static CollisionsEpsilon: number;
  35389. /**
  35390. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35391. */
  35392. static get ShadersRepository(): string;
  35393. static set ShadersRepository(value: string);
  35394. /** @hidden */
  35395. _shaderProcessor: IShaderProcessor;
  35396. /**
  35397. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35398. */
  35399. forcePOTTextures: boolean;
  35400. /**
  35401. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35402. */
  35403. isFullscreen: boolean;
  35404. /**
  35405. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35406. */
  35407. cullBackFaces: boolean;
  35408. /**
  35409. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35410. */
  35411. renderEvenInBackground: boolean;
  35412. /**
  35413. * Gets or sets a boolean indicating that cache can be kept between frames
  35414. */
  35415. preventCacheWipeBetweenFrames: boolean;
  35416. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35417. validateShaderPrograms: boolean;
  35418. /**
  35419. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35420. * This can provide greater z depth for distant objects.
  35421. */
  35422. useReverseDepthBuffer: boolean;
  35423. /**
  35424. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35425. */
  35426. disableUniformBuffers: boolean;
  35427. /** @hidden */
  35428. _uniformBuffers: UniformBuffer[];
  35429. /**
  35430. * Gets a boolean indicating that the engine supports uniform buffers
  35431. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35432. */
  35433. get supportsUniformBuffers(): boolean;
  35434. /** @hidden */
  35435. _gl: WebGLRenderingContext;
  35436. /** @hidden */
  35437. _webGLVersion: number;
  35438. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35439. protected _windowIsBackground: boolean;
  35440. protected _creationOptions: EngineOptions;
  35441. protected _highPrecisionShadersAllowed: boolean;
  35442. /** @hidden */
  35443. get _shouldUseHighPrecisionShader(): boolean;
  35444. /**
  35445. * Gets a boolean indicating that only power of 2 textures are supported
  35446. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35447. */
  35448. get needPOTTextures(): boolean;
  35449. /** @hidden */
  35450. _badOS: boolean;
  35451. /** @hidden */
  35452. _badDesktopOS: boolean;
  35453. private _hardwareScalingLevel;
  35454. /** @hidden */
  35455. _caps: EngineCapabilities;
  35456. private _isStencilEnable;
  35457. private _glVersion;
  35458. private _glRenderer;
  35459. private _glVendor;
  35460. /** @hidden */
  35461. _videoTextureSupported: boolean;
  35462. protected _renderingQueueLaunched: boolean;
  35463. protected _activeRenderLoops: (() => void)[];
  35464. /**
  35465. * Observable signaled when a context lost event is raised
  35466. */
  35467. onContextLostObservable: Observable<ThinEngine>;
  35468. /**
  35469. * Observable signaled when a context restored event is raised
  35470. */
  35471. onContextRestoredObservable: Observable<ThinEngine>;
  35472. private _onContextLost;
  35473. private _onContextRestored;
  35474. protected _contextWasLost: boolean;
  35475. /** @hidden */
  35476. _doNotHandleContextLost: boolean;
  35477. /**
  35478. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35479. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35480. */
  35481. get doNotHandleContextLost(): boolean;
  35482. set doNotHandleContextLost(value: boolean);
  35483. /**
  35484. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35485. */
  35486. disableVertexArrayObjects: boolean;
  35487. /** @hidden */
  35488. protected _colorWrite: boolean;
  35489. /** @hidden */
  35490. protected _colorWriteChanged: boolean;
  35491. /** @hidden */
  35492. protected _depthCullingState: DepthCullingState;
  35493. /** @hidden */
  35494. protected _stencilState: StencilState;
  35495. /** @hidden */
  35496. _alphaState: AlphaState;
  35497. /** @hidden */
  35498. _alphaMode: number;
  35499. /** @hidden */
  35500. _alphaEquation: number;
  35501. /** @hidden */
  35502. _internalTexturesCache: InternalTexture[];
  35503. /** @hidden */
  35504. protected _activeChannel: number;
  35505. private _currentTextureChannel;
  35506. /** @hidden */
  35507. protected _boundTexturesCache: {
  35508. [key: string]: Nullable<InternalTexture>;
  35509. };
  35510. /** @hidden */
  35511. protected _currentEffect: Nullable<Effect>;
  35512. /** @hidden */
  35513. protected _currentProgram: Nullable<WebGLProgram>;
  35514. private _compiledEffects;
  35515. private _vertexAttribArraysEnabled;
  35516. /** @hidden */
  35517. protected _cachedViewport: Nullable<IViewportLike>;
  35518. private _cachedVertexArrayObject;
  35519. /** @hidden */
  35520. protected _cachedVertexBuffers: any;
  35521. /** @hidden */
  35522. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35523. /** @hidden */
  35524. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35525. /** @hidden */
  35526. _currentRenderTarget: Nullable<InternalTexture>;
  35527. private _uintIndicesCurrentlySet;
  35528. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35529. /** @hidden */
  35530. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35531. /** @hidden */
  35532. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35533. private _currentBufferPointers;
  35534. private _currentInstanceLocations;
  35535. private _currentInstanceBuffers;
  35536. private _textureUnits;
  35537. /** @hidden */
  35538. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35539. /** @hidden */
  35540. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35541. /** @hidden */
  35542. _boundRenderFunction: any;
  35543. private _vaoRecordInProgress;
  35544. private _mustWipeVertexAttributes;
  35545. private _emptyTexture;
  35546. private _emptyCubeTexture;
  35547. private _emptyTexture3D;
  35548. private _emptyTexture2DArray;
  35549. /** @hidden */
  35550. _frameHandler: number;
  35551. private _nextFreeTextureSlots;
  35552. private _maxSimultaneousTextures;
  35553. private _activeRequests;
  35554. /** @hidden */
  35555. _transformTextureUrl: Nullable<(url: string) => string>;
  35556. /**
  35557. * Gets information about the current host
  35558. */
  35559. hostInformation: HostInformation;
  35560. protected get _supportsHardwareTextureRescaling(): boolean;
  35561. private _framebufferDimensionsObject;
  35562. /**
  35563. * sets the object from which width and height will be taken from when getting render width and height
  35564. * Will fallback to the gl object
  35565. * @param dimensions the framebuffer width and height that will be used.
  35566. */
  35567. set framebufferDimensionsObject(dimensions: Nullable<{
  35568. framebufferWidth: number;
  35569. framebufferHeight: number;
  35570. }>);
  35571. /**
  35572. * Gets the current viewport
  35573. */
  35574. get currentViewport(): Nullable<IViewportLike>;
  35575. /**
  35576. * Gets the default empty texture
  35577. */
  35578. get emptyTexture(): InternalTexture;
  35579. /**
  35580. * Gets the default empty 3D texture
  35581. */
  35582. get emptyTexture3D(): InternalTexture;
  35583. /**
  35584. * Gets the default empty 2D array texture
  35585. */
  35586. get emptyTexture2DArray(): InternalTexture;
  35587. /**
  35588. * Gets the default empty cube texture
  35589. */
  35590. get emptyCubeTexture(): InternalTexture;
  35591. /**
  35592. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35593. */
  35594. readonly premultipliedAlpha: boolean;
  35595. /**
  35596. * Observable event triggered before each texture is initialized
  35597. */
  35598. onBeforeTextureInitObservable: Observable<Texture>;
  35599. /**
  35600. * Creates a new engine
  35601. * @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
  35602. * @param antialias defines enable antialiasing (default: false)
  35603. * @param options defines further options to be sent to the getContext() function
  35604. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35605. */
  35606. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35607. private _rebuildInternalTextures;
  35608. private _rebuildEffects;
  35609. /**
  35610. * Gets a boolean indicating if all created effects are ready
  35611. * @returns true if all effects are ready
  35612. */
  35613. areAllEffectsReady(): boolean;
  35614. protected _rebuildBuffers(): void;
  35615. protected _initGLContext(): void;
  35616. /**
  35617. * Gets version of the current webGL context
  35618. */
  35619. get webGLVersion(): number;
  35620. /**
  35621. * Gets a string identifying the name of the class
  35622. * @returns "Engine" string
  35623. */
  35624. getClassName(): string;
  35625. /**
  35626. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35627. */
  35628. get isStencilEnable(): boolean;
  35629. /** @hidden */
  35630. _prepareWorkingCanvas(): void;
  35631. /**
  35632. * Reset the texture cache to empty state
  35633. */
  35634. resetTextureCache(): void;
  35635. /**
  35636. * Gets an object containing information about the current webGL context
  35637. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35638. */
  35639. getGlInfo(): {
  35640. vendor: string;
  35641. renderer: string;
  35642. version: string;
  35643. };
  35644. /**
  35645. * Defines the hardware scaling level.
  35646. * By default the hardware scaling level is computed from the window device ratio.
  35647. * 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.
  35648. * @param level defines the level to use
  35649. */
  35650. setHardwareScalingLevel(level: number): void;
  35651. /**
  35652. * Gets the current hardware scaling level.
  35653. * By default the hardware scaling level is computed from the window device ratio.
  35654. * 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.
  35655. * @returns a number indicating the current hardware scaling level
  35656. */
  35657. getHardwareScalingLevel(): number;
  35658. /**
  35659. * Gets the list of loaded textures
  35660. * @returns an array containing all loaded textures
  35661. */
  35662. getLoadedTexturesCache(): InternalTexture[];
  35663. /**
  35664. * Gets the object containing all engine capabilities
  35665. * @returns the EngineCapabilities object
  35666. */
  35667. getCaps(): EngineCapabilities;
  35668. /**
  35669. * stop executing a render loop function and remove it from the execution array
  35670. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35671. */
  35672. stopRenderLoop(renderFunction?: () => void): void;
  35673. /** @hidden */
  35674. _renderLoop(): void;
  35675. /**
  35676. * Gets the HTML canvas attached with the current webGL context
  35677. * @returns a HTML canvas
  35678. */
  35679. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35680. /**
  35681. * Gets host window
  35682. * @returns the host window object
  35683. */
  35684. getHostWindow(): Nullable<Window>;
  35685. /**
  35686. * Gets the current render width
  35687. * @param useScreen defines if screen size must be used (or the current render target if any)
  35688. * @returns a number defining the current render width
  35689. */
  35690. getRenderWidth(useScreen?: boolean): number;
  35691. /**
  35692. * Gets the current render height
  35693. * @param useScreen defines if screen size must be used (or the current render target if any)
  35694. * @returns a number defining the current render height
  35695. */
  35696. getRenderHeight(useScreen?: boolean): number;
  35697. /**
  35698. * Can be used to override the current requestAnimationFrame requester.
  35699. * @hidden
  35700. */
  35701. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35702. /**
  35703. * Register and execute a render loop. The engine can have more than one render function
  35704. * @param renderFunction defines the function to continuously execute
  35705. */
  35706. runRenderLoop(renderFunction: () => void): void;
  35707. /**
  35708. * Clear the current render buffer or the current render target (if any is set up)
  35709. * @param color defines the color to use
  35710. * @param backBuffer defines if the back buffer must be cleared
  35711. * @param depth defines if the depth buffer must be cleared
  35712. * @param stencil defines if the stencil buffer must be cleared
  35713. */
  35714. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35715. private _viewportCached;
  35716. /** @hidden */
  35717. _viewport(x: number, y: number, width: number, height: number): void;
  35718. /**
  35719. * Set the WebGL's viewport
  35720. * @param viewport defines the viewport element to be used
  35721. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35722. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35723. */
  35724. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35725. /**
  35726. * Begin a new frame
  35727. */
  35728. beginFrame(): void;
  35729. /**
  35730. * Enf the current frame
  35731. */
  35732. endFrame(): void;
  35733. /**
  35734. * Resize the view according to the canvas' size
  35735. */
  35736. resize(): void;
  35737. /**
  35738. * Force a specific size of the canvas
  35739. * @param width defines the new canvas' width
  35740. * @param height defines the new canvas' height
  35741. * @returns true if the size was changed
  35742. */
  35743. setSize(width: number, height: number): boolean;
  35744. /**
  35745. * Binds the frame buffer to the specified texture.
  35746. * @param texture The texture to render to or null for the default canvas
  35747. * @param faceIndex The face of the texture to render to in case of cube texture
  35748. * @param requiredWidth The width of the target to render to
  35749. * @param requiredHeight The height of the target to render to
  35750. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35751. * @param lodLevel defines the lod level to bind to the frame buffer
  35752. * @param layer defines the 2d array index to bind to frame buffer to
  35753. */
  35754. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35755. /** @hidden */
  35756. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35757. /**
  35758. * Unbind the current render target texture from the webGL context
  35759. * @param texture defines the render target texture to unbind
  35760. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35761. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35762. */
  35763. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35764. /**
  35765. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35766. */
  35767. flushFramebuffer(): void;
  35768. /**
  35769. * Unbind the current render target and bind the default framebuffer
  35770. */
  35771. restoreDefaultFramebuffer(): void;
  35772. /** @hidden */
  35773. protected _resetVertexBufferBinding(): void;
  35774. /**
  35775. * Creates a vertex buffer
  35776. * @param data the data for the vertex buffer
  35777. * @returns the new WebGL static buffer
  35778. */
  35779. createVertexBuffer(data: DataArray): DataBuffer;
  35780. private _createVertexBuffer;
  35781. /**
  35782. * Creates a dynamic vertex buffer
  35783. * @param data the data for the dynamic vertex buffer
  35784. * @returns the new WebGL dynamic buffer
  35785. */
  35786. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35787. protected _resetIndexBufferBinding(): void;
  35788. /**
  35789. * Creates a new index buffer
  35790. * @param indices defines the content of the index buffer
  35791. * @param updatable defines if the index buffer must be updatable
  35792. * @returns a new webGL buffer
  35793. */
  35794. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35795. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35796. /**
  35797. * Bind a webGL buffer to the webGL context
  35798. * @param buffer defines the buffer to bind
  35799. */
  35800. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35801. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35802. private bindBuffer;
  35803. /**
  35804. * update the bound buffer with the given data
  35805. * @param data defines the data to update
  35806. */
  35807. updateArrayBuffer(data: Float32Array): void;
  35808. private _vertexAttribPointer;
  35809. /** @hidden */
  35810. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35811. private _bindVertexBuffersAttributes;
  35812. /**
  35813. * Records a vertex array object
  35814. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35815. * @param vertexBuffers defines the list of vertex buffers to store
  35816. * @param indexBuffer defines the index buffer to store
  35817. * @param effect defines the effect to store
  35818. * @returns the new vertex array object
  35819. */
  35820. recordVertexArrayObject(vertexBuffers: {
  35821. [key: string]: VertexBuffer;
  35822. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35823. /**
  35824. * Bind a specific vertex array object
  35825. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35826. * @param vertexArrayObject defines the vertex array object to bind
  35827. * @param indexBuffer defines the index buffer to bind
  35828. */
  35829. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35830. /**
  35831. * Bind webGl buffers directly to the webGL context
  35832. * @param vertexBuffer defines the vertex buffer to bind
  35833. * @param indexBuffer defines the index buffer to bind
  35834. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35835. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35836. * @param effect defines the effect associated with the vertex buffer
  35837. */
  35838. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35839. private _unbindVertexArrayObject;
  35840. /**
  35841. * Bind a list of vertex buffers to the webGL context
  35842. * @param vertexBuffers defines the list of vertex buffers to bind
  35843. * @param indexBuffer defines the index buffer to bind
  35844. * @param effect defines the effect associated with the vertex buffers
  35845. */
  35846. bindBuffers(vertexBuffers: {
  35847. [key: string]: Nullable<VertexBuffer>;
  35848. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35849. /**
  35850. * Unbind all instance attributes
  35851. */
  35852. unbindInstanceAttributes(): void;
  35853. /**
  35854. * Release and free the memory of a vertex array object
  35855. * @param vao defines the vertex array object to delete
  35856. */
  35857. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35858. /** @hidden */
  35859. _releaseBuffer(buffer: DataBuffer): boolean;
  35860. protected _deleteBuffer(buffer: DataBuffer): void;
  35861. /**
  35862. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35863. * @param instancesBuffer defines the webGL buffer to update and bind
  35864. * @param data defines the data to store in the buffer
  35865. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35866. */
  35867. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35868. /**
  35869. * Bind the content of a webGL buffer used with instantiation
  35870. * @param instancesBuffer defines the webGL buffer to bind
  35871. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35872. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35873. */
  35874. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35875. /**
  35876. * Disable the instance attribute corresponding to the name in parameter
  35877. * @param name defines the name of the attribute to disable
  35878. */
  35879. disableInstanceAttributeByName(name: string): void;
  35880. /**
  35881. * Disable the instance attribute corresponding to the location in parameter
  35882. * @param attributeLocation defines the attribute location of the attribute to disable
  35883. */
  35884. disableInstanceAttribute(attributeLocation: number): void;
  35885. /**
  35886. * Disable the attribute corresponding to the location in parameter
  35887. * @param attributeLocation defines the attribute location of the attribute to disable
  35888. */
  35889. disableAttributeByIndex(attributeLocation: number): void;
  35890. /**
  35891. * Send a draw order
  35892. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35893. * @param indexStart defines the starting index
  35894. * @param indexCount defines the number of index to draw
  35895. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35896. */
  35897. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35898. /**
  35899. * Draw a list of points
  35900. * @param verticesStart defines the index of first vertex to draw
  35901. * @param verticesCount defines the count of vertices to draw
  35902. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35903. */
  35904. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35905. /**
  35906. * Draw a list of unindexed primitives
  35907. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35908. * @param verticesStart defines the index of first vertex to draw
  35909. * @param verticesCount defines the count of vertices to draw
  35910. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35911. */
  35912. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35913. /**
  35914. * Draw a list of indexed primitives
  35915. * @param fillMode defines the primitive to use
  35916. * @param indexStart defines the starting index
  35917. * @param indexCount defines the number of index to draw
  35918. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35919. */
  35920. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35921. /**
  35922. * Draw a list of unindexed primitives
  35923. * @param fillMode defines the primitive to use
  35924. * @param verticesStart defines the index of first vertex to draw
  35925. * @param verticesCount defines the count of vertices to draw
  35926. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35927. */
  35928. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35929. private _drawMode;
  35930. /** @hidden */
  35931. protected _reportDrawCall(): void;
  35932. /** @hidden */
  35933. _releaseEffect(effect: Effect): void;
  35934. /** @hidden */
  35935. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35936. /**
  35937. * Create a new effect (used to store vertex/fragment shaders)
  35938. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35939. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35940. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35941. * @param samplers defines an array of string used to represent textures
  35942. * @param defines defines the string containing the defines to use to compile the shaders
  35943. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35944. * @param onCompiled defines a function to call when the effect creation is successful
  35945. * @param onError defines a function to call when the effect creation has failed
  35946. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35947. * @returns the new Effect
  35948. */
  35949. 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;
  35950. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35951. private _compileShader;
  35952. private _compileRawShader;
  35953. /** @hidden */
  35954. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35955. /**
  35956. * Directly creates a webGL program
  35957. * @param pipelineContext defines the pipeline context to attach to
  35958. * @param vertexCode defines the vertex shader code to use
  35959. * @param fragmentCode defines the fragment shader code to use
  35960. * @param context defines the webGL context to use (if not set, the current one will be used)
  35961. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35962. * @returns the new webGL program
  35963. */
  35964. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35965. /**
  35966. * Creates a webGL program
  35967. * @param pipelineContext defines the pipeline context to attach to
  35968. * @param vertexCode defines the vertex shader code to use
  35969. * @param fragmentCode defines the fragment shader code to use
  35970. * @param defines defines the string containing the defines to use to compile the shaders
  35971. * @param context defines the webGL context to use (if not set, the current one will be used)
  35972. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35973. * @returns the new webGL program
  35974. */
  35975. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35976. /**
  35977. * Creates a new pipeline context
  35978. * @returns the new pipeline
  35979. */
  35980. createPipelineContext(): IPipelineContext;
  35981. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35982. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35983. /** @hidden */
  35984. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35985. /** @hidden */
  35986. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35987. /** @hidden */
  35988. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35989. /**
  35990. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35991. * @param pipelineContext defines the pipeline context to use
  35992. * @param uniformsNames defines the list of uniform names
  35993. * @returns an array of webGL uniform locations
  35994. */
  35995. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  35996. /**
  35997. * Gets the lsit of active attributes for a given webGL program
  35998. * @param pipelineContext defines the pipeline context to use
  35999. * @param attributesNames defines the list of attribute names to get
  36000. * @returns an array of indices indicating the offset of each attribute
  36001. */
  36002. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  36003. /**
  36004. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  36005. * @param effect defines the effect to activate
  36006. */
  36007. enableEffect(effect: Nullable<Effect>): void;
  36008. /**
  36009. * Set the value of an uniform to a number (int)
  36010. * @param uniform defines the webGL uniform location where to store the value
  36011. * @param value defines the int number to store
  36012. * @returns true if the value was set
  36013. */
  36014. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  36015. /**
  36016. * Set the value of an uniform to an array of int32
  36017. * @param uniform defines the webGL uniform location where to store the value
  36018. * @param array defines the array of int32 to store
  36019. * @returns true if the value was set
  36020. */
  36021. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  36022. /**
  36023. * Set the value of an uniform to an array of int32 (stored as vec2)
  36024. * @param uniform defines the webGL uniform location where to store the value
  36025. * @param array defines the array of int32 to store
  36026. * @returns true if the value was set
  36027. */
  36028. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  36029. /**
  36030. * Set the value of an uniform to an array of int32 (stored as vec3)
  36031. * @param uniform defines the webGL uniform location where to store the value
  36032. * @param array defines the array of int32 to store
  36033. * @returns true if the value was set
  36034. */
  36035. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  36036. /**
  36037. * Set the value of an uniform to an array of int32 (stored as vec4)
  36038. * @param uniform defines the webGL uniform location where to store the value
  36039. * @param array defines the array of int32 to store
  36040. * @returns true if the value was set
  36041. */
  36042. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  36043. /**
  36044. * Set the value of an uniform to an array of number
  36045. * @param uniform defines the webGL uniform location where to store the value
  36046. * @param array defines the array of number to store
  36047. * @returns true if the value was set
  36048. */
  36049. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  36050. /**
  36051. * Set the value of an uniform to an array of number (stored as vec2)
  36052. * @param uniform defines the webGL uniform location where to store the value
  36053. * @param array defines the array of number to store
  36054. * @returns true if the value was set
  36055. */
  36056. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  36057. /**
  36058. * Set the value of an uniform to an array of number (stored as vec3)
  36059. * @param uniform defines the webGL uniform location where to store the value
  36060. * @param array defines the array of number to store
  36061. * @returns true if the value was set
  36062. */
  36063. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  36064. /**
  36065. * Set the value of an uniform to an array of number (stored as vec4)
  36066. * @param uniform defines the webGL uniform location where to store the value
  36067. * @param array defines the array of number to store
  36068. * @returns true if the value was set
  36069. */
  36070. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  36071. /**
  36072. * Set the value of an uniform to an array of float32 (stored as matrices)
  36073. * @param uniform defines the webGL uniform location where to store the value
  36074. * @param matrices defines the array of float32 to store
  36075. * @returns true if the value was set
  36076. */
  36077. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  36078. /**
  36079. * Set the value of an uniform to a matrix (3x3)
  36080. * @param uniform defines the webGL uniform location where to store the value
  36081. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  36082. * @returns true if the value was set
  36083. */
  36084. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  36085. /**
  36086. * Set the value of an uniform to a matrix (2x2)
  36087. * @param uniform defines the webGL uniform location where to store the value
  36088. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  36089. * @returns true if the value was set
  36090. */
  36091. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  36092. /**
  36093. * Set the value of an uniform to a number (float)
  36094. * @param uniform defines the webGL uniform location where to store the value
  36095. * @param value defines the float number to store
  36096. * @returns true if the value was transfered
  36097. */
  36098. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  36099. /**
  36100. * Set the value of an uniform to a vec2
  36101. * @param uniform defines the webGL uniform location where to store the value
  36102. * @param x defines the 1st component of the value
  36103. * @param y defines the 2nd component of the value
  36104. * @returns true if the value was set
  36105. */
  36106. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  36107. /**
  36108. * Set the value of an uniform to a vec3
  36109. * @param uniform defines the webGL uniform location where to store the value
  36110. * @param x defines the 1st component of the value
  36111. * @param y defines the 2nd component of the value
  36112. * @param z defines the 3rd component of the value
  36113. * @returns true if the value was set
  36114. */
  36115. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  36116. /**
  36117. * Set the value of an uniform to a vec4
  36118. * @param uniform defines the webGL uniform location where to store the value
  36119. * @param x defines the 1st component of the value
  36120. * @param y defines the 2nd component of the value
  36121. * @param z defines the 3rd component of the value
  36122. * @param w defines the 4th component of the value
  36123. * @returns true if the value was set
  36124. */
  36125. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  36126. /**
  36127. * Apply all cached states (depth, culling, stencil and alpha)
  36128. */
  36129. applyStates(): void;
  36130. /**
  36131. * Enable or disable color writing
  36132. * @param enable defines the state to set
  36133. */
  36134. setColorWrite(enable: boolean): void;
  36135. /**
  36136. * Gets a boolean indicating if color writing is enabled
  36137. * @returns the current color writing state
  36138. */
  36139. getColorWrite(): boolean;
  36140. /**
  36141. * Gets the depth culling state manager
  36142. */
  36143. get depthCullingState(): DepthCullingState;
  36144. /**
  36145. * Gets the alpha state manager
  36146. */
  36147. get alphaState(): AlphaState;
  36148. /**
  36149. * Gets the stencil state manager
  36150. */
  36151. get stencilState(): StencilState;
  36152. /**
  36153. * Clears the list of texture accessible through engine.
  36154. * This can help preventing texture load conflict due to name collision.
  36155. */
  36156. clearInternalTexturesCache(): void;
  36157. /**
  36158. * Force the entire cache to be cleared
  36159. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36160. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36161. */
  36162. wipeCaches(bruteForce?: boolean): void;
  36163. /** @hidden */
  36164. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36165. min: number;
  36166. mag: number;
  36167. };
  36168. /** @hidden */
  36169. _createTexture(): WebGLTexture;
  36170. /**
  36171. * Usually called from Texture.ts.
  36172. * Passed information to create a WebGLTexture
  36173. * @param url defines a value which contains one of the following:
  36174. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36175. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36176. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36177. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36178. * @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)
  36179. * @param scene needed for loading to the correct scene
  36180. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36181. * @param onLoad optional callback to be called upon successful completion
  36182. * @param onError optional callback to be called upon failure
  36183. * @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
  36184. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36185. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36186. * @param forcedExtension defines the extension to use to pick the right loader
  36187. * @param mimeType defines an optional mime type
  36188. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36189. */
  36190. 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;
  36191. /**
  36192. * Loads an image as an HTMLImageElement.
  36193. * @param input url string, ArrayBuffer, or Blob to load
  36194. * @param onLoad callback called when the image successfully loads
  36195. * @param onError callback called when the image fails to load
  36196. * @param offlineProvider offline provider for caching
  36197. * @param mimeType optional mime type
  36198. * @returns the HTMLImageElement of the loaded image
  36199. * @hidden
  36200. */
  36201. 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>;
  36202. /**
  36203. * @hidden
  36204. */
  36205. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36206. private _unpackFlipYCached;
  36207. /**
  36208. * In case you are sharing the context with other applications, it might
  36209. * be interested to not cache the unpack flip y state to ensure a consistent
  36210. * value would be set.
  36211. */
  36212. enableUnpackFlipYCached: boolean;
  36213. /** @hidden */
  36214. _unpackFlipY(value: boolean): void;
  36215. /** @hidden */
  36216. _getUnpackAlignement(): number;
  36217. private _getTextureTarget;
  36218. /**
  36219. * Update the sampling mode of a given texture
  36220. * @param samplingMode defines the required sampling mode
  36221. * @param texture defines the texture to update
  36222. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36223. */
  36224. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36225. /**
  36226. * Update the sampling mode of a given texture
  36227. * @param texture defines the texture to update
  36228. * @param wrapU defines the texture wrap mode of the u coordinates
  36229. * @param wrapV defines the texture wrap mode of the v coordinates
  36230. * @param wrapR defines the texture wrap mode of the r coordinates
  36231. */
  36232. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36233. /** @hidden */
  36234. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36235. width: number;
  36236. height: number;
  36237. layers?: number;
  36238. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36239. /** @hidden */
  36240. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36241. /** @hidden */
  36242. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36243. /**
  36244. * Update a portion of an internal texture
  36245. * @param texture defines the texture to update
  36246. * @param imageData defines the data to store into the texture
  36247. * @param xOffset defines the x coordinates of the update rectangle
  36248. * @param yOffset defines the y coordinates of the update rectangle
  36249. * @param width defines the width of the update rectangle
  36250. * @param height defines the height of the update rectangle
  36251. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36252. * @param lod defines the lod level to update (0 by default)
  36253. */
  36254. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36255. /** @hidden */
  36256. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36257. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36258. private _prepareWebGLTexture;
  36259. /** @hidden */
  36260. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36261. private _getDepthStencilBuffer;
  36262. /** @hidden */
  36263. _releaseFramebufferObjects(texture: InternalTexture): void;
  36264. /** @hidden */
  36265. _releaseTexture(texture: InternalTexture): void;
  36266. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36267. protected _setProgram(program: WebGLProgram): void;
  36268. protected _boundUniforms: {
  36269. [key: number]: WebGLUniformLocation;
  36270. };
  36271. /**
  36272. * Binds an effect to the webGL context
  36273. * @param effect defines the effect to bind
  36274. */
  36275. bindSamplers(effect: Effect): void;
  36276. private _activateCurrentTexture;
  36277. /** @hidden */
  36278. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36279. /** @hidden */
  36280. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36281. /**
  36282. * Unbind all textures from the webGL context
  36283. */
  36284. unbindAllTextures(): void;
  36285. /**
  36286. * Sets a texture to the according uniform.
  36287. * @param channel The texture channel
  36288. * @param uniform The uniform to set
  36289. * @param texture The texture to apply
  36290. */
  36291. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36292. private _bindSamplerUniformToChannel;
  36293. private _getTextureWrapMode;
  36294. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36295. /**
  36296. * Sets an array of texture to the webGL context
  36297. * @param channel defines the channel where the texture array must be set
  36298. * @param uniform defines the associated uniform location
  36299. * @param textures defines the array of textures to bind
  36300. */
  36301. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36302. /** @hidden */
  36303. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36304. private _setTextureParameterFloat;
  36305. private _setTextureParameterInteger;
  36306. /**
  36307. * Unbind all vertex attributes from the webGL context
  36308. */
  36309. unbindAllAttributes(): void;
  36310. /**
  36311. * 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
  36312. */
  36313. releaseEffects(): void;
  36314. /**
  36315. * Dispose and release all associated resources
  36316. */
  36317. dispose(): void;
  36318. /**
  36319. * Attach a new callback raised when context lost event is fired
  36320. * @param callback defines the callback to call
  36321. */
  36322. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36323. /**
  36324. * Attach a new callback raised when context restored event is fired
  36325. * @param callback defines the callback to call
  36326. */
  36327. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36328. /**
  36329. * Get the current error code of the webGL context
  36330. * @returns the error code
  36331. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36332. */
  36333. getError(): number;
  36334. private _canRenderToFloatFramebuffer;
  36335. private _canRenderToHalfFloatFramebuffer;
  36336. private _canRenderToFramebuffer;
  36337. /** @hidden */
  36338. _getWebGLTextureType(type: number): number;
  36339. /** @hidden */
  36340. _getInternalFormat(format: number): number;
  36341. /** @hidden */
  36342. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36343. /** @hidden */
  36344. _getRGBAMultiSampleBufferFormat(type: number): number;
  36345. /** @hidden */
  36346. _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;
  36347. /**
  36348. * Loads a file from a url
  36349. * @param url url to load
  36350. * @param onSuccess callback called when the file successfully loads
  36351. * @param onProgress callback called while file is loading (if the server supports this mode)
  36352. * @param offlineProvider defines the offline provider for caching
  36353. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36354. * @param onError callback called when the file fails to load
  36355. * @returns a file request object
  36356. * @hidden
  36357. */
  36358. 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;
  36359. /**
  36360. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36361. * @param x defines the x coordinate of the rectangle where pixels must be read
  36362. * @param y defines the y coordinate of the rectangle where pixels must be read
  36363. * @param width defines the width of the rectangle where pixels must be read
  36364. * @param height defines the height of the rectangle where pixels must be read
  36365. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36366. * @returns a Uint8Array containing RGBA colors
  36367. */
  36368. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36369. private static _isSupported;
  36370. /**
  36371. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36372. * @returns true if the engine can be created
  36373. * @ignorenaming
  36374. */
  36375. static isSupported(): boolean;
  36376. /**
  36377. * Find the next highest power of two.
  36378. * @param x Number to start search from.
  36379. * @return Next highest power of two.
  36380. */
  36381. static CeilingPOT(x: number): number;
  36382. /**
  36383. * Find the next lowest power of two.
  36384. * @param x Number to start search from.
  36385. * @return Next lowest power of two.
  36386. */
  36387. static FloorPOT(x: number): number;
  36388. /**
  36389. * Find the nearest power of two.
  36390. * @param x Number to start search from.
  36391. * @return Next nearest power of two.
  36392. */
  36393. static NearestPOT(x: number): number;
  36394. /**
  36395. * Get the closest exponent of two
  36396. * @param value defines the value to approximate
  36397. * @param max defines the maximum value to return
  36398. * @param mode defines how to define the closest value
  36399. * @returns closest exponent of two of the given value
  36400. */
  36401. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36402. /**
  36403. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36404. * @param func - the function to be called
  36405. * @param requester - the object that will request the next frame. Falls back to window.
  36406. * @returns frame number
  36407. */
  36408. static QueueNewFrame(func: () => void, requester?: any): number;
  36409. /**
  36410. * Gets host document
  36411. * @returns the host document object
  36412. */
  36413. getHostDocument(): Nullable<Document>;
  36414. }
  36415. }
  36416. declare module BABYLON {
  36417. /**
  36418. * Class representing spherical harmonics coefficients to the 3rd degree
  36419. */
  36420. export class SphericalHarmonics {
  36421. /**
  36422. * Defines whether or not the harmonics have been prescaled for rendering.
  36423. */
  36424. preScaled: boolean;
  36425. /**
  36426. * The l0,0 coefficients of the spherical harmonics
  36427. */
  36428. l00: Vector3;
  36429. /**
  36430. * The l1,-1 coefficients of the spherical harmonics
  36431. */
  36432. l1_1: Vector3;
  36433. /**
  36434. * The l1,0 coefficients of the spherical harmonics
  36435. */
  36436. l10: Vector3;
  36437. /**
  36438. * The l1,1 coefficients of the spherical harmonics
  36439. */
  36440. l11: Vector3;
  36441. /**
  36442. * The l2,-2 coefficients of the spherical harmonics
  36443. */
  36444. l2_2: Vector3;
  36445. /**
  36446. * The l2,-1 coefficients of the spherical harmonics
  36447. */
  36448. l2_1: Vector3;
  36449. /**
  36450. * The l2,0 coefficients of the spherical harmonics
  36451. */
  36452. l20: Vector3;
  36453. /**
  36454. * The l2,1 coefficients of the spherical harmonics
  36455. */
  36456. l21: Vector3;
  36457. /**
  36458. * The l2,2 coefficients of the spherical harmonics
  36459. */
  36460. l22: Vector3;
  36461. /**
  36462. * Adds a light to the spherical harmonics
  36463. * @param direction the direction of the light
  36464. * @param color the color of the light
  36465. * @param deltaSolidAngle the delta solid angle of the light
  36466. */
  36467. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36468. /**
  36469. * Scales the spherical harmonics by the given amount
  36470. * @param scale the amount to scale
  36471. */
  36472. scaleInPlace(scale: number): void;
  36473. /**
  36474. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36475. *
  36476. * ```
  36477. * E_lm = A_l * L_lm
  36478. * ```
  36479. *
  36480. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36481. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36482. * the scaling factors are given in equation 9.
  36483. */
  36484. convertIncidentRadianceToIrradiance(): void;
  36485. /**
  36486. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36487. *
  36488. * ```
  36489. * L = (1/pi) * E * rho
  36490. * ```
  36491. *
  36492. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36493. */
  36494. convertIrradianceToLambertianRadiance(): void;
  36495. /**
  36496. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36497. * required operations at run time.
  36498. *
  36499. * This is simply done by scaling back the SH with Ylm constants parameter.
  36500. * The trigonometric part being applied by the shader at run time.
  36501. */
  36502. preScaleForRendering(): void;
  36503. /**
  36504. * Constructs a spherical harmonics from an array.
  36505. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36506. * @returns the spherical harmonics
  36507. */
  36508. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36509. /**
  36510. * Gets the spherical harmonics from polynomial
  36511. * @param polynomial the spherical polynomial
  36512. * @returns the spherical harmonics
  36513. */
  36514. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36515. }
  36516. /**
  36517. * Class representing spherical polynomial coefficients to the 3rd degree
  36518. */
  36519. export class SphericalPolynomial {
  36520. private _harmonics;
  36521. /**
  36522. * The spherical harmonics used to create the polynomials.
  36523. */
  36524. get preScaledHarmonics(): SphericalHarmonics;
  36525. /**
  36526. * The x coefficients of the spherical polynomial
  36527. */
  36528. x: Vector3;
  36529. /**
  36530. * The y coefficients of the spherical polynomial
  36531. */
  36532. y: Vector3;
  36533. /**
  36534. * The z coefficients of the spherical polynomial
  36535. */
  36536. z: Vector3;
  36537. /**
  36538. * The xx coefficients of the spherical polynomial
  36539. */
  36540. xx: Vector3;
  36541. /**
  36542. * The yy coefficients of the spherical polynomial
  36543. */
  36544. yy: Vector3;
  36545. /**
  36546. * The zz coefficients of the spherical polynomial
  36547. */
  36548. zz: Vector3;
  36549. /**
  36550. * The xy coefficients of the spherical polynomial
  36551. */
  36552. xy: Vector3;
  36553. /**
  36554. * The yz coefficients of the spherical polynomial
  36555. */
  36556. yz: Vector3;
  36557. /**
  36558. * The zx coefficients of the spherical polynomial
  36559. */
  36560. zx: Vector3;
  36561. /**
  36562. * Adds an ambient color to the spherical polynomial
  36563. * @param color the color to add
  36564. */
  36565. addAmbient(color: Color3): void;
  36566. /**
  36567. * Scales the spherical polynomial by the given amount
  36568. * @param scale the amount to scale
  36569. */
  36570. scaleInPlace(scale: number): void;
  36571. /**
  36572. * Gets the spherical polynomial from harmonics
  36573. * @param harmonics the spherical harmonics
  36574. * @returns the spherical polynomial
  36575. */
  36576. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36577. /**
  36578. * Constructs a spherical polynomial from an array.
  36579. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36580. * @returns the spherical polynomial
  36581. */
  36582. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36583. }
  36584. }
  36585. declare module BABYLON {
  36586. /**
  36587. * Defines the source of the internal texture
  36588. */
  36589. export enum InternalTextureSource {
  36590. /**
  36591. * The source of the texture data is unknown
  36592. */
  36593. Unknown = 0,
  36594. /**
  36595. * Texture data comes from an URL
  36596. */
  36597. Url = 1,
  36598. /**
  36599. * Texture data is only used for temporary storage
  36600. */
  36601. Temp = 2,
  36602. /**
  36603. * Texture data comes from raw data (ArrayBuffer)
  36604. */
  36605. Raw = 3,
  36606. /**
  36607. * Texture content is dynamic (video or dynamic texture)
  36608. */
  36609. Dynamic = 4,
  36610. /**
  36611. * Texture content is generated by rendering to it
  36612. */
  36613. RenderTarget = 5,
  36614. /**
  36615. * Texture content is part of a multi render target process
  36616. */
  36617. MultiRenderTarget = 6,
  36618. /**
  36619. * Texture data comes from a cube data file
  36620. */
  36621. Cube = 7,
  36622. /**
  36623. * Texture data comes from a raw cube data
  36624. */
  36625. CubeRaw = 8,
  36626. /**
  36627. * Texture data come from a prefiltered cube data file
  36628. */
  36629. CubePrefiltered = 9,
  36630. /**
  36631. * Texture content is raw 3D data
  36632. */
  36633. Raw3D = 10,
  36634. /**
  36635. * Texture content is raw 2D array data
  36636. */
  36637. Raw2DArray = 11,
  36638. /**
  36639. * Texture content is a depth texture
  36640. */
  36641. Depth = 12,
  36642. /**
  36643. * Texture data comes from a raw cube data encoded with RGBD
  36644. */
  36645. CubeRawRGBD = 13
  36646. }
  36647. /**
  36648. * Class used to store data associated with WebGL texture data for the engine
  36649. * This class should not be used directly
  36650. */
  36651. export class InternalTexture {
  36652. /** @hidden */
  36653. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36654. /**
  36655. * Defines if the texture is ready
  36656. */
  36657. isReady: boolean;
  36658. /**
  36659. * Defines if the texture is a cube texture
  36660. */
  36661. isCube: boolean;
  36662. /**
  36663. * Defines if the texture contains 3D data
  36664. */
  36665. is3D: boolean;
  36666. /**
  36667. * Defines if the texture contains 2D array data
  36668. */
  36669. is2DArray: boolean;
  36670. /**
  36671. * Defines if the texture contains multiview data
  36672. */
  36673. isMultiview: boolean;
  36674. /**
  36675. * Gets the URL used to load this texture
  36676. */
  36677. url: string;
  36678. /**
  36679. * Gets the sampling mode of the texture
  36680. */
  36681. samplingMode: number;
  36682. /**
  36683. * Gets a boolean indicating if the texture needs mipmaps generation
  36684. */
  36685. generateMipMaps: boolean;
  36686. /**
  36687. * Gets the number of samples used by the texture (WebGL2+ only)
  36688. */
  36689. samples: number;
  36690. /**
  36691. * Gets the type of the texture (int, float...)
  36692. */
  36693. type: number;
  36694. /**
  36695. * Gets the format of the texture (RGB, RGBA...)
  36696. */
  36697. format: number;
  36698. /**
  36699. * Observable called when the texture is loaded
  36700. */
  36701. onLoadedObservable: Observable<InternalTexture>;
  36702. /**
  36703. * Gets the width of the texture
  36704. */
  36705. width: number;
  36706. /**
  36707. * Gets the height of the texture
  36708. */
  36709. height: number;
  36710. /**
  36711. * Gets the depth of the texture
  36712. */
  36713. depth: number;
  36714. /**
  36715. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36716. */
  36717. baseWidth: number;
  36718. /**
  36719. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36720. */
  36721. baseHeight: number;
  36722. /**
  36723. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36724. */
  36725. baseDepth: number;
  36726. /**
  36727. * Gets a boolean indicating if the texture is inverted on Y axis
  36728. */
  36729. invertY: boolean;
  36730. /** @hidden */
  36731. _invertVScale: boolean;
  36732. /** @hidden */
  36733. _associatedChannel: number;
  36734. /** @hidden */
  36735. _source: InternalTextureSource;
  36736. /** @hidden */
  36737. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36738. /** @hidden */
  36739. _bufferView: Nullable<ArrayBufferView>;
  36740. /** @hidden */
  36741. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36742. /** @hidden */
  36743. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36744. /** @hidden */
  36745. _size: number;
  36746. /** @hidden */
  36747. _extension: string;
  36748. /** @hidden */
  36749. _files: Nullable<string[]>;
  36750. /** @hidden */
  36751. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36752. /** @hidden */
  36753. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36754. /** @hidden */
  36755. _framebuffer: Nullable<WebGLFramebuffer>;
  36756. /** @hidden */
  36757. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36758. /** @hidden */
  36759. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36760. /** @hidden */
  36761. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36762. /** @hidden */
  36763. _attachments: Nullable<number[]>;
  36764. /** @hidden */
  36765. _textureArray: Nullable<InternalTexture[]>;
  36766. /** @hidden */
  36767. _cachedCoordinatesMode: Nullable<number>;
  36768. /** @hidden */
  36769. _cachedWrapU: Nullable<number>;
  36770. /** @hidden */
  36771. _cachedWrapV: Nullable<number>;
  36772. /** @hidden */
  36773. _cachedWrapR: Nullable<number>;
  36774. /** @hidden */
  36775. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36776. /** @hidden */
  36777. _isDisabled: boolean;
  36778. /** @hidden */
  36779. _compression: Nullable<string>;
  36780. /** @hidden */
  36781. _generateStencilBuffer: boolean;
  36782. /** @hidden */
  36783. _generateDepthBuffer: boolean;
  36784. /** @hidden */
  36785. _comparisonFunction: number;
  36786. /** @hidden */
  36787. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36788. /** @hidden */
  36789. _lodGenerationScale: number;
  36790. /** @hidden */
  36791. _lodGenerationOffset: number;
  36792. /** @hidden */
  36793. _depthStencilTexture: Nullable<InternalTexture>;
  36794. /** @hidden */
  36795. _colorTextureArray: Nullable<WebGLTexture>;
  36796. /** @hidden */
  36797. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36798. /** @hidden */
  36799. _lodTextureHigh: Nullable<BaseTexture>;
  36800. /** @hidden */
  36801. _lodTextureMid: Nullable<BaseTexture>;
  36802. /** @hidden */
  36803. _lodTextureLow: Nullable<BaseTexture>;
  36804. /** @hidden */
  36805. _isRGBD: boolean;
  36806. /** @hidden */
  36807. _linearSpecularLOD: boolean;
  36808. /** @hidden */
  36809. _irradianceTexture: Nullable<BaseTexture>;
  36810. /** @hidden */
  36811. _webGLTexture: Nullable<WebGLTexture>;
  36812. /** @hidden */
  36813. _references: number;
  36814. /** @hidden */
  36815. _gammaSpace: Nullable<boolean>;
  36816. private _engine;
  36817. /**
  36818. * Gets the Engine the texture belongs to.
  36819. * @returns The babylon engine
  36820. */
  36821. getEngine(): ThinEngine;
  36822. /**
  36823. * Gets the data source type of the texture
  36824. */
  36825. get source(): InternalTextureSource;
  36826. /**
  36827. * Creates a new InternalTexture
  36828. * @param engine defines the engine to use
  36829. * @param source defines the type of data that will be used
  36830. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36831. */
  36832. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36833. /**
  36834. * Increments the number of references (ie. the number of Texture that point to it)
  36835. */
  36836. incrementReferences(): void;
  36837. /**
  36838. * Change the size of the texture (not the size of the content)
  36839. * @param width defines the new width
  36840. * @param height defines the new height
  36841. * @param depth defines the new depth (1 by default)
  36842. */
  36843. updateSize(width: int, height: int, depth?: int): void;
  36844. /** @hidden */
  36845. _rebuild(): void;
  36846. /** @hidden */
  36847. _swapAndDie(target: InternalTexture): void;
  36848. /**
  36849. * Dispose the current allocated resources
  36850. */
  36851. dispose(): void;
  36852. }
  36853. }
  36854. declare module BABYLON {
  36855. /**
  36856. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36857. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36858. */
  36859. export class Analyser {
  36860. /**
  36861. * Gets or sets the smoothing
  36862. * @ignorenaming
  36863. */
  36864. SMOOTHING: number;
  36865. /**
  36866. * Gets or sets the FFT table size
  36867. * @ignorenaming
  36868. */
  36869. FFT_SIZE: number;
  36870. /**
  36871. * Gets or sets the bar graph amplitude
  36872. * @ignorenaming
  36873. */
  36874. BARGRAPHAMPLITUDE: number;
  36875. /**
  36876. * Gets or sets the position of the debug canvas
  36877. * @ignorenaming
  36878. */
  36879. DEBUGCANVASPOS: {
  36880. x: number;
  36881. y: number;
  36882. };
  36883. /**
  36884. * Gets or sets the debug canvas size
  36885. * @ignorenaming
  36886. */
  36887. DEBUGCANVASSIZE: {
  36888. width: number;
  36889. height: number;
  36890. };
  36891. private _byteFreqs;
  36892. private _byteTime;
  36893. private _floatFreqs;
  36894. private _webAudioAnalyser;
  36895. private _debugCanvas;
  36896. private _debugCanvasContext;
  36897. private _scene;
  36898. private _registerFunc;
  36899. private _audioEngine;
  36900. /**
  36901. * Creates a new analyser
  36902. * @param scene defines hosting scene
  36903. */
  36904. constructor(scene: Scene);
  36905. /**
  36906. * Get the number of data values you will have to play with for the visualization
  36907. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36908. * @returns a number
  36909. */
  36910. getFrequencyBinCount(): number;
  36911. /**
  36912. * Gets the current frequency data as a byte array
  36913. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36914. * @returns a Uint8Array
  36915. */
  36916. getByteFrequencyData(): Uint8Array;
  36917. /**
  36918. * Gets the current waveform as a byte array
  36919. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36920. * @returns a Uint8Array
  36921. */
  36922. getByteTimeDomainData(): Uint8Array;
  36923. /**
  36924. * Gets the current frequency data as a float array
  36925. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36926. * @returns a Float32Array
  36927. */
  36928. getFloatFrequencyData(): Float32Array;
  36929. /**
  36930. * Renders the debug canvas
  36931. */
  36932. drawDebugCanvas(): void;
  36933. /**
  36934. * Stops rendering the debug canvas and removes it
  36935. */
  36936. stopDebugCanvas(): void;
  36937. /**
  36938. * Connects two audio nodes
  36939. * @param inputAudioNode defines first node to connect
  36940. * @param outputAudioNode defines second node to connect
  36941. */
  36942. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36943. /**
  36944. * Releases all associated resources
  36945. */
  36946. dispose(): void;
  36947. }
  36948. }
  36949. declare module BABYLON {
  36950. /**
  36951. * This represents an audio engine and it is responsible
  36952. * to play, synchronize and analyse sounds throughout the application.
  36953. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36954. */
  36955. export interface IAudioEngine extends IDisposable {
  36956. /**
  36957. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36958. */
  36959. readonly canUseWebAudio: boolean;
  36960. /**
  36961. * Gets the current AudioContext if available.
  36962. */
  36963. readonly audioContext: Nullable<AudioContext>;
  36964. /**
  36965. * The master gain node defines the global audio volume of your audio engine.
  36966. */
  36967. readonly masterGain: GainNode;
  36968. /**
  36969. * Gets whether or not mp3 are supported by your browser.
  36970. */
  36971. readonly isMP3supported: boolean;
  36972. /**
  36973. * Gets whether or not ogg are supported by your browser.
  36974. */
  36975. readonly isOGGsupported: boolean;
  36976. /**
  36977. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36978. * @ignoreNaming
  36979. */
  36980. WarnedWebAudioUnsupported: boolean;
  36981. /**
  36982. * Defines if the audio engine relies on a custom unlocked button.
  36983. * In this case, the embedded button will not be displayed.
  36984. */
  36985. useCustomUnlockedButton: boolean;
  36986. /**
  36987. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  36988. */
  36989. readonly unlocked: boolean;
  36990. /**
  36991. * Event raised when audio has been unlocked on the browser.
  36992. */
  36993. onAudioUnlockedObservable: Observable<AudioEngine>;
  36994. /**
  36995. * Event raised when audio has been locked on the browser.
  36996. */
  36997. onAudioLockedObservable: Observable<AudioEngine>;
  36998. /**
  36999. * Flags the audio engine in Locked state.
  37000. * This happens due to new browser policies preventing audio to autoplay.
  37001. */
  37002. lock(): void;
  37003. /**
  37004. * Unlocks the audio engine once a user action has been done on the dom.
  37005. * This is helpful to resume play once browser policies have been satisfied.
  37006. */
  37007. unlock(): void;
  37008. /**
  37009. * Gets the global volume sets on the master gain.
  37010. * @returns the global volume if set or -1 otherwise
  37011. */
  37012. getGlobalVolume(): number;
  37013. /**
  37014. * Sets the global volume of your experience (sets on the master gain).
  37015. * @param newVolume Defines the new global volume of the application
  37016. */
  37017. setGlobalVolume(newVolume: number): void;
  37018. /**
  37019. * Connect the audio engine to an audio analyser allowing some amazing
  37020. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37021. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37022. * @param analyser The analyser to connect to the engine
  37023. */
  37024. connectToAnalyser(analyser: Analyser): void;
  37025. }
  37026. /**
  37027. * This represents the default audio engine used in babylon.
  37028. * It is responsible to play, synchronize and analyse sounds throughout the application.
  37029. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37030. */
  37031. export class AudioEngine implements IAudioEngine {
  37032. private _audioContext;
  37033. private _audioContextInitialized;
  37034. private _muteButton;
  37035. private _hostElement;
  37036. /**
  37037. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37038. */
  37039. canUseWebAudio: boolean;
  37040. /**
  37041. * The master gain node defines the global audio volume of your audio engine.
  37042. */
  37043. masterGain: GainNode;
  37044. /**
  37045. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37046. * @ignoreNaming
  37047. */
  37048. WarnedWebAudioUnsupported: boolean;
  37049. /**
  37050. * Gets whether or not mp3 are supported by your browser.
  37051. */
  37052. isMP3supported: boolean;
  37053. /**
  37054. * Gets whether or not ogg are supported by your browser.
  37055. */
  37056. isOGGsupported: boolean;
  37057. /**
  37058. * Gets whether audio has been unlocked on the device.
  37059. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  37060. * a user interaction has happened.
  37061. */
  37062. unlocked: boolean;
  37063. /**
  37064. * Defines if the audio engine relies on a custom unlocked button.
  37065. * In this case, the embedded button will not be displayed.
  37066. */
  37067. useCustomUnlockedButton: boolean;
  37068. /**
  37069. * Event raised when audio has been unlocked on the browser.
  37070. */
  37071. onAudioUnlockedObservable: Observable<AudioEngine>;
  37072. /**
  37073. * Event raised when audio has been locked on the browser.
  37074. */
  37075. onAudioLockedObservable: Observable<AudioEngine>;
  37076. /**
  37077. * Gets the current AudioContext if available.
  37078. */
  37079. get audioContext(): Nullable<AudioContext>;
  37080. private _connectedAnalyser;
  37081. /**
  37082. * Instantiates a new audio engine.
  37083. *
  37084. * There should be only one per page as some browsers restrict the number
  37085. * of audio contexts you can create.
  37086. * @param hostElement defines the host element where to display the mute icon if necessary
  37087. */
  37088. constructor(hostElement?: Nullable<HTMLElement>);
  37089. /**
  37090. * Flags the audio engine in Locked state.
  37091. * This happens due to new browser policies preventing audio to autoplay.
  37092. */
  37093. lock(): void;
  37094. /**
  37095. * Unlocks the audio engine once a user action has been done on the dom.
  37096. * This is helpful to resume play once browser policies have been satisfied.
  37097. */
  37098. unlock(): void;
  37099. private _resumeAudioContext;
  37100. private _initializeAudioContext;
  37101. private _tryToRun;
  37102. private _triggerRunningState;
  37103. private _triggerSuspendedState;
  37104. private _displayMuteButton;
  37105. private _moveButtonToTopLeft;
  37106. private _onResize;
  37107. private _hideMuteButton;
  37108. /**
  37109. * Destroy and release the resources associated with the audio ccontext.
  37110. */
  37111. dispose(): void;
  37112. /**
  37113. * Gets the global volume sets on the master gain.
  37114. * @returns the global volume if set or -1 otherwise
  37115. */
  37116. getGlobalVolume(): number;
  37117. /**
  37118. * Sets the global volume of your experience (sets on the master gain).
  37119. * @param newVolume Defines the new global volume of the application
  37120. */
  37121. setGlobalVolume(newVolume: number): void;
  37122. /**
  37123. * Connect the audio engine to an audio analyser allowing some amazing
  37124. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37125. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37126. * @param analyser The analyser to connect to the engine
  37127. */
  37128. connectToAnalyser(analyser: Analyser): void;
  37129. }
  37130. }
  37131. declare module BABYLON {
  37132. /**
  37133. * Interface used to present a loading screen while loading a scene
  37134. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37135. */
  37136. export interface ILoadingScreen {
  37137. /**
  37138. * Function called to display the loading screen
  37139. */
  37140. displayLoadingUI: () => void;
  37141. /**
  37142. * Function called to hide the loading screen
  37143. */
  37144. hideLoadingUI: () => void;
  37145. /**
  37146. * Gets or sets the color to use for the background
  37147. */
  37148. loadingUIBackgroundColor: string;
  37149. /**
  37150. * Gets or sets the text to display while loading
  37151. */
  37152. loadingUIText: string;
  37153. }
  37154. /**
  37155. * Class used for the default loading screen
  37156. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37157. */
  37158. export class DefaultLoadingScreen implements ILoadingScreen {
  37159. private _renderingCanvas;
  37160. private _loadingText;
  37161. private _loadingDivBackgroundColor;
  37162. private _loadingDiv;
  37163. private _loadingTextDiv;
  37164. /** Gets or sets the logo url to use for the default loading screen */
  37165. static DefaultLogoUrl: string;
  37166. /** Gets or sets the spinner url to use for the default loading screen */
  37167. static DefaultSpinnerUrl: string;
  37168. /**
  37169. * Creates a new default loading screen
  37170. * @param _renderingCanvas defines the canvas used to render the scene
  37171. * @param _loadingText defines the default text to display
  37172. * @param _loadingDivBackgroundColor defines the default background color
  37173. */
  37174. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37175. /**
  37176. * Function called to display the loading screen
  37177. */
  37178. displayLoadingUI(): void;
  37179. /**
  37180. * Function called to hide the loading screen
  37181. */
  37182. hideLoadingUI(): void;
  37183. /**
  37184. * Gets or sets the text to display while loading
  37185. */
  37186. set loadingUIText(text: string);
  37187. get loadingUIText(): string;
  37188. /**
  37189. * Gets or sets the color to use for the background
  37190. */
  37191. get loadingUIBackgroundColor(): string;
  37192. set loadingUIBackgroundColor(color: string);
  37193. private _resizeLoadingUI;
  37194. }
  37195. }
  37196. declare module BABYLON {
  37197. /**
  37198. * Interface for any object that can request an animation frame
  37199. */
  37200. export interface ICustomAnimationFrameRequester {
  37201. /**
  37202. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37203. */
  37204. renderFunction?: Function;
  37205. /**
  37206. * Called to request the next frame to render to
  37207. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37208. */
  37209. requestAnimationFrame: Function;
  37210. /**
  37211. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37212. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37213. */
  37214. requestID?: number;
  37215. }
  37216. }
  37217. declare module BABYLON {
  37218. /**
  37219. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37220. */
  37221. export class PerformanceMonitor {
  37222. private _enabled;
  37223. private _rollingFrameTime;
  37224. private _lastFrameTimeMs;
  37225. /**
  37226. * constructor
  37227. * @param frameSampleSize The number of samples required to saturate the sliding window
  37228. */
  37229. constructor(frameSampleSize?: number);
  37230. /**
  37231. * Samples current frame
  37232. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37233. */
  37234. sampleFrame(timeMs?: number): void;
  37235. /**
  37236. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37237. */
  37238. get averageFrameTime(): number;
  37239. /**
  37240. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37241. */
  37242. get averageFrameTimeVariance(): number;
  37243. /**
  37244. * Returns the frame time of the most recent frame
  37245. */
  37246. get instantaneousFrameTime(): number;
  37247. /**
  37248. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37249. */
  37250. get averageFPS(): number;
  37251. /**
  37252. * Returns the average framerate in frames per second using the most recent frame time
  37253. */
  37254. get instantaneousFPS(): number;
  37255. /**
  37256. * Returns true if enough samples have been taken to completely fill the sliding window
  37257. */
  37258. get isSaturated(): boolean;
  37259. /**
  37260. * Enables contributions to the sliding window sample set
  37261. */
  37262. enable(): void;
  37263. /**
  37264. * Disables contributions to the sliding window sample set
  37265. * Samples will not be interpolated over the disabled period
  37266. */
  37267. disable(): void;
  37268. /**
  37269. * Returns true if sampling is enabled
  37270. */
  37271. get isEnabled(): boolean;
  37272. /**
  37273. * Resets performance monitor
  37274. */
  37275. reset(): void;
  37276. }
  37277. /**
  37278. * RollingAverage
  37279. *
  37280. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37281. */
  37282. export class RollingAverage {
  37283. /**
  37284. * Current average
  37285. */
  37286. average: number;
  37287. /**
  37288. * Current variance
  37289. */
  37290. variance: number;
  37291. protected _samples: Array<number>;
  37292. protected _sampleCount: number;
  37293. protected _pos: number;
  37294. protected _m2: number;
  37295. /**
  37296. * constructor
  37297. * @param length The number of samples required to saturate the sliding window
  37298. */
  37299. constructor(length: number);
  37300. /**
  37301. * Adds a sample to the sample set
  37302. * @param v The sample value
  37303. */
  37304. add(v: number): void;
  37305. /**
  37306. * Returns previously added values or null if outside of history or outside the sliding window domain
  37307. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37308. * @return Value previously recorded with add() or null if outside of range
  37309. */
  37310. history(i: number): number;
  37311. /**
  37312. * Returns true if enough samples have been taken to completely fill the sliding window
  37313. * @return true if sample-set saturated
  37314. */
  37315. isSaturated(): boolean;
  37316. /**
  37317. * Resets the rolling average (equivalent to 0 samples taken so far)
  37318. */
  37319. reset(): void;
  37320. /**
  37321. * Wraps a value around the sample range boundaries
  37322. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37323. * @return Wrapped position in sample range
  37324. */
  37325. protected _wrapPosition(i: number): number;
  37326. }
  37327. }
  37328. declare module BABYLON {
  37329. /**
  37330. * This class is used to track a performance counter which is number based.
  37331. * The user has access to many properties which give statistics of different nature.
  37332. *
  37333. * The implementer can track two kinds of Performance Counter: time and count.
  37334. * 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.
  37335. * 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.
  37336. */
  37337. export class PerfCounter {
  37338. /**
  37339. * Gets or sets a global boolean to turn on and off all the counters
  37340. */
  37341. static Enabled: boolean;
  37342. /**
  37343. * Returns the smallest value ever
  37344. */
  37345. get min(): number;
  37346. /**
  37347. * Returns the biggest value ever
  37348. */
  37349. get max(): number;
  37350. /**
  37351. * Returns the average value since the performance counter is running
  37352. */
  37353. get average(): number;
  37354. /**
  37355. * Returns the average value of the last second the counter was monitored
  37356. */
  37357. get lastSecAverage(): number;
  37358. /**
  37359. * Returns the current value
  37360. */
  37361. get current(): number;
  37362. /**
  37363. * Gets the accumulated total
  37364. */
  37365. get total(): number;
  37366. /**
  37367. * Gets the total value count
  37368. */
  37369. get count(): number;
  37370. /**
  37371. * Creates a new counter
  37372. */
  37373. constructor();
  37374. /**
  37375. * Call this method to start monitoring a new frame.
  37376. * 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.
  37377. */
  37378. fetchNewFrame(): void;
  37379. /**
  37380. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37381. * @param newCount the count value to add to the monitored count
  37382. * @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.
  37383. */
  37384. addCount(newCount: number, fetchResult: boolean): void;
  37385. /**
  37386. * Start monitoring this performance counter
  37387. */
  37388. beginMonitoring(): void;
  37389. /**
  37390. * Compute the time lapsed since the previous beginMonitoring() call.
  37391. * @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
  37392. */
  37393. endMonitoring(newFrame?: boolean): void;
  37394. private _fetchResult;
  37395. private _startMonitoringTime;
  37396. private _min;
  37397. private _max;
  37398. private _average;
  37399. private _current;
  37400. private _totalValueCount;
  37401. private _totalAccumulated;
  37402. private _lastSecAverage;
  37403. private _lastSecAccumulated;
  37404. private _lastSecTime;
  37405. private _lastSecValueCount;
  37406. }
  37407. }
  37408. declare module BABYLON {
  37409. interface ThinEngine {
  37410. /** @hidden */
  37411. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37412. }
  37413. }
  37414. declare module BABYLON {
  37415. /**
  37416. * Defines the interface used by display changed events
  37417. */
  37418. export interface IDisplayChangedEventArgs {
  37419. /** Gets the vrDisplay object (if any) */
  37420. vrDisplay: Nullable<any>;
  37421. /** Gets a boolean indicating if webVR is supported */
  37422. vrSupported: boolean;
  37423. }
  37424. /**
  37425. * Defines the interface used by objects containing a viewport (like a camera)
  37426. */
  37427. interface IViewportOwnerLike {
  37428. /**
  37429. * Gets or sets the viewport
  37430. */
  37431. viewport: IViewportLike;
  37432. }
  37433. /**
  37434. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37435. */
  37436. export class Engine extends ThinEngine {
  37437. /** Defines that alpha blending is disabled */
  37438. static readonly ALPHA_DISABLE: number;
  37439. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37440. static readonly ALPHA_ADD: number;
  37441. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37442. static readonly ALPHA_COMBINE: number;
  37443. /** Defines that alpha blending to DEST - SRC * DEST */
  37444. static readonly ALPHA_SUBTRACT: number;
  37445. /** Defines that alpha blending to SRC * DEST */
  37446. static readonly ALPHA_MULTIPLY: number;
  37447. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37448. static readonly ALPHA_MAXIMIZED: number;
  37449. /** Defines that alpha blending to SRC + DEST */
  37450. static readonly ALPHA_ONEONE: number;
  37451. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37452. static readonly ALPHA_PREMULTIPLIED: number;
  37453. /**
  37454. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37455. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37456. */
  37457. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37458. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37459. static readonly ALPHA_INTERPOLATE: number;
  37460. /**
  37461. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37462. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37463. */
  37464. static readonly ALPHA_SCREENMODE: number;
  37465. /** Defines that the ressource is not delayed*/
  37466. static readonly DELAYLOADSTATE_NONE: number;
  37467. /** Defines that the ressource was successfully delay loaded */
  37468. static readonly DELAYLOADSTATE_LOADED: number;
  37469. /** Defines that the ressource is currently delay loading */
  37470. static readonly DELAYLOADSTATE_LOADING: number;
  37471. /** Defines that the ressource is delayed and has not started loading */
  37472. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37473. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37474. static readonly NEVER: number;
  37475. /** 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 */
  37476. static readonly ALWAYS: number;
  37477. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37478. static readonly LESS: number;
  37479. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37480. static readonly EQUAL: number;
  37481. /** 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 */
  37482. static readonly LEQUAL: number;
  37483. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37484. static readonly GREATER: number;
  37485. /** 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 */
  37486. static readonly GEQUAL: number;
  37487. /** 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 */
  37488. static readonly NOTEQUAL: number;
  37489. /** Passed to stencilOperation to specify that stencil value must be kept */
  37490. static readonly KEEP: number;
  37491. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37492. static readonly REPLACE: number;
  37493. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37494. static readonly INCR: number;
  37495. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37496. static readonly DECR: number;
  37497. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37498. static readonly INVERT: number;
  37499. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37500. static readonly INCR_WRAP: number;
  37501. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37502. static readonly DECR_WRAP: number;
  37503. /** Texture is not repeating outside of 0..1 UVs */
  37504. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37505. /** Texture is repeating outside of 0..1 UVs */
  37506. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37507. /** Texture is repeating and mirrored */
  37508. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37509. /** ALPHA */
  37510. static readonly TEXTUREFORMAT_ALPHA: number;
  37511. /** LUMINANCE */
  37512. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37513. /** LUMINANCE_ALPHA */
  37514. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37515. /** RGB */
  37516. static readonly TEXTUREFORMAT_RGB: number;
  37517. /** RGBA */
  37518. static readonly TEXTUREFORMAT_RGBA: number;
  37519. /** RED */
  37520. static readonly TEXTUREFORMAT_RED: number;
  37521. /** RED (2nd reference) */
  37522. static readonly TEXTUREFORMAT_R: number;
  37523. /** RG */
  37524. static readonly TEXTUREFORMAT_RG: number;
  37525. /** RED_INTEGER */
  37526. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37527. /** RED_INTEGER (2nd reference) */
  37528. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37529. /** RG_INTEGER */
  37530. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37531. /** RGB_INTEGER */
  37532. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37533. /** RGBA_INTEGER */
  37534. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37535. /** UNSIGNED_BYTE */
  37536. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37537. /** UNSIGNED_BYTE (2nd reference) */
  37538. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37539. /** FLOAT */
  37540. static readonly TEXTURETYPE_FLOAT: number;
  37541. /** HALF_FLOAT */
  37542. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37543. /** BYTE */
  37544. static readonly TEXTURETYPE_BYTE: number;
  37545. /** SHORT */
  37546. static readonly TEXTURETYPE_SHORT: number;
  37547. /** UNSIGNED_SHORT */
  37548. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37549. /** INT */
  37550. static readonly TEXTURETYPE_INT: number;
  37551. /** UNSIGNED_INT */
  37552. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37553. /** UNSIGNED_SHORT_4_4_4_4 */
  37554. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37555. /** UNSIGNED_SHORT_5_5_5_1 */
  37556. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37557. /** UNSIGNED_SHORT_5_6_5 */
  37558. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37559. /** UNSIGNED_INT_2_10_10_10_REV */
  37560. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37561. /** UNSIGNED_INT_24_8 */
  37562. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37563. /** UNSIGNED_INT_10F_11F_11F_REV */
  37564. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37565. /** UNSIGNED_INT_5_9_9_9_REV */
  37566. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37567. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37568. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37569. /** nearest is mag = nearest and min = nearest and mip = linear */
  37570. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37571. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37572. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37573. /** Trilinear is mag = linear and min = linear and mip = linear */
  37574. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37575. /** nearest is mag = nearest and min = nearest and mip = linear */
  37576. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37577. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37578. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37579. /** Trilinear is mag = linear and min = linear and mip = linear */
  37580. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37581. /** mag = nearest and min = nearest and mip = nearest */
  37582. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37583. /** mag = nearest and min = linear and mip = nearest */
  37584. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37585. /** mag = nearest and min = linear and mip = linear */
  37586. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37587. /** mag = nearest and min = linear and mip = none */
  37588. static readonly TEXTURE_NEAREST_LINEAR: number;
  37589. /** mag = nearest and min = nearest and mip = none */
  37590. static readonly TEXTURE_NEAREST_NEAREST: number;
  37591. /** mag = linear and min = nearest and mip = nearest */
  37592. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37593. /** mag = linear and min = nearest and mip = linear */
  37594. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37595. /** mag = linear and min = linear and mip = none */
  37596. static readonly TEXTURE_LINEAR_LINEAR: number;
  37597. /** mag = linear and min = nearest and mip = none */
  37598. static readonly TEXTURE_LINEAR_NEAREST: number;
  37599. /** Explicit coordinates mode */
  37600. static readonly TEXTURE_EXPLICIT_MODE: number;
  37601. /** Spherical coordinates mode */
  37602. static readonly TEXTURE_SPHERICAL_MODE: number;
  37603. /** Planar coordinates mode */
  37604. static readonly TEXTURE_PLANAR_MODE: number;
  37605. /** Cubic coordinates mode */
  37606. static readonly TEXTURE_CUBIC_MODE: number;
  37607. /** Projection coordinates mode */
  37608. static readonly TEXTURE_PROJECTION_MODE: number;
  37609. /** Skybox coordinates mode */
  37610. static readonly TEXTURE_SKYBOX_MODE: number;
  37611. /** Inverse Cubic coordinates mode */
  37612. static readonly TEXTURE_INVCUBIC_MODE: number;
  37613. /** Equirectangular coordinates mode */
  37614. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37615. /** Equirectangular Fixed coordinates mode */
  37616. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37617. /** Equirectangular Fixed Mirrored coordinates mode */
  37618. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37619. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37620. static readonly SCALEMODE_FLOOR: number;
  37621. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37622. static readonly SCALEMODE_NEAREST: number;
  37623. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37624. static readonly SCALEMODE_CEILING: number;
  37625. /**
  37626. * Returns the current npm package of the sdk
  37627. */
  37628. static get NpmPackage(): string;
  37629. /**
  37630. * Returns the current version of the framework
  37631. */
  37632. static get Version(): string;
  37633. /** Gets the list of created engines */
  37634. static get Instances(): Engine[];
  37635. /**
  37636. * Gets the latest created engine
  37637. */
  37638. static get LastCreatedEngine(): Nullable<Engine>;
  37639. /**
  37640. * Gets the latest created scene
  37641. */
  37642. static get LastCreatedScene(): Nullable<Scene>;
  37643. /**
  37644. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37645. * @param flag defines which part of the materials must be marked as dirty
  37646. * @param predicate defines a predicate used to filter which materials should be affected
  37647. */
  37648. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37649. /**
  37650. * Method called to create the default loading screen.
  37651. * This can be overriden in your own app.
  37652. * @param canvas The rendering canvas element
  37653. * @returns The loading screen
  37654. */
  37655. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37656. /**
  37657. * Method called to create the default rescale post process on each engine.
  37658. */
  37659. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37660. /**
  37661. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37662. **/
  37663. enableOfflineSupport: boolean;
  37664. /**
  37665. * 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)
  37666. **/
  37667. disableManifestCheck: boolean;
  37668. /**
  37669. * Gets the list of created scenes
  37670. */
  37671. scenes: Scene[];
  37672. /**
  37673. * Event raised when a new scene is created
  37674. */
  37675. onNewSceneAddedObservable: Observable<Scene>;
  37676. /**
  37677. * Gets the list of created postprocesses
  37678. */
  37679. postProcesses: PostProcess[];
  37680. /**
  37681. * Gets a boolean indicating if the pointer is currently locked
  37682. */
  37683. isPointerLock: boolean;
  37684. /**
  37685. * Observable event triggered each time the rendering canvas is resized
  37686. */
  37687. onResizeObservable: Observable<Engine>;
  37688. /**
  37689. * Observable event triggered each time the canvas loses focus
  37690. */
  37691. onCanvasBlurObservable: Observable<Engine>;
  37692. /**
  37693. * Observable event triggered each time the canvas gains focus
  37694. */
  37695. onCanvasFocusObservable: Observable<Engine>;
  37696. /**
  37697. * Observable event triggered each time the canvas receives pointerout event
  37698. */
  37699. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37700. /**
  37701. * Observable raised when the engine begins a new frame
  37702. */
  37703. onBeginFrameObservable: Observable<Engine>;
  37704. /**
  37705. * If set, will be used to request the next animation frame for the render loop
  37706. */
  37707. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37708. /**
  37709. * Observable raised when the engine ends the current frame
  37710. */
  37711. onEndFrameObservable: Observable<Engine>;
  37712. /**
  37713. * Observable raised when the engine is about to compile a shader
  37714. */
  37715. onBeforeShaderCompilationObservable: Observable<Engine>;
  37716. /**
  37717. * Observable raised when the engine has jsut compiled a shader
  37718. */
  37719. onAfterShaderCompilationObservable: Observable<Engine>;
  37720. /**
  37721. * Gets the audio engine
  37722. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37723. * @ignorenaming
  37724. */
  37725. static audioEngine: IAudioEngine;
  37726. /**
  37727. * Default AudioEngine factory responsible of creating the Audio Engine.
  37728. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37729. */
  37730. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37731. /**
  37732. * Default offline support factory responsible of creating a tool used to store data locally.
  37733. * By default, this will create a Database object if the workload has been embedded.
  37734. */
  37735. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37736. private _loadingScreen;
  37737. private _pointerLockRequested;
  37738. private _rescalePostProcess;
  37739. private _deterministicLockstep;
  37740. private _lockstepMaxSteps;
  37741. private _timeStep;
  37742. protected get _supportsHardwareTextureRescaling(): boolean;
  37743. private _fps;
  37744. private _deltaTime;
  37745. /** @hidden */
  37746. _drawCalls: PerfCounter;
  37747. /** 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 */
  37748. canvasTabIndex: number;
  37749. /**
  37750. * Turn this value on if you want to pause FPS computation when in background
  37751. */
  37752. disablePerformanceMonitorInBackground: boolean;
  37753. private _performanceMonitor;
  37754. /**
  37755. * Gets the performance monitor attached to this engine
  37756. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37757. */
  37758. get performanceMonitor(): PerformanceMonitor;
  37759. private _onFocus;
  37760. private _onBlur;
  37761. private _onCanvasPointerOut;
  37762. private _onCanvasBlur;
  37763. private _onCanvasFocus;
  37764. private _onFullscreenChange;
  37765. private _onPointerLockChange;
  37766. /**
  37767. * Gets the HTML element used to attach event listeners
  37768. * @returns a HTML element
  37769. */
  37770. getInputElement(): Nullable<HTMLElement>;
  37771. /**
  37772. * Creates a new engine
  37773. * @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
  37774. * @param antialias defines enable antialiasing (default: false)
  37775. * @param options defines further options to be sent to the getContext() function
  37776. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37777. */
  37778. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37779. /**
  37780. * Gets current aspect ratio
  37781. * @param viewportOwner defines the camera to use to get the aspect ratio
  37782. * @param useScreen defines if screen size must be used (or the current render target if any)
  37783. * @returns a number defining the aspect ratio
  37784. */
  37785. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37786. /**
  37787. * Gets current screen aspect ratio
  37788. * @returns a number defining the aspect ratio
  37789. */
  37790. getScreenAspectRatio(): number;
  37791. /**
  37792. * Gets the client rect of the HTML canvas attached with the current webGL context
  37793. * @returns a client rectanglee
  37794. */
  37795. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37796. /**
  37797. * Gets the client rect of the HTML element used for events
  37798. * @returns a client rectanglee
  37799. */
  37800. getInputElementClientRect(): Nullable<ClientRect>;
  37801. /**
  37802. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37803. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37804. * @returns true if engine is in deterministic lock step mode
  37805. */
  37806. isDeterministicLockStep(): boolean;
  37807. /**
  37808. * Gets the max steps when engine is running in deterministic lock step
  37809. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37810. * @returns the max steps
  37811. */
  37812. getLockstepMaxSteps(): number;
  37813. /**
  37814. * Returns the time in ms between steps when using deterministic lock step.
  37815. * @returns time step in (ms)
  37816. */
  37817. getTimeStep(): number;
  37818. /**
  37819. * Force the mipmap generation for the given render target texture
  37820. * @param texture defines the render target texture to use
  37821. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37822. */
  37823. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37824. /** States */
  37825. /**
  37826. * Set various states to the webGL context
  37827. * @param culling defines backface culling state
  37828. * @param zOffset defines the value to apply to zOffset (0 by default)
  37829. * @param force defines if states must be applied even if cache is up to date
  37830. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37831. */
  37832. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37833. /**
  37834. * Set the z offset to apply to current rendering
  37835. * @param value defines the offset to apply
  37836. */
  37837. setZOffset(value: number): void;
  37838. /**
  37839. * Gets the current value of the zOffset
  37840. * @returns the current zOffset state
  37841. */
  37842. getZOffset(): number;
  37843. /**
  37844. * Enable or disable depth buffering
  37845. * @param enable defines the state to set
  37846. */
  37847. setDepthBuffer(enable: boolean): void;
  37848. /**
  37849. * Gets a boolean indicating if depth writing is enabled
  37850. * @returns the current depth writing state
  37851. */
  37852. getDepthWrite(): boolean;
  37853. /**
  37854. * Enable or disable depth writing
  37855. * @param enable defines the state to set
  37856. */
  37857. setDepthWrite(enable: boolean): void;
  37858. /**
  37859. * Gets a boolean indicating if stencil buffer is enabled
  37860. * @returns the current stencil buffer state
  37861. */
  37862. getStencilBuffer(): boolean;
  37863. /**
  37864. * Enable or disable the stencil buffer
  37865. * @param enable defines if the stencil buffer must be enabled or disabled
  37866. */
  37867. setStencilBuffer(enable: boolean): void;
  37868. /**
  37869. * Gets the current stencil mask
  37870. * @returns a number defining the new stencil mask to use
  37871. */
  37872. getStencilMask(): number;
  37873. /**
  37874. * Sets the current stencil mask
  37875. * @param mask defines the new stencil mask to use
  37876. */
  37877. setStencilMask(mask: number): void;
  37878. /**
  37879. * Gets the current stencil function
  37880. * @returns a number defining the stencil function to use
  37881. */
  37882. getStencilFunction(): number;
  37883. /**
  37884. * Gets the current stencil reference value
  37885. * @returns a number defining the stencil reference value to use
  37886. */
  37887. getStencilFunctionReference(): number;
  37888. /**
  37889. * Gets the current stencil mask
  37890. * @returns a number defining the stencil mask to use
  37891. */
  37892. getStencilFunctionMask(): number;
  37893. /**
  37894. * Sets the current stencil function
  37895. * @param stencilFunc defines the new stencil function to use
  37896. */
  37897. setStencilFunction(stencilFunc: number): void;
  37898. /**
  37899. * Sets the current stencil reference
  37900. * @param reference defines the new stencil reference to use
  37901. */
  37902. setStencilFunctionReference(reference: number): void;
  37903. /**
  37904. * Sets the current stencil mask
  37905. * @param mask defines the new stencil mask to use
  37906. */
  37907. setStencilFunctionMask(mask: number): void;
  37908. /**
  37909. * Gets the current stencil operation when stencil fails
  37910. * @returns a number defining stencil operation to use when stencil fails
  37911. */
  37912. getStencilOperationFail(): number;
  37913. /**
  37914. * Gets the current stencil operation when depth fails
  37915. * @returns a number defining stencil operation to use when depth fails
  37916. */
  37917. getStencilOperationDepthFail(): number;
  37918. /**
  37919. * Gets the current stencil operation when stencil passes
  37920. * @returns a number defining stencil operation to use when stencil passes
  37921. */
  37922. getStencilOperationPass(): number;
  37923. /**
  37924. * Sets the stencil operation to use when stencil fails
  37925. * @param operation defines the stencil operation to use when stencil fails
  37926. */
  37927. setStencilOperationFail(operation: number): void;
  37928. /**
  37929. * Sets the stencil operation to use when depth fails
  37930. * @param operation defines the stencil operation to use when depth fails
  37931. */
  37932. setStencilOperationDepthFail(operation: number): void;
  37933. /**
  37934. * Sets the stencil operation to use when stencil passes
  37935. * @param operation defines the stencil operation to use when stencil passes
  37936. */
  37937. setStencilOperationPass(operation: number): void;
  37938. /**
  37939. * Sets a boolean indicating if the dithering state is enabled or disabled
  37940. * @param value defines the dithering state
  37941. */
  37942. setDitheringState(value: boolean): void;
  37943. /**
  37944. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37945. * @param value defines the rasterizer state
  37946. */
  37947. setRasterizerState(value: boolean): void;
  37948. /**
  37949. * Gets the current depth function
  37950. * @returns a number defining the depth function
  37951. */
  37952. getDepthFunction(): Nullable<number>;
  37953. /**
  37954. * Sets the current depth function
  37955. * @param depthFunc defines the function to use
  37956. */
  37957. setDepthFunction(depthFunc: number): void;
  37958. /**
  37959. * Sets the current depth function to GREATER
  37960. */
  37961. setDepthFunctionToGreater(): void;
  37962. /**
  37963. * Sets the current depth function to GEQUAL
  37964. */
  37965. setDepthFunctionToGreaterOrEqual(): void;
  37966. /**
  37967. * Sets the current depth function to LESS
  37968. */
  37969. setDepthFunctionToLess(): void;
  37970. /**
  37971. * Sets the current depth function to LEQUAL
  37972. */
  37973. setDepthFunctionToLessOrEqual(): void;
  37974. private _cachedStencilBuffer;
  37975. private _cachedStencilFunction;
  37976. private _cachedStencilMask;
  37977. private _cachedStencilOperationPass;
  37978. private _cachedStencilOperationFail;
  37979. private _cachedStencilOperationDepthFail;
  37980. private _cachedStencilReference;
  37981. /**
  37982. * Caches the the state of the stencil buffer
  37983. */
  37984. cacheStencilState(): void;
  37985. /**
  37986. * Restores the state of the stencil buffer
  37987. */
  37988. restoreStencilState(): void;
  37989. /**
  37990. * Directly set the WebGL Viewport
  37991. * @param x defines the x coordinate of the viewport (in screen space)
  37992. * @param y defines the y coordinate of the viewport (in screen space)
  37993. * @param width defines the width of the viewport (in screen space)
  37994. * @param height defines the height of the viewport (in screen space)
  37995. * @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
  37996. */
  37997. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  37998. /**
  37999. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  38000. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38001. * @param y defines the y-coordinate of the corner of the clear rectangle
  38002. * @param width defines the width of the clear rectangle
  38003. * @param height defines the height of the clear rectangle
  38004. * @param clearColor defines the clear color
  38005. */
  38006. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  38007. /**
  38008. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  38009. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38010. * @param y defines the y-coordinate of the corner of the clear rectangle
  38011. * @param width defines the width of the clear rectangle
  38012. * @param height defines the height of the clear rectangle
  38013. */
  38014. enableScissor(x: number, y: number, width: number, height: number): void;
  38015. /**
  38016. * Disable previously set scissor test rectangle
  38017. */
  38018. disableScissor(): void;
  38019. protected _reportDrawCall(): void;
  38020. /**
  38021. * Initializes a webVR display and starts listening to display change events
  38022. * The onVRDisplayChangedObservable will be notified upon these changes
  38023. * @returns The onVRDisplayChangedObservable
  38024. */
  38025. initWebVR(): Observable<IDisplayChangedEventArgs>;
  38026. /** @hidden */
  38027. _prepareVRComponent(): void;
  38028. /** @hidden */
  38029. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  38030. /** @hidden */
  38031. _submitVRFrame(): void;
  38032. /**
  38033. * Call this function to leave webVR mode
  38034. * Will do nothing if webVR is not supported or if there is no webVR device
  38035. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38036. */
  38037. disableVR(): void;
  38038. /**
  38039. * Gets a boolean indicating that the system is in VR mode and is presenting
  38040. * @returns true if VR mode is engaged
  38041. */
  38042. isVRPresenting(): boolean;
  38043. /** @hidden */
  38044. _requestVRFrame(): void;
  38045. /** @hidden */
  38046. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38047. /**
  38048. * Gets the source code of the vertex shader associated with a specific webGL program
  38049. * @param program defines the program to use
  38050. * @returns a string containing the source code of the vertex shader associated with the program
  38051. */
  38052. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  38053. /**
  38054. * Gets the source code of the fragment shader associated with a specific webGL program
  38055. * @param program defines the program to use
  38056. * @returns a string containing the source code of the fragment shader associated with the program
  38057. */
  38058. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  38059. /**
  38060. * Sets a depth stencil texture from a render target to the according uniform.
  38061. * @param channel The texture channel
  38062. * @param uniform The uniform to set
  38063. * @param texture The render target texture containing the depth stencil texture to apply
  38064. */
  38065. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  38066. /**
  38067. * Sets a texture to the webGL context from a postprocess
  38068. * @param channel defines the channel to use
  38069. * @param postProcess defines the source postprocess
  38070. */
  38071. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  38072. /**
  38073. * Binds the output of the passed in post process to the texture channel specified
  38074. * @param channel The channel the texture should be bound to
  38075. * @param postProcess The post process which's output should be bound
  38076. */
  38077. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  38078. protected _rebuildBuffers(): void;
  38079. /** @hidden */
  38080. _renderFrame(): void;
  38081. _renderLoop(): void;
  38082. /** @hidden */
  38083. _renderViews(): boolean;
  38084. /**
  38085. * Toggle full screen mode
  38086. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38087. */
  38088. switchFullscreen(requestPointerLock: boolean): void;
  38089. /**
  38090. * Enters full screen mode
  38091. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38092. */
  38093. enterFullscreen(requestPointerLock: boolean): void;
  38094. /**
  38095. * Exits full screen mode
  38096. */
  38097. exitFullscreen(): void;
  38098. /**
  38099. * Enters Pointerlock mode
  38100. */
  38101. enterPointerlock(): void;
  38102. /**
  38103. * Exits Pointerlock mode
  38104. */
  38105. exitPointerlock(): void;
  38106. /**
  38107. * Begin a new frame
  38108. */
  38109. beginFrame(): void;
  38110. /**
  38111. * Enf the current frame
  38112. */
  38113. endFrame(): void;
  38114. resize(): void;
  38115. /**
  38116. * Force a specific size of the canvas
  38117. * @param width defines the new canvas' width
  38118. * @param height defines the new canvas' height
  38119. * @returns true if the size was changed
  38120. */
  38121. setSize(width: number, height: number): boolean;
  38122. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38123. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38124. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38125. _releaseTexture(texture: InternalTexture): void;
  38126. /**
  38127. * @hidden
  38128. * Rescales a texture
  38129. * @param source input texutre
  38130. * @param destination destination texture
  38131. * @param scene scene to use to render the resize
  38132. * @param internalFormat format to use when resizing
  38133. * @param onComplete callback to be called when resize has completed
  38134. */
  38135. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38136. /**
  38137. * Gets the current framerate
  38138. * @returns a number representing the framerate
  38139. */
  38140. getFps(): number;
  38141. /**
  38142. * Gets the time spent between current and previous frame
  38143. * @returns a number representing the delta time in ms
  38144. */
  38145. getDeltaTime(): number;
  38146. private _measureFps;
  38147. /** @hidden */
  38148. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38149. /**
  38150. * Updates the sample count of a render target texture
  38151. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38152. * @param texture defines the texture to update
  38153. * @param samples defines the sample count to set
  38154. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38155. */
  38156. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38157. /**
  38158. * Updates a depth texture Comparison Mode and Function.
  38159. * If the comparison Function is equal to 0, the mode will be set to none.
  38160. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38161. * @param texture The texture to set the comparison function for
  38162. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38163. */
  38164. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38165. /**
  38166. * Creates a webGL buffer to use with instanciation
  38167. * @param capacity defines the size of the buffer
  38168. * @returns the webGL buffer
  38169. */
  38170. createInstancesBuffer(capacity: number): DataBuffer;
  38171. /**
  38172. * Delete a webGL buffer used with instanciation
  38173. * @param buffer defines the webGL buffer to delete
  38174. */
  38175. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38176. private _clientWaitAsync;
  38177. /** @hidden */
  38178. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38179. dispose(): void;
  38180. private _disableTouchAction;
  38181. /**
  38182. * Display the loading screen
  38183. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38184. */
  38185. displayLoadingUI(): void;
  38186. /**
  38187. * Hide the loading screen
  38188. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38189. */
  38190. hideLoadingUI(): void;
  38191. /**
  38192. * Gets the current loading screen object
  38193. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38194. */
  38195. get loadingScreen(): ILoadingScreen;
  38196. /**
  38197. * Sets the current loading screen object
  38198. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38199. */
  38200. set loadingScreen(loadingScreen: ILoadingScreen);
  38201. /**
  38202. * Sets the current loading screen text
  38203. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38204. */
  38205. set loadingUIText(text: string);
  38206. /**
  38207. * Sets the current loading screen background color
  38208. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38209. */
  38210. set loadingUIBackgroundColor(color: string);
  38211. /** Pointerlock and fullscreen */
  38212. /**
  38213. * Ask the browser to promote the current element to pointerlock mode
  38214. * @param element defines the DOM element to promote
  38215. */
  38216. static _RequestPointerlock(element: HTMLElement): void;
  38217. /**
  38218. * Asks the browser to exit pointerlock mode
  38219. */
  38220. static _ExitPointerlock(): void;
  38221. /**
  38222. * Ask the browser to promote the current element to fullscreen rendering mode
  38223. * @param element defines the DOM element to promote
  38224. */
  38225. static _RequestFullscreen(element: HTMLElement): void;
  38226. /**
  38227. * Asks the browser to exit fullscreen mode
  38228. */
  38229. static _ExitFullscreen(): void;
  38230. }
  38231. }
  38232. declare module BABYLON {
  38233. /**
  38234. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38235. * during the life time of the application.
  38236. */
  38237. export class EngineStore {
  38238. /** Gets the list of created engines */
  38239. static Instances: Engine[];
  38240. /** @hidden */
  38241. static _LastCreatedScene: Nullable<Scene>;
  38242. /**
  38243. * Gets the latest created engine
  38244. */
  38245. static get LastCreatedEngine(): Nullable<Engine>;
  38246. /**
  38247. * Gets the latest created scene
  38248. */
  38249. static get LastCreatedScene(): Nullable<Scene>;
  38250. /**
  38251. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38252. * @ignorenaming
  38253. */
  38254. static UseFallbackTexture: boolean;
  38255. /**
  38256. * Texture content used if a texture cannot loaded
  38257. * @ignorenaming
  38258. */
  38259. static FallbackTexture: string;
  38260. }
  38261. }
  38262. declare module BABYLON {
  38263. /**
  38264. * Helper class that provides a small promise polyfill
  38265. */
  38266. export class PromisePolyfill {
  38267. /**
  38268. * Static function used to check if the polyfill is required
  38269. * If this is the case then the function will inject the polyfill to window.Promise
  38270. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38271. */
  38272. static Apply(force?: boolean): void;
  38273. }
  38274. }
  38275. declare module BABYLON {
  38276. /**
  38277. * Interface for screenshot methods with describe argument called `size` as object with options
  38278. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38279. */
  38280. export interface IScreenshotSize {
  38281. /**
  38282. * number in pixels for canvas height
  38283. */
  38284. height?: number;
  38285. /**
  38286. * multiplier allowing render at a higher or lower resolution
  38287. * If value is defined then height and width will be ignored and taken from camera
  38288. */
  38289. precision?: number;
  38290. /**
  38291. * number in pixels for canvas width
  38292. */
  38293. width?: number;
  38294. }
  38295. }
  38296. declare module BABYLON {
  38297. interface IColor4Like {
  38298. r: float;
  38299. g: float;
  38300. b: float;
  38301. a: float;
  38302. }
  38303. /**
  38304. * Class containing a set of static utilities functions
  38305. */
  38306. export class Tools {
  38307. /**
  38308. * Gets or sets the base URL to use to load assets
  38309. */
  38310. static get BaseUrl(): string;
  38311. static set BaseUrl(value: string);
  38312. /**
  38313. * Enable/Disable Custom HTTP Request Headers globally.
  38314. * default = false
  38315. * @see CustomRequestHeaders
  38316. */
  38317. static UseCustomRequestHeaders: boolean;
  38318. /**
  38319. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38320. * i.e. when loading files, where the server/service expects an Authorization header
  38321. */
  38322. static CustomRequestHeaders: {
  38323. [key: string]: string;
  38324. };
  38325. /**
  38326. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38327. */
  38328. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38329. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38330. /**
  38331. * Default behaviour for cors in the application.
  38332. * It can be a string if the expected behavior is identical in the entire app.
  38333. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38334. */
  38335. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38336. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38337. /**
  38338. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38339. * @ignorenaming
  38340. */
  38341. static get UseFallbackTexture(): boolean;
  38342. static set UseFallbackTexture(value: boolean);
  38343. /**
  38344. * Use this object to register external classes like custom textures or material
  38345. * to allow the laoders to instantiate them
  38346. */
  38347. static get RegisteredExternalClasses(): {
  38348. [key: string]: Object;
  38349. };
  38350. static set RegisteredExternalClasses(classes: {
  38351. [key: string]: Object;
  38352. });
  38353. /**
  38354. * Texture content used if a texture cannot loaded
  38355. * @ignorenaming
  38356. */
  38357. static get fallbackTexture(): string;
  38358. static set fallbackTexture(value: string);
  38359. /**
  38360. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38361. * @param u defines the coordinate on X axis
  38362. * @param v defines the coordinate on Y axis
  38363. * @param width defines the width of the source data
  38364. * @param height defines the height of the source data
  38365. * @param pixels defines the source byte array
  38366. * @param color defines the output color
  38367. */
  38368. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38369. /**
  38370. * Interpolates between a and b via alpha
  38371. * @param a The lower value (returned when alpha = 0)
  38372. * @param b The upper value (returned when alpha = 1)
  38373. * @param alpha The interpolation-factor
  38374. * @return The mixed value
  38375. */
  38376. static Mix(a: number, b: number, alpha: number): number;
  38377. /**
  38378. * Tries to instantiate a new object from a given class name
  38379. * @param className defines the class name to instantiate
  38380. * @returns the new object or null if the system was not able to do the instantiation
  38381. */
  38382. static Instantiate(className: string): any;
  38383. /**
  38384. * Provides a slice function that will work even on IE
  38385. * @param data defines the array to slice
  38386. * @param start defines the start of the data (optional)
  38387. * @param end defines the end of the data (optional)
  38388. * @returns the new sliced array
  38389. */
  38390. static Slice<T>(data: T, start?: number, end?: number): T;
  38391. /**
  38392. * Polyfill for setImmediate
  38393. * @param action defines the action to execute after the current execution block
  38394. */
  38395. static SetImmediate(action: () => void): void;
  38396. /**
  38397. * Function indicating if a number is an exponent of 2
  38398. * @param value defines the value to test
  38399. * @returns true if the value is an exponent of 2
  38400. */
  38401. static IsExponentOfTwo(value: number): boolean;
  38402. private static _tmpFloatArray;
  38403. /**
  38404. * Returns the nearest 32-bit single precision float representation of a Number
  38405. * @param value A Number. If the parameter is of a different type, it will get converted
  38406. * to a number or to NaN if it cannot be converted
  38407. * @returns number
  38408. */
  38409. static FloatRound(value: number): number;
  38410. /**
  38411. * Extracts the filename from a path
  38412. * @param path defines the path to use
  38413. * @returns the filename
  38414. */
  38415. static GetFilename(path: string): string;
  38416. /**
  38417. * Extracts the "folder" part of a path (everything before the filename).
  38418. * @param uri The URI to extract the info from
  38419. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38420. * @returns The "folder" part of the path
  38421. */
  38422. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38423. /**
  38424. * Extracts text content from a DOM element hierarchy
  38425. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38426. */
  38427. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38428. /**
  38429. * Convert an angle in radians to degrees
  38430. * @param angle defines the angle to convert
  38431. * @returns the angle in degrees
  38432. */
  38433. static ToDegrees(angle: number): number;
  38434. /**
  38435. * Convert an angle in degrees to radians
  38436. * @param angle defines the angle to convert
  38437. * @returns the angle in radians
  38438. */
  38439. static ToRadians(angle: number): number;
  38440. /**
  38441. * Returns an array if obj is not an array
  38442. * @param obj defines the object to evaluate as an array
  38443. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38444. * @returns either obj directly if obj is an array or a new array containing obj
  38445. */
  38446. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38447. /**
  38448. * Gets the pointer prefix to use
  38449. * @param engine defines the engine we are finding the prefix for
  38450. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38451. */
  38452. static GetPointerPrefix(engine: Engine): string;
  38453. /**
  38454. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38455. * @param url define the url we are trying
  38456. * @param element define the dom element where to configure the cors policy
  38457. */
  38458. static SetCorsBehavior(url: string | string[], element: {
  38459. crossOrigin: string | null;
  38460. }): void;
  38461. /**
  38462. * Removes unwanted characters from an url
  38463. * @param url defines the url to clean
  38464. * @returns the cleaned url
  38465. */
  38466. static CleanUrl(url: string): string;
  38467. /**
  38468. * Gets or sets a function used to pre-process url before using them to load assets
  38469. */
  38470. static get PreprocessUrl(): (url: string) => string;
  38471. static set PreprocessUrl(processor: (url: string) => string);
  38472. /**
  38473. * Loads an image as an HTMLImageElement.
  38474. * @param input url string, ArrayBuffer, or Blob to load
  38475. * @param onLoad callback called when the image successfully loads
  38476. * @param onError callback called when the image fails to load
  38477. * @param offlineProvider offline provider for caching
  38478. * @param mimeType optional mime type
  38479. * @returns the HTMLImageElement of the loaded image
  38480. */
  38481. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38482. /**
  38483. * Loads a file from a url
  38484. * @param url url string, ArrayBuffer, or Blob to load
  38485. * @param onSuccess callback called when the file successfully loads
  38486. * @param onProgress callback called while file is loading (if the server supports this mode)
  38487. * @param offlineProvider defines the offline provider for caching
  38488. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38489. * @param onError callback called when the file fails to load
  38490. * @returns a file request object
  38491. */
  38492. 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;
  38493. /**
  38494. * Loads a file from a url
  38495. * @param url the file url to load
  38496. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38497. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38498. */
  38499. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38500. /**
  38501. * Load a script (identified by an url). When the url returns, the
  38502. * content of this file is added into a new script element, attached to the DOM (body element)
  38503. * @param scriptUrl defines the url of the script to laod
  38504. * @param onSuccess defines the callback called when the script is loaded
  38505. * @param onError defines the callback to call if an error occurs
  38506. * @param scriptId defines the id of the script element
  38507. */
  38508. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38509. /**
  38510. * Load an asynchronous script (identified by an url). When the url returns, the
  38511. * content of this file is added into a new script element, attached to the DOM (body element)
  38512. * @param scriptUrl defines the url of the script to laod
  38513. * @param scriptId defines the id of the script element
  38514. * @returns a promise request object
  38515. */
  38516. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38517. /**
  38518. * Loads a file from a blob
  38519. * @param fileToLoad defines the blob to use
  38520. * @param callback defines the callback to call when data is loaded
  38521. * @param progressCallback defines the callback to call during loading process
  38522. * @returns a file request object
  38523. */
  38524. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38525. /**
  38526. * Reads a file from a File object
  38527. * @param file defines the file to load
  38528. * @param onSuccess defines the callback to call when data is loaded
  38529. * @param onProgress defines the callback to call during loading process
  38530. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38531. * @param onError defines the callback to call when an error occurs
  38532. * @returns a file request object
  38533. */
  38534. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38535. /**
  38536. * Creates a data url from a given string content
  38537. * @param content defines the content to convert
  38538. * @returns the new data url link
  38539. */
  38540. static FileAsURL(content: string): string;
  38541. /**
  38542. * Format the given number to a specific decimal format
  38543. * @param value defines the number to format
  38544. * @param decimals defines the number of decimals to use
  38545. * @returns the formatted string
  38546. */
  38547. static Format(value: number, decimals?: number): string;
  38548. /**
  38549. * Tries to copy an object by duplicating every property
  38550. * @param source defines the source object
  38551. * @param destination defines the target object
  38552. * @param doNotCopyList defines a list of properties to avoid
  38553. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38554. */
  38555. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38556. /**
  38557. * Gets a boolean indicating if the given object has no own property
  38558. * @param obj defines the object to test
  38559. * @returns true if object has no own property
  38560. */
  38561. static IsEmpty(obj: any): boolean;
  38562. /**
  38563. * Function used to register events at window level
  38564. * @param windowElement defines the Window object to use
  38565. * @param events defines the events to register
  38566. */
  38567. static RegisterTopRootEvents(windowElement: Window, events: {
  38568. name: string;
  38569. handler: Nullable<(e: FocusEvent) => any>;
  38570. }[]): void;
  38571. /**
  38572. * Function used to unregister events from window level
  38573. * @param windowElement defines the Window object to use
  38574. * @param events defines the events to unregister
  38575. */
  38576. static UnregisterTopRootEvents(windowElement: Window, events: {
  38577. name: string;
  38578. handler: Nullable<(e: FocusEvent) => any>;
  38579. }[]): void;
  38580. /**
  38581. * @ignore
  38582. */
  38583. static _ScreenshotCanvas: HTMLCanvasElement;
  38584. /**
  38585. * Dumps the current bound framebuffer
  38586. * @param width defines the rendering width
  38587. * @param height defines the rendering height
  38588. * @param engine defines the hosting engine
  38589. * @param successCallback defines the callback triggered once the data are available
  38590. * @param mimeType defines the mime type of the result
  38591. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38592. */
  38593. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38594. /**
  38595. * Converts the canvas data to blob.
  38596. * This acts as a polyfill for browsers not supporting the to blob function.
  38597. * @param canvas Defines the canvas to extract the data from
  38598. * @param successCallback Defines the callback triggered once the data are available
  38599. * @param mimeType Defines the mime type of the result
  38600. */
  38601. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38602. /**
  38603. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38604. * @param successCallback defines the callback triggered once the data are available
  38605. * @param mimeType defines the mime type of the result
  38606. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38607. */
  38608. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38609. /**
  38610. * Downloads a blob in the browser
  38611. * @param blob defines the blob to download
  38612. * @param fileName defines the name of the downloaded file
  38613. */
  38614. static Download(blob: Blob, fileName: string): void;
  38615. /**
  38616. * Captures a screenshot of the current rendering
  38617. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38618. * @param engine defines the rendering engine
  38619. * @param camera defines the source camera
  38620. * @param size This parameter can be set to a single number or to an object with the
  38621. * following (optional) properties: precision, width, height. If a single number is passed,
  38622. * it will be used for both width and height. If an object is passed, the screenshot size
  38623. * will be derived from the parameters. The precision property is a multiplier allowing
  38624. * rendering at a higher or lower resolution
  38625. * @param successCallback defines the callback receives a single parameter which contains the
  38626. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38627. * src parameter of an <img> to display it
  38628. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38629. * Check your browser for supported MIME types
  38630. */
  38631. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38632. /**
  38633. * Captures a screenshot of the current rendering
  38634. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38635. * @param engine defines the rendering engine
  38636. * @param camera defines the source camera
  38637. * @param size This parameter can be set to a single number or to an object with the
  38638. * following (optional) properties: precision, width, height. If a single number is passed,
  38639. * it will be used for both width and height. If an object is passed, the screenshot size
  38640. * will be derived from the parameters. The precision property is a multiplier allowing
  38641. * rendering at a higher or lower resolution
  38642. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38643. * Check your browser for supported MIME types
  38644. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38645. * to the src parameter of an <img> to display it
  38646. */
  38647. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38648. /**
  38649. * Generates an image screenshot from the specified camera.
  38650. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38651. * @param engine The engine to use for rendering
  38652. * @param camera The camera to use for rendering
  38653. * @param size This parameter can be set to a single number or to an object with the
  38654. * following (optional) properties: precision, width, height. If a single number is passed,
  38655. * it will be used for both width and height. If an object is passed, the screenshot size
  38656. * will be derived from the parameters. The precision property is a multiplier allowing
  38657. * rendering at a higher or lower resolution
  38658. * @param successCallback The callback receives a single parameter which contains the
  38659. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38660. * src parameter of an <img> to display it
  38661. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38662. * Check your browser for supported MIME types
  38663. * @param samples Texture samples (default: 1)
  38664. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38665. * @param fileName A name for for the downloaded file.
  38666. */
  38667. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38668. /**
  38669. * Generates an image screenshot from the specified camera.
  38670. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38671. * @param engine The engine to use for rendering
  38672. * @param camera The camera to use for rendering
  38673. * @param size This parameter can be set to a single number or to an object with the
  38674. * following (optional) properties: precision, width, height. If a single number is passed,
  38675. * it will be used for both width and height. If an object is passed, the screenshot size
  38676. * will be derived from the parameters. The precision property is a multiplier allowing
  38677. * rendering at a higher or lower resolution
  38678. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38679. * Check your browser for supported MIME types
  38680. * @param samples Texture samples (default: 1)
  38681. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38682. * @param fileName A name for for the downloaded file.
  38683. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38684. * to the src parameter of an <img> to display it
  38685. */
  38686. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38687. /**
  38688. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38689. * Be aware Math.random() could cause collisions, but:
  38690. * "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"
  38691. * @returns a pseudo random id
  38692. */
  38693. static RandomId(): string;
  38694. /**
  38695. * Test if the given uri is a base64 string
  38696. * @param uri The uri to test
  38697. * @return True if the uri is a base64 string or false otherwise
  38698. */
  38699. static IsBase64(uri: string): boolean;
  38700. /**
  38701. * Decode the given base64 uri.
  38702. * @param uri The uri to decode
  38703. * @return The decoded base64 data.
  38704. */
  38705. static DecodeBase64(uri: string): ArrayBuffer;
  38706. /**
  38707. * Gets the absolute url.
  38708. * @param url the input url
  38709. * @return the absolute url
  38710. */
  38711. static GetAbsoluteUrl(url: string): string;
  38712. /**
  38713. * No log
  38714. */
  38715. static readonly NoneLogLevel: number;
  38716. /**
  38717. * Only message logs
  38718. */
  38719. static readonly MessageLogLevel: number;
  38720. /**
  38721. * Only warning logs
  38722. */
  38723. static readonly WarningLogLevel: number;
  38724. /**
  38725. * Only error logs
  38726. */
  38727. static readonly ErrorLogLevel: number;
  38728. /**
  38729. * All logs
  38730. */
  38731. static readonly AllLogLevel: number;
  38732. /**
  38733. * Gets a value indicating the number of loading errors
  38734. * @ignorenaming
  38735. */
  38736. static get errorsCount(): number;
  38737. /**
  38738. * Callback called when a new log is added
  38739. */
  38740. static OnNewCacheEntry: (entry: string) => void;
  38741. /**
  38742. * Log a message to the console
  38743. * @param message defines the message to log
  38744. */
  38745. static Log(message: string): void;
  38746. /**
  38747. * Write a warning message to the console
  38748. * @param message defines the message to log
  38749. */
  38750. static Warn(message: string): void;
  38751. /**
  38752. * Write an error message to the console
  38753. * @param message defines the message to log
  38754. */
  38755. static Error(message: string): void;
  38756. /**
  38757. * Gets current log cache (list of logs)
  38758. */
  38759. static get LogCache(): string;
  38760. /**
  38761. * Clears the log cache
  38762. */
  38763. static ClearLogCache(): void;
  38764. /**
  38765. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38766. */
  38767. static set LogLevels(level: number);
  38768. /**
  38769. * Checks if the window object exists
  38770. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38771. */
  38772. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38773. /**
  38774. * No performance log
  38775. */
  38776. static readonly PerformanceNoneLogLevel: number;
  38777. /**
  38778. * Use user marks to log performance
  38779. */
  38780. static readonly PerformanceUserMarkLogLevel: number;
  38781. /**
  38782. * Log performance to the console
  38783. */
  38784. static readonly PerformanceConsoleLogLevel: number;
  38785. private static _performance;
  38786. /**
  38787. * Sets the current performance log level
  38788. */
  38789. static set PerformanceLogLevel(level: number);
  38790. private static _StartPerformanceCounterDisabled;
  38791. private static _EndPerformanceCounterDisabled;
  38792. private static _StartUserMark;
  38793. private static _EndUserMark;
  38794. private static _StartPerformanceConsole;
  38795. private static _EndPerformanceConsole;
  38796. /**
  38797. * Starts a performance counter
  38798. */
  38799. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38800. /**
  38801. * Ends a specific performance coutner
  38802. */
  38803. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38804. /**
  38805. * Gets either window.performance.now() if supported or Date.now() else
  38806. */
  38807. static get Now(): number;
  38808. /**
  38809. * This method will return the name of the class used to create the instance of the given object.
  38810. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38811. * @param object the object to get the class name from
  38812. * @param isType defines if the object is actually a type
  38813. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38814. */
  38815. static GetClassName(object: any, isType?: boolean): string;
  38816. /**
  38817. * Gets the first element of an array satisfying a given predicate
  38818. * @param array defines the array to browse
  38819. * @param predicate defines the predicate to use
  38820. * @returns null if not found or the element
  38821. */
  38822. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38823. /**
  38824. * This method will return the name of the full name of the class, including its owning module (if any).
  38825. * 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).
  38826. * @param object the object to get the class name from
  38827. * @param isType defines if the object is actually a type
  38828. * @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.
  38829. * @ignorenaming
  38830. */
  38831. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38832. /**
  38833. * Returns a promise that resolves after the given amount of time.
  38834. * @param delay Number of milliseconds to delay
  38835. * @returns Promise that resolves after the given amount of time
  38836. */
  38837. static DelayAsync(delay: number): Promise<void>;
  38838. /**
  38839. * Utility function to detect if the current user agent is Safari
  38840. * @returns whether or not the current user agent is safari
  38841. */
  38842. static IsSafari(): boolean;
  38843. }
  38844. /**
  38845. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38846. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38847. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38848. * @param name The name of the class, case should be preserved
  38849. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38850. */
  38851. export function className(name: string, module?: string): (target: Object) => void;
  38852. /**
  38853. * An implementation of a loop for asynchronous functions.
  38854. */
  38855. export class AsyncLoop {
  38856. /**
  38857. * Defines the number of iterations for the loop
  38858. */
  38859. iterations: number;
  38860. /**
  38861. * Defines the current index of the loop.
  38862. */
  38863. index: number;
  38864. private _done;
  38865. private _fn;
  38866. private _successCallback;
  38867. /**
  38868. * Constructor.
  38869. * @param iterations the number of iterations.
  38870. * @param func the function to run each iteration
  38871. * @param successCallback the callback that will be called upon succesful execution
  38872. * @param offset starting offset.
  38873. */
  38874. constructor(
  38875. /**
  38876. * Defines the number of iterations for the loop
  38877. */
  38878. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38879. /**
  38880. * Execute the next iteration. Must be called after the last iteration was finished.
  38881. */
  38882. executeNext(): void;
  38883. /**
  38884. * Break the loop and run the success callback.
  38885. */
  38886. breakLoop(): void;
  38887. /**
  38888. * Create and run an async loop.
  38889. * @param iterations the number of iterations.
  38890. * @param fn the function to run each iteration
  38891. * @param successCallback the callback that will be called upon succesful execution
  38892. * @param offset starting offset.
  38893. * @returns the created async loop object
  38894. */
  38895. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38896. /**
  38897. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38898. * @param iterations total number of iterations
  38899. * @param syncedIterations number of synchronous iterations in each async iteration.
  38900. * @param fn the function to call each iteration.
  38901. * @param callback a success call back that will be called when iterating stops.
  38902. * @param breakFunction a break condition (optional)
  38903. * @param timeout timeout settings for the setTimeout function. default - 0.
  38904. * @returns the created async loop object
  38905. */
  38906. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38907. }
  38908. }
  38909. declare module BABYLON {
  38910. /**
  38911. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38912. * The underlying implementation relies on an associative array to ensure the best performances.
  38913. * The value can be anything including 'null' but except 'undefined'
  38914. */
  38915. export class StringDictionary<T> {
  38916. /**
  38917. * This will clear this dictionary and copy the content from the 'source' one.
  38918. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38919. * @param source the dictionary to take the content from and copy to this dictionary
  38920. */
  38921. copyFrom(source: StringDictionary<T>): void;
  38922. /**
  38923. * Get a value based from its key
  38924. * @param key the given key to get the matching value from
  38925. * @return the value if found, otherwise undefined is returned
  38926. */
  38927. get(key: string): T | undefined;
  38928. /**
  38929. * Get a value from its key or add it if it doesn't exist.
  38930. * This method will ensure you that a given key/data will be present in the dictionary.
  38931. * @param key the given key to get the matching value from
  38932. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38933. * The factory will only be invoked if there's no data for the given key.
  38934. * @return the value corresponding to the key.
  38935. */
  38936. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38937. /**
  38938. * Get a value from its key if present in the dictionary otherwise add it
  38939. * @param key the key to get the value from
  38940. * @param val if there's no such key/value pair in the dictionary add it with this value
  38941. * @return the value corresponding to the key
  38942. */
  38943. getOrAdd(key: string, val: T): T;
  38944. /**
  38945. * Check if there's a given key in the dictionary
  38946. * @param key the key to check for
  38947. * @return true if the key is present, false otherwise
  38948. */
  38949. contains(key: string): boolean;
  38950. /**
  38951. * Add a new key and its corresponding value
  38952. * @param key the key to add
  38953. * @param value the value corresponding to the key
  38954. * @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
  38955. */
  38956. add(key: string, value: T): boolean;
  38957. /**
  38958. * Update a specific value associated to a key
  38959. * @param key defines the key to use
  38960. * @param value defines the value to store
  38961. * @returns true if the value was updated (or false if the key was not found)
  38962. */
  38963. set(key: string, value: T): boolean;
  38964. /**
  38965. * Get the element of the given key and remove it from the dictionary
  38966. * @param key defines the key to search
  38967. * @returns the value associated with the key or null if not found
  38968. */
  38969. getAndRemove(key: string): Nullable<T>;
  38970. /**
  38971. * Remove a key/value from the dictionary.
  38972. * @param key the key to remove
  38973. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38974. */
  38975. remove(key: string): boolean;
  38976. /**
  38977. * Clear the whole content of the dictionary
  38978. */
  38979. clear(): void;
  38980. /**
  38981. * Gets the current count
  38982. */
  38983. get count(): number;
  38984. /**
  38985. * Execute a callback on each key/val of the dictionary.
  38986. * Note that you can remove any element in this dictionary in the callback implementation
  38987. * @param callback the callback to execute on a given key/value pair
  38988. */
  38989. forEach(callback: (key: string, val: T) => void): void;
  38990. /**
  38991. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38992. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38993. * Note that you can remove any element in this dictionary in the callback implementation
  38994. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38995. * @returns the first item
  38996. */
  38997. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38998. private _count;
  38999. private _data;
  39000. }
  39001. }
  39002. declare module BABYLON {
  39003. /** @hidden */
  39004. export interface ICollisionCoordinator {
  39005. createCollider(): Collider;
  39006. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39007. init(scene: Scene): void;
  39008. }
  39009. /** @hidden */
  39010. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  39011. private _scene;
  39012. private _scaledPosition;
  39013. private _scaledVelocity;
  39014. private _finalPosition;
  39015. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39016. createCollider(): Collider;
  39017. init(scene: Scene): void;
  39018. private _collideWithWorld;
  39019. }
  39020. }
  39021. declare module BABYLON {
  39022. /**
  39023. * Class used to manage all inputs for the scene.
  39024. */
  39025. export class InputManager {
  39026. /** The distance in pixel that you have to move to prevent some events */
  39027. static DragMovementThreshold: number;
  39028. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  39029. static LongPressDelay: number;
  39030. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  39031. static DoubleClickDelay: number;
  39032. /** If you need to check double click without raising a single click at first click, enable this flag */
  39033. static ExclusiveDoubleClickMode: boolean;
  39034. /** 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. */
  39035. private _alreadyAttached;
  39036. private _wheelEventName;
  39037. private _onPointerMove;
  39038. private _onPointerDown;
  39039. private _onPointerUp;
  39040. private _initClickEvent;
  39041. private _initActionManager;
  39042. private _delayedSimpleClick;
  39043. private _delayedSimpleClickTimeout;
  39044. private _previousDelayedSimpleClickTimeout;
  39045. private _meshPickProceed;
  39046. private _previousButtonPressed;
  39047. private _currentPickResult;
  39048. private _previousPickResult;
  39049. private _totalPointersPressed;
  39050. private _doubleClickOccured;
  39051. private _pointerOverMesh;
  39052. private _pickedDownMesh;
  39053. private _pickedUpMesh;
  39054. private _pointerX;
  39055. private _pointerY;
  39056. private _unTranslatedPointerX;
  39057. private _unTranslatedPointerY;
  39058. private _startingPointerPosition;
  39059. private _previousStartingPointerPosition;
  39060. private _startingPointerTime;
  39061. private _previousStartingPointerTime;
  39062. private _pointerCaptures;
  39063. private _meshUnderPointerId;
  39064. private _onKeyDown;
  39065. private _onKeyUp;
  39066. private _onCanvasFocusObserver;
  39067. private _onCanvasBlurObserver;
  39068. private _scene;
  39069. /**
  39070. * Creates a new InputManager
  39071. * @param scene defines the hosting scene
  39072. */
  39073. constructor(scene: Scene);
  39074. /**
  39075. * Gets the mesh that is currently under the pointer
  39076. */
  39077. get meshUnderPointer(): Nullable<AbstractMesh>;
  39078. /**
  39079. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  39080. * @param pointerId the pointer id to use
  39081. * @returns The mesh under this pointer id or null if not found
  39082. */
  39083. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  39084. /**
  39085. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  39086. */
  39087. get unTranslatedPointer(): Vector2;
  39088. /**
  39089. * Gets or sets the current on-screen X position of the pointer
  39090. */
  39091. get pointerX(): number;
  39092. set pointerX(value: number);
  39093. /**
  39094. * Gets or sets the current on-screen Y position of the pointer
  39095. */
  39096. get pointerY(): number;
  39097. set pointerY(value: number);
  39098. private _updatePointerPosition;
  39099. private _processPointerMove;
  39100. private _setRayOnPointerInfo;
  39101. private _checkPrePointerObservable;
  39102. /**
  39103. * Use this method to simulate a pointer move on a mesh
  39104. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39105. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39106. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39107. */
  39108. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39109. /**
  39110. * Use this method to simulate a pointer down on a mesh
  39111. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39112. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39113. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39114. */
  39115. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39116. private _processPointerDown;
  39117. /** @hidden */
  39118. _isPointerSwiping(): boolean;
  39119. /**
  39120. * Use this method to simulate a pointer up on a mesh
  39121. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39122. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39123. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39124. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39125. */
  39126. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39127. private _processPointerUp;
  39128. /**
  39129. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39130. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39131. * @returns true if the pointer was captured
  39132. */
  39133. isPointerCaptured(pointerId?: number): boolean;
  39134. /**
  39135. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39136. * @param attachUp defines if you want to attach events to pointerup
  39137. * @param attachDown defines if you want to attach events to pointerdown
  39138. * @param attachMove defines if you want to attach events to pointermove
  39139. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39140. */
  39141. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39142. /**
  39143. * Detaches all event handlers
  39144. */
  39145. detachControl(): void;
  39146. /**
  39147. * Force the value of meshUnderPointer
  39148. * @param mesh defines the mesh to use
  39149. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  39150. */
  39151. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  39152. /**
  39153. * Gets the mesh under the pointer
  39154. * @returns a Mesh or null if no mesh is under the pointer
  39155. */
  39156. getPointerOverMesh(): Nullable<AbstractMesh>;
  39157. }
  39158. }
  39159. declare module BABYLON {
  39160. /**
  39161. * This class defines the direct association between an animation and a target
  39162. */
  39163. export class TargetedAnimation {
  39164. /**
  39165. * Animation to perform
  39166. */
  39167. animation: Animation;
  39168. /**
  39169. * Target to animate
  39170. */
  39171. target: any;
  39172. /**
  39173. * Returns the string "TargetedAnimation"
  39174. * @returns "TargetedAnimation"
  39175. */
  39176. getClassName(): string;
  39177. /**
  39178. * Serialize the object
  39179. * @returns the JSON object representing the current entity
  39180. */
  39181. serialize(): any;
  39182. }
  39183. /**
  39184. * Use this class to create coordinated animations on multiple targets
  39185. */
  39186. export class AnimationGroup implements IDisposable {
  39187. /** The name of the animation group */
  39188. name: string;
  39189. private _scene;
  39190. private _targetedAnimations;
  39191. private _animatables;
  39192. private _from;
  39193. private _to;
  39194. private _isStarted;
  39195. private _isPaused;
  39196. private _speedRatio;
  39197. private _loopAnimation;
  39198. private _isAdditive;
  39199. /**
  39200. * Gets or sets the unique id of the node
  39201. */
  39202. uniqueId: number;
  39203. /**
  39204. * This observable will notify when one animation have ended
  39205. */
  39206. onAnimationEndObservable: Observable<TargetedAnimation>;
  39207. /**
  39208. * Observer raised when one animation loops
  39209. */
  39210. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39211. /**
  39212. * Observer raised when all animations have looped
  39213. */
  39214. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39215. /**
  39216. * This observable will notify when all animations have ended.
  39217. */
  39218. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39219. /**
  39220. * This observable will notify when all animations have paused.
  39221. */
  39222. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39223. /**
  39224. * This observable will notify when all animations are playing.
  39225. */
  39226. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39227. /**
  39228. * Gets the first frame
  39229. */
  39230. get from(): number;
  39231. /**
  39232. * Gets the last frame
  39233. */
  39234. get to(): number;
  39235. /**
  39236. * Define if the animations are started
  39237. */
  39238. get isStarted(): boolean;
  39239. /**
  39240. * Gets a value indicating that the current group is playing
  39241. */
  39242. get isPlaying(): boolean;
  39243. /**
  39244. * Gets or sets the speed ratio to use for all animations
  39245. */
  39246. get speedRatio(): number;
  39247. /**
  39248. * Gets or sets the speed ratio to use for all animations
  39249. */
  39250. set speedRatio(value: number);
  39251. /**
  39252. * Gets or sets if all animations should loop or not
  39253. */
  39254. get loopAnimation(): boolean;
  39255. set loopAnimation(value: boolean);
  39256. /**
  39257. * Gets or sets if all animations should be evaluated additively
  39258. */
  39259. get isAdditive(): boolean;
  39260. set isAdditive(value: boolean);
  39261. /**
  39262. * Gets the targeted animations for this animation group
  39263. */
  39264. get targetedAnimations(): Array<TargetedAnimation>;
  39265. /**
  39266. * returning the list of animatables controlled by this animation group.
  39267. */
  39268. get animatables(): Array<Animatable>;
  39269. /**
  39270. * Gets the list of target animations
  39271. */
  39272. get children(): TargetedAnimation[];
  39273. /**
  39274. * Instantiates a new Animation Group.
  39275. * This helps managing several animations at once.
  39276. * @see https://doc.babylonjs.com/how_to/group
  39277. * @param name Defines the name of the group
  39278. * @param scene Defines the scene the group belongs to
  39279. */
  39280. constructor(
  39281. /** The name of the animation group */
  39282. name: string, scene?: Nullable<Scene>);
  39283. /**
  39284. * Add an animation (with its target) in the group
  39285. * @param animation defines the animation we want to add
  39286. * @param target defines the target of the animation
  39287. * @returns the TargetedAnimation object
  39288. */
  39289. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39290. /**
  39291. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39292. * It can add constant keys at begin or end
  39293. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39294. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39295. * @returns the animation group
  39296. */
  39297. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39298. private _animationLoopCount;
  39299. private _animationLoopFlags;
  39300. private _processLoop;
  39301. /**
  39302. * Start all animations on given targets
  39303. * @param loop defines if animations must loop
  39304. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39305. * @param from defines the from key (optional)
  39306. * @param to defines the to key (optional)
  39307. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39308. * @returns the current animation group
  39309. */
  39310. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39311. /**
  39312. * Pause all animations
  39313. * @returns the animation group
  39314. */
  39315. pause(): AnimationGroup;
  39316. /**
  39317. * Play all animations to initial state
  39318. * This function will start() the animations if they were not started or will restart() them if they were paused
  39319. * @param loop defines if animations must loop
  39320. * @returns the animation group
  39321. */
  39322. play(loop?: boolean): AnimationGroup;
  39323. /**
  39324. * Reset all animations to initial state
  39325. * @returns the animation group
  39326. */
  39327. reset(): AnimationGroup;
  39328. /**
  39329. * Restart animations from key 0
  39330. * @returns the animation group
  39331. */
  39332. restart(): AnimationGroup;
  39333. /**
  39334. * Stop all animations
  39335. * @returns the animation group
  39336. */
  39337. stop(): AnimationGroup;
  39338. /**
  39339. * Set animation weight for all animatables
  39340. * @param weight defines the weight to use
  39341. * @return the animationGroup
  39342. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39343. */
  39344. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39345. /**
  39346. * Synchronize and normalize all animatables with a source animatable
  39347. * @param root defines the root animatable to synchronize with
  39348. * @return the animationGroup
  39349. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39350. */
  39351. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39352. /**
  39353. * Goes to a specific frame in this animation group
  39354. * @param frame the frame number to go to
  39355. * @return the animationGroup
  39356. */
  39357. goToFrame(frame: number): AnimationGroup;
  39358. /**
  39359. * Dispose all associated resources
  39360. */
  39361. dispose(): void;
  39362. private _checkAnimationGroupEnded;
  39363. /**
  39364. * Clone the current animation group and returns a copy
  39365. * @param newName defines the name of the new group
  39366. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39367. * @returns the new aniamtion group
  39368. */
  39369. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39370. /**
  39371. * Serializes the animationGroup to an object
  39372. * @returns Serialized object
  39373. */
  39374. serialize(): any;
  39375. /**
  39376. * Returns a new AnimationGroup object parsed from the source provided.
  39377. * @param parsedAnimationGroup defines the source
  39378. * @param scene defines the scene that will receive the animationGroup
  39379. * @returns a new AnimationGroup
  39380. */
  39381. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39382. /**
  39383. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39384. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39385. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39386. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39387. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39388. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39389. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39390. */
  39391. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39392. /**
  39393. * Returns the string "AnimationGroup"
  39394. * @returns "AnimationGroup"
  39395. */
  39396. getClassName(): string;
  39397. /**
  39398. * Creates a detailled string about the object
  39399. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39400. * @returns a string representing the object
  39401. */
  39402. toString(fullDetails?: boolean): string;
  39403. }
  39404. }
  39405. declare module BABYLON {
  39406. /**
  39407. * Define an interface for all classes that will hold resources
  39408. */
  39409. export interface IDisposable {
  39410. /**
  39411. * Releases all held resources
  39412. */
  39413. dispose(): void;
  39414. }
  39415. /** Interface defining initialization parameters for Scene class */
  39416. export interface SceneOptions {
  39417. /**
  39418. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39419. * It will improve performance when the number of geometries becomes important.
  39420. */
  39421. useGeometryUniqueIdsMap?: boolean;
  39422. /**
  39423. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39424. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39425. */
  39426. useMaterialMeshMap?: boolean;
  39427. /**
  39428. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39429. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39430. */
  39431. useClonedMeshMap?: boolean;
  39432. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39433. virtual?: boolean;
  39434. }
  39435. /**
  39436. * Represents a scene to be rendered by the engine.
  39437. * @see https://doc.babylonjs.com/features/scene
  39438. */
  39439. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  39440. /** The fog is deactivated */
  39441. static readonly FOGMODE_NONE: number;
  39442. /** The fog density is following an exponential function */
  39443. static readonly FOGMODE_EXP: number;
  39444. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39445. static readonly FOGMODE_EXP2: number;
  39446. /** The fog density is following a linear function. */
  39447. static readonly FOGMODE_LINEAR: number;
  39448. /**
  39449. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39450. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39451. */
  39452. static MinDeltaTime: number;
  39453. /**
  39454. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39455. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39456. */
  39457. static MaxDeltaTime: number;
  39458. /**
  39459. * Factory used to create the default material.
  39460. * @param name The name of the material to create
  39461. * @param scene The scene to create the material for
  39462. * @returns The default material
  39463. */
  39464. static DefaultMaterialFactory(scene: Scene): Material;
  39465. /**
  39466. * Factory used to create the a collision coordinator.
  39467. * @returns The collision coordinator
  39468. */
  39469. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39470. /** @hidden */
  39471. _inputManager: InputManager;
  39472. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39473. cameraToUseForPointers: Nullable<Camera>;
  39474. /** @hidden */
  39475. readonly _isScene: boolean;
  39476. /** @hidden */
  39477. _blockEntityCollection: boolean;
  39478. /**
  39479. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39480. */
  39481. autoClear: boolean;
  39482. /**
  39483. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39484. */
  39485. autoClearDepthAndStencil: boolean;
  39486. /**
  39487. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39488. */
  39489. clearColor: Color4;
  39490. /**
  39491. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39492. */
  39493. ambientColor: Color3;
  39494. /**
  39495. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39496. * It should only be one of the following (if not the default embedded one):
  39497. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39498. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39499. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39500. * The material properties need to be setup according to the type of texture in use.
  39501. */
  39502. environmentBRDFTexture: BaseTexture;
  39503. /**
  39504. * Texture used in all pbr material as the reflection texture.
  39505. * As in the majority of the scene they are the same (exception for multi room and so on),
  39506. * this is easier to reference from here than from all the materials.
  39507. */
  39508. get environmentTexture(): Nullable<BaseTexture>;
  39509. /**
  39510. * Texture used in all pbr material as the reflection texture.
  39511. * As in the majority of the scene they are the same (exception for multi room and so on),
  39512. * this is easier to set here than in all the materials.
  39513. */
  39514. set environmentTexture(value: Nullable<BaseTexture>);
  39515. /** @hidden */
  39516. protected _environmentIntensity: number;
  39517. /**
  39518. * Intensity of the environment in all pbr material.
  39519. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39520. * As in the majority of the scene they are the same (exception for multi room and so on),
  39521. * this is easier to reference from here than from all the materials.
  39522. */
  39523. get environmentIntensity(): number;
  39524. /**
  39525. * Intensity of the environment in all pbr material.
  39526. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39527. * As in the majority of the scene they are the same (exception for multi room and so on),
  39528. * this is easier to set here than in all the materials.
  39529. */
  39530. set environmentIntensity(value: number);
  39531. /** @hidden */
  39532. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39533. /**
  39534. * Default image processing configuration used either in the rendering
  39535. * Forward main pass or through the imageProcessingPostProcess if present.
  39536. * As in the majority of the scene they are the same (exception for multi camera),
  39537. * this is easier to reference from here than from all the materials and post process.
  39538. *
  39539. * No setter as we it is a shared configuration, you can set the values instead.
  39540. */
  39541. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39542. private _forceWireframe;
  39543. /**
  39544. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39545. */
  39546. set forceWireframe(value: boolean);
  39547. get forceWireframe(): boolean;
  39548. private _skipFrustumClipping;
  39549. /**
  39550. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39551. */
  39552. set skipFrustumClipping(value: boolean);
  39553. get skipFrustumClipping(): boolean;
  39554. private _forcePointsCloud;
  39555. /**
  39556. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39557. */
  39558. set forcePointsCloud(value: boolean);
  39559. get forcePointsCloud(): boolean;
  39560. /**
  39561. * Gets or sets the active clipplane 1
  39562. */
  39563. clipPlane: Nullable<Plane>;
  39564. /**
  39565. * Gets or sets the active clipplane 2
  39566. */
  39567. clipPlane2: Nullable<Plane>;
  39568. /**
  39569. * Gets or sets the active clipplane 3
  39570. */
  39571. clipPlane3: Nullable<Plane>;
  39572. /**
  39573. * Gets or sets the active clipplane 4
  39574. */
  39575. clipPlane4: Nullable<Plane>;
  39576. /**
  39577. * Gets or sets the active clipplane 5
  39578. */
  39579. clipPlane5: Nullable<Plane>;
  39580. /**
  39581. * Gets or sets the active clipplane 6
  39582. */
  39583. clipPlane6: Nullable<Plane>;
  39584. /**
  39585. * Gets or sets a boolean indicating if animations are enabled
  39586. */
  39587. animationsEnabled: boolean;
  39588. private _animationPropertiesOverride;
  39589. /**
  39590. * Gets or sets the animation properties override
  39591. */
  39592. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39593. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39594. /**
  39595. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39596. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39597. */
  39598. useConstantAnimationDeltaTime: boolean;
  39599. /**
  39600. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39601. * Please note that it requires to run a ray cast through the scene on every frame
  39602. */
  39603. constantlyUpdateMeshUnderPointer: boolean;
  39604. /**
  39605. * Defines the HTML cursor to use when hovering over interactive elements
  39606. */
  39607. hoverCursor: string;
  39608. /**
  39609. * Defines the HTML default cursor to use (empty by default)
  39610. */
  39611. defaultCursor: string;
  39612. /**
  39613. * Defines whether cursors are handled by the scene.
  39614. */
  39615. doNotHandleCursors: boolean;
  39616. /**
  39617. * This is used to call preventDefault() on pointer down
  39618. * in order to block unwanted artifacts like system double clicks
  39619. */
  39620. preventDefaultOnPointerDown: boolean;
  39621. /**
  39622. * This is used to call preventDefault() on pointer up
  39623. * in order to block unwanted artifacts like system double clicks
  39624. */
  39625. preventDefaultOnPointerUp: boolean;
  39626. /**
  39627. * Gets or sets user defined metadata
  39628. */
  39629. metadata: any;
  39630. /**
  39631. * For internal use only. Please do not use.
  39632. */
  39633. reservedDataStore: any;
  39634. /**
  39635. * Gets the name of the plugin used to load this scene (null by default)
  39636. */
  39637. loadingPluginName: string;
  39638. /**
  39639. * Use this array to add regular expressions used to disable offline support for specific urls
  39640. */
  39641. disableOfflineSupportExceptionRules: RegExp[];
  39642. /**
  39643. * An event triggered when the scene is disposed.
  39644. */
  39645. onDisposeObservable: Observable<Scene>;
  39646. private _onDisposeObserver;
  39647. /** Sets a function to be executed when this scene is disposed. */
  39648. set onDispose(callback: () => void);
  39649. /**
  39650. * An event triggered before rendering the scene (right after animations and physics)
  39651. */
  39652. onBeforeRenderObservable: Observable<Scene>;
  39653. private _onBeforeRenderObserver;
  39654. /** Sets a function to be executed before rendering this scene */
  39655. set beforeRender(callback: Nullable<() => void>);
  39656. /**
  39657. * An event triggered after rendering the scene
  39658. */
  39659. onAfterRenderObservable: Observable<Scene>;
  39660. /**
  39661. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39662. */
  39663. onAfterRenderCameraObservable: Observable<Camera>;
  39664. private _onAfterRenderObserver;
  39665. /** Sets a function to be executed after rendering this scene */
  39666. set afterRender(callback: Nullable<() => void>);
  39667. /**
  39668. * An event triggered before animating the scene
  39669. */
  39670. onBeforeAnimationsObservable: Observable<Scene>;
  39671. /**
  39672. * An event triggered after animations processing
  39673. */
  39674. onAfterAnimationsObservable: Observable<Scene>;
  39675. /**
  39676. * An event triggered before draw calls are ready to be sent
  39677. */
  39678. onBeforeDrawPhaseObservable: Observable<Scene>;
  39679. /**
  39680. * An event triggered after draw calls have been sent
  39681. */
  39682. onAfterDrawPhaseObservable: Observable<Scene>;
  39683. /**
  39684. * An event triggered when the scene is ready
  39685. */
  39686. onReadyObservable: Observable<Scene>;
  39687. /**
  39688. * An event triggered before rendering a camera
  39689. */
  39690. onBeforeCameraRenderObservable: Observable<Camera>;
  39691. private _onBeforeCameraRenderObserver;
  39692. /** Sets a function to be executed before rendering a camera*/
  39693. set beforeCameraRender(callback: () => void);
  39694. /**
  39695. * An event triggered after rendering a camera
  39696. */
  39697. onAfterCameraRenderObservable: Observable<Camera>;
  39698. private _onAfterCameraRenderObserver;
  39699. /** Sets a function to be executed after rendering a camera*/
  39700. set afterCameraRender(callback: () => void);
  39701. /**
  39702. * An event triggered when active meshes evaluation is about to start
  39703. */
  39704. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39705. /**
  39706. * An event triggered when active meshes evaluation is done
  39707. */
  39708. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39709. /**
  39710. * An event triggered when particles rendering is about to start
  39711. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39712. */
  39713. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39714. /**
  39715. * An event triggered when particles rendering is done
  39716. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39717. */
  39718. onAfterParticlesRenderingObservable: Observable<Scene>;
  39719. /**
  39720. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39721. */
  39722. onDataLoadedObservable: Observable<Scene>;
  39723. /**
  39724. * An event triggered when a camera is created
  39725. */
  39726. onNewCameraAddedObservable: Observable<Camera>;
  39727. /**
  39728. * An event triggered when a camera is removed
  39729. */
  39730. onCameraRemovedObservable: Observable<Camera>;
  39731. /**
  39732. * An event triggered when a light is created
  39733. */
  39734. onNewLightAddedObservable: Observable<Light>;
  39735. /**
  39736. * An event triggered when a light is removed
  39737. */
  39738. onLightRemovedObservable: Observable<Light>;
  39739. /**
  39740. * An event triggered when a geometry is created
  39741. */
  39742. onNewGeometryAddedObservable: Observable<Geometry>;
  39743. /**
  39744. * An event triggered when a geometry is removed
  39745. */
  39746. onGeometryRemovedObservable: Observable<Geometry>;
  39747. /**
  39748. * An event triggered when a transform node is created
  39749. */
  39750. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39751. /**
  39752. * An event triggered when a transform node is removed
  39753. */
  39754. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39755. /**
  39756. * An event triggered when a mesh is created
  39757. */
  39758. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39759. /**
  39760. * An event triggered when a mesh is removed
  39761. */
  39762. onMeshRemovedObservable: Observable<AbstractMesh>;
  39763. /**
  39764. * An event triggered when a skeleton is created
  39765. */
  39766. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39767. /**
  39768. * An event triggered when a skeleton is removed
  39769. */
  39770. onSkeletonRemovedObservable: Observable<Skeleton>;
  39771. /**
  39772. * An event triggered when a material is created
  39773. */
  39774. onNewMaterialAddedObservable: Observable<Material>;
  39775. /**
  39776. * An event triggered when a material is removed
  39777. */
  39778. onMaterialRemovedObservable: Observable<Material>;
  39779. /**
  39780. * An event triggered when a texture is created
  39781. */
  39782. onNewTextureAddedObservable: Observable<BaseTexture>;
  39783. /**
  39784. * An event triggered when a texture is removed
  39785. */
  39786. onTextureRemovedObservable: Observable<BaseTexture>;
  39787. /**
  39788. * An event triggered when render targets are about to be rendered
  39789. * Can happen multiple times per frame.
  39790. */
  39791. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39792. /**
  39793. * An event triggered when render targets were rendered.
  39794. * Can happen multiple times per frame.
  39795. */
  39796. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39797. /**
  39798. * An event triggered before calculating deterministic simulation step
  39799. */
  39800. onBeforeStepObservable: Observable<Scene>;
  39801. /**
  39802. * An event triggered after calculating deterministic simulation step
  39803. */
  39804. onAfterStepObservable: Observable<Scene>;
  39805. /**
  39806. * An event triggered when the activeCamera property is updated
  39807. */
  39808. onActiveCameraChanged: Observable<Scene>;
  39809. /**
  39810. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39811. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39812. * 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)
  39813. */
  39814. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39815. /**
  39816. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39817. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39818. * 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)
  39819. */
  39820. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39821. /**
  39822. * This Observable will when a mesh has been imported into the scene.
  39823. */
  39824. onMeshImportedObservable: Observable<AbstractMesh>;
  39825. /**
  39826. * This Observable will when an animation file has been imported into the scene.
  39827. */
  39828. onAnimationFileImportedObservable: Observable<Scene>;
  39829. /**
  39830. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39831. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39832. */
  39833. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39834. /** @hidden */
  39835. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39836. /**
  39837. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39838. */
  39839. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39840. /**
  39841. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39842. */
  39843. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39844. /**
  39845. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39846. */
  39847. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39848. /** Callback called when a pointer move is detected */
  39849. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39850. /** Callback called when a pointer down is detected */
  39851. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39852. /** Callback called when a pointer up is detected */
  39853. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39854. /** Callback called when a pointer pick is detected */
  39855. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39856. /**
  39857. * 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).
  39858. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39859. */
  39860. onPrePointerObservable: Observable<PointerInfoPre>;
  39861. /**
  39862. * Observable event triggered each time an input event is received from the rendering canvas
  39863. */
  39864. onPointerObservable: Observable<PointerInfo>;
  39865. /**
  39866. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39867. */
  39868. get unTranslatedPointer(): Vector2;
  39869. /**
  39870. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39871. */
  39872. static get DragMovementThreshold(): number;
  39873. static set DragMovementThreshold(value: number);
  39874. /**
  39875. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39876. */
  39877. static get LongPressDelay(): number;
  39878. static set LongPressDelay(value: number);
  39879. /**
  39880. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39881. */
  39882. static get DoubleClickDelay(): number;
  39883. static set DoubleClickDelay(value: number);
  39884. /** If you need to check double click without raising a single click at first click, enable this flag */
  39885. static get ExclusiveDoubleClickMode(): boolean;
  39886. static set ExclusiveDoubleClickMode(value: boolean);
  39887. /** @hidden */
  39888. _mirroredCameraPosition: Nullable<Vector3>;
  39889. /**
  39890. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39891. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39892. */
  39893. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39894. /**
  39895. * Observable event triggered each time an keyboard event is received from the hosting window
  39896. */
  39897. onKeyboardObservable: Observable<KeyboardInfo>;
  39898. private _useRightHandedSystem;
  39899. /**
  39900. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39901. */
  39902. set useRightHandedSystem(value: boolean);
  39903. get useRightHandedSystem(): boolean;
  39904. private _timeAccumulator;
  39905. private _currentStepId;
  39906. private _currentInternalStep;
  39907. /**
  39908. * Sets the step Id used by deterministic lock step
  39909. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39910. * @param newStepId defines the step Id
  39911. */
  39912. setStepId(newStepId: number): void;
  39913. /**
  39914. * Gets the step Id used by deterministic lock step
  39915. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39916. * @returns the step Id
  39917. */
  39918. getStepId(): number;
  39919. /**
  39920. * Gets the internal step used by deterministic lock step
  39921. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39922. * @returns the internal step
  39923. */
  39924. getInternalStep(): number;
  39925. private _fogEnabled;
  39926. /**
  39927. * Gets or sets a boolean indicating if fog is enabled on this scene
  39928. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39929. * (Default is true)
  39930. */
  39931. set fogEnabled(value: boolean);
  39932. get fogEnabled(): boolean;
  39933. private _fogMode;
  39934. /**
  39935. * Gets or sets the fog mode to use
  39936. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39937. * | mode | value |
  39938. * | --- | --- |
  39939. * | FOGMODE_NONE | 0 |
  39940. * | FOGMODE_EXP | 1 |
  39941. * | FOGMODE_EXP2 | 2 |
  39942. * | FOGMODE_LINEAR | 3 |
  39943. */
  39944. set fogMode(value: number);
  39945. get fogMode(): number;
  39946. /**
  39947. * Gets or sets the fog color to use
  39948. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39949. * (Default is Color3(0.2, 0.2, 0.3))
  39950. */
  39951. fogColor: Color3;
  39952. /**
  39953. * Gets or sets the fog density to use
  39954. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39955. * (Default is 0.1)
  39956. */
  39957. fogDensity: number;
  39958. /**
  39959. * Gets or sets the fog start distance to use
  39960. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39961. * (Default is 0)
  39962. */
  39963. fogStart: number;
  39964. /**
  39965. * Gets or sets the fog end distance to use
  39966. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39967. * (Default is 1000)
  39968. */
  39969. fogEnd: number;
  39970. /**
  39971. * Flag indicating that the frame buffer binding is handled by another component
  39972. */
  39973. prePass: boolean;
  39974. private _shadowsEnabled;
  39975. /**
  39976. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39977. */
  39978. set shadowsEnabled(value: boolean);
  39979. get shadowsEnabled(): boolean;
  39980. private _lightsEnabled;
  39981. /**
  39982. * Gets or sets a boolean indicating if lights are enabled on this scene
  39983. */
  39984. set lightsEnabled(value: boolean);
  39985. get lightsEnabled(): boolean;
  39986. /** All of the active cameras added to this scene. */
  39987. activeCameras: Camera[];
  39988. /** @hidden */
  39989. _activeCamera: Nullable<Camera>;
  39990. /** Gets or sets the current active camera */
  39991. get activeCamera(): Nullable<Camera>;
  39992. set activeCamera(value: Nullable<Camera>);
  39993. private _defaultMaterial;
  39994. /** The default material used on meshes when no material is affected */
  39995. get defaultMaterial(): Material;
  39996. /** The default material used on meshes when no material is affected */
  39997. set defaultMaterial(value: Material);
  39998. private _texturesEnabled;
  39999. /**
  40000. * Gets or sets a boolean indicating if textures are enabled on this scene
  40001. */
  40002. set texturesEnabled(value: boolean);
  40003. get texturesEnabled(): boolean;
  40004. /**
  40005. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  40006. */
  40007. physicsEnabled: boolean;
  40008. /**
  40009. * Gets or sets a boolean indicating if particles are enabled on this scene
  40010. */
  40011. particlesEnabled: boolean;
  40012. /**
  40013. * Gets or sets a boolean indicating if sprites are enabled on this scene
  40014. */
  40015. spritesEnabled: boolean;
  40016. private _skeletonsEnabled;
  40017. /**
  40018. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  40019. */
  40020. set skeletonsEnabled(value: boolean);
  40021. get skeletonsEnabled(): boolean;
  40022. /**
  40023. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  40024. */
  40025. lensFlaresEnabled: boolean;
  40026. /**
  40027. * Gets or sets a boolean indicating if collisions are enabled on this scene
  40028. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40029. */
  40030. collisionsEnabled: boolean;
  40031. private _collisionCoordinator;
  40032. /** @hidden */
  40033. get collisionCoordinator(): ICollisionCoordinator;
  40034. /**
  40035. * Defines the gravity applied to this scene (used only for collisions)
  40036. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40037. */
  40038. gravity: Vector3;
  40039. /**
  40040. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  40041. */
  40042. postProcessesEnabled: boolean;
  40043. /**
  40044. * Gets the current postprocess manager
  40045. */
  40046. postProcessManager: PostProcessManager;
  40047. /**
  40048. * Gets or sets a boolean indicating if render targets are enabled on this scene
  40049. */
  40050. renderTargetsEnabled: boolean;
  40051. /**
  40052. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  40053. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  40054. */
  40055. dumpNextRenderTargets: boolean;
  40056. /**
  40057. * The list of user defined render targets added to the scene
  40058. */
  40059. customRenderTargets: RenderTargetTexture[];
  40060. /**
  40061. * Defines if texture loading must be delayed
  40062. * If true, textures will only be loaded when they need to be rendered
  40063. */
  40064. useDelayedTextureLoading: boolean;
  40065. /**
  40066. * Gets the list of meshes imported to the scene through SceneLoader
  40067. */
  40068. importedMeshesFiles: String[];
  40069. /**
  40070. * Gets or sets a boolean indicating if probes are enabled on this scene
  40071. */
  40072. probesEnabled: boolean;
  40073. /**
  40074. * Gets or sets the current offline provider to use to store scene data
  40075. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  40076. */
  40077. offlineProvider: IOfflineProvider;
  40078. /**
  40079. * Gets or sets the action manager associated with the scene
  40080. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  40081. */
  40082. actionManager: AbstractActionManager;
  40083. private _meshesForIntersections;
  40084. /**
  40085. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  40086. */
  40087. proceduralTexturesEnabled: boolean;
  40088. private _engine;
  40089. private _totalVertices;
  40090. /** @hidden */
  40091. _activeIndices: PerfCounter;
  40092. /** @hidden */
  40093. _activeParticles: PerfCounter;
  40094. /** @hidden */
  40095. _activeBones: PerfCounter;
  40096. private _animationRatio;
  40097. /** @hidden */
  40098. _animationTimeLast: number;
  40099. /** @hidden */
  40100. _animationTime: number;
  40101. /**
  40102. * Gets or sets a general scale for animation speed
  40103. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  40104. */
  40105. animationTimeScale: number;
  40106. /** @hidden */
  40107. _cachedMaterial: Nullable<Material>;
  40108. /** @hidden */
  40109. _cachedEffect: Nullable<Effect>;
  40110. /** @hidden */
  40111. _cachedVisibility: Nullable<number>;
  40112. private _renderId;
  40113. private _frameId;
  40114. private _executeWhenReadyTimeoutId;
  40115. private _intermediateRendering;
  40116. private _viewUpdateFlag;
  40117. private _projectionUpdateFlag;
  40118. /** @hidden */
  40119. _toBeDisposed: Nullable<IDisposable>[];
  40120. private _activeRequests;
  40121. /** @hidden */
  40122. _pendingData: any[];
  40123. private _isDisposed;
  40124. /**
  40125. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40126. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40127. */
  40128. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40129. private _activeMeshes;
  40130. private _processedMaterials;
  40131. private _renderTargets;
  40132. /** @hidden */
  40133. _activeParticleSystems: SmartArray<IParticleSystem>;
  40134. private _activeSkeletons;
  40135. private _softwareSkinnedMeshes;
  40136. private _renderingManager;
  40137. /** @hidden */
  40138. _activeAnimatables: Animatable[];
  40139. private _transformMatrix;
  40140. private _sceneUbo;
  40141. /** @hidden */
  40142. _viewMatrix: Matrix;
  40143. private _projectionMatrix;
  40144. /** @hidden */
  40145. _forcedViewPosition: Nullable<Vector3>;
  40146. /** @hidden */
  40147. _frustumPlanes: Plane[];
  40148. /**
  40149. * Gets the list of frustum planes (built from the active camera)
  40150. */
  40151. get frustumPlanes(): Plane[];
  40152. /**
  40153. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40154. * This is useful if there are more lights that the maximum simulteanous authorized
  40155. */
  40156. requireLightSorting: boolean;
  40157. /** @hidden */
  40158. readonly useMaterialMeshMap: boolean;
  40159. /** @hidden */
  40160. readonly useClonedMeshMap: boolean;
  40161. private _externalData;
  40162. private _uid;
  40163. /**
  40164. * @hidden
  40165. * Backing store of defined scene components.
  40166. */
  40167. _components: ISceneComponent[];
  40168. /**
  40169. * @hidden
  40170. * Backing store of defined scene components.
  40171. */
  40172. _serializableComponents: ISceneSerializableComponent[];
  40173. /**
  40174. * List of components to register on the next registration step.
  40175. */
  40176. private _transientComponents;
  40177. /**
  40178. * Registers the transient components if needed.
  40179. */
  40180. private _registerTransientComponents;
  40181. /**
  40182. * @hidden
  40183. * Add a component to the scene.
  40184. * Note that the ccomponent could be registered on th next frame if this is called after
  40185. * the register component stage.
  40186. * @param component Defines the component to add to the scene
  40187. */
  40188. _addComponent(component: ISceneComponent): void;
  40189. /**
  40190. * @hidden
  40191. * Gets a component from the scene.
  40192. * @param name defines the name of the component to retrieve
  40193. * @returns the component or null if not present
  40194. */
  40195. _getComponent(name: string): Nullable<ISceneComponent>;
  40196. /**
  40197. * @hidden
  40198. * Defines the actions happening before camera updates.
  40199. */
  40200. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40201. /**
  40202. * @hidden
  40203. * Defines the actions happening before clear the canvas.
  40204. */
  40205. _beforeClearStage: Stage<SimpleStageAction>;
  40206. /**
  40207. * @hidden
  40208. * Defines the actions when collecting render targets for the frame.
  40209. */
  40210. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40211. /**
  40212. * @hidden
  40213. * Defines the actions happening for one camera in the frame.
  40214. */
  40215. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40216. /**
  40217. * @hidden
  40218. * Defines the actions happening during the per mesh ready checks.
  40219. */
  40220. _isReadyForMeshStage: Stage<MeshStageAction>;
  40221. /**
  40222. * @hidden
  40223. * Defines the actions happening before evaluate active mesh checks.
  40224. */
  40225. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40226. /**
  40227. * @hidden
  40228. * Defines the actions happening during the evaluate sub mesh checks.
  40229. */
  40230. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40231. /**
  40232. * @hidden
  40233. * Defines the actions happening during the active mesh stage.
  40234. */
  40235. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40236. /**
  40237. * @hidden
  40238. * Defines the actions happening during the per camera render target step.
  40239. */
  40240. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40241. /**
  40242. * @hidden
  40243. * Defines the actions happening just before the active camera is drawing.
  40244. */
  40245. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40246. /**
  40247. * @hidden
  40248. * Defines the actions happening just before a render target is drawing.
  40249. */
  40250. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40251. /**
  40252. * @hidden
  40253. * Defines the actions happening just before a rendering group is drawing.
  40254. */
  40255. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40256. /**
  40257. * @hidden
  40258. * Defines the actions happening just before a mesh is drawing.
  40259. */
  40260. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40261. /**
  40262. * @hidden
  40263. * Defines the actions happening just after a mesh has been drawn.
  40264. */
  40265. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40266. /**
  40267. * @hidden
  40268. * Defines the actions happening just after a rendering group has been drawn.
  40269. */
  40270. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40271. /**
  40272. * @hidden
  40273. * Defines the actions happening just after the active camera has been drawn.
  40274. */
  40275. _afterCameraDrawStage: Stage<CameraStageAction>;
  40276. /**
  40277. * @hidden
  40278. * Defines the actions happening just after a render target has been drawn.
  40279. */
  40280. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40281. /**
  40282. * @hidden
  40283. * Defines the actions happening just after rendering all cameras and computing intersections.
  40284. */
  40285. _afterRenderStage: Stage<SimpleStageAction>;
  40286. /**
  40287. * @hidden
  40288. * Defines the actions happening when a pointer move event happens.
  40289. */
  40290. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40291. /**
  40292. * @hidden
  40293. * Defines the actions happening when a pointer down event happens.
  40294. */
  40295. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40296. /**
  40297. * @hidden
  40298. * Defines the actions happening when a pointer up event happens.
  40299. */
  40300. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40301. /**
  40302. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40303. */
  40304. private geometriesByUniqueId;
  40305. /**
  40306. * Creates a new Scene
  40307. * @param engine defines the engine to use to render this scene
  40308. * @param options defines the scene options
  40309. */
  40310. constructor(engine: Engine, options?: SceneOptions);
  40311. /**
  40312. * Gets a string identifying the name of the class
  40313. * @returns "Scene" string
  40314. */
  40315. getClassName(): string;
  40316. private _defaultMeshCandidates;
  40317. /**
  40318. * @hidden
  40319. */
  40320. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40321. private _defaultSubMeshCandidates;
  40322. /**
  40323. * @hidden
  40324. */
  40325. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40326. /**
  40327. * Sets the default candidate providers for the scene.
  40328. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40329. * and getCollidingSubMeshCandidates to their default function
  40330. */
  40331. setDefaultCandidateProviders(): void;
  40332. /**
  40333. * Gets the mesh that is currently under the pointer
  40334. */
  40335. get meshUnderPointer(): Nullable<AbstractMesh>;
  40336. /**
  40337. * Gets or sets the current on-screen X position of the pointer
  40338. */
  40339. get pointerX(): number;
  40340. set pointerX(value: number);
  40341. /**
  40342. * Gets or sets the current on-screen Y position of the pointer
  40343. */
  40344. get pointerY(): number;
  40345. set pointerY(value: number);
  40346. /**
  40347. * Gets the cached material (ie. the latest rendered one)
  40348. * @returns the cached material
  40349. */
  40350. getCachedMaterial(): Nullable<Material>;
  40351. /**
  40352. * Gets the cached effect (ie. the latest rendered one)
  40353. * @returns the cached effect
  40354. */
  40355. getCachedEffect(): Nullable<Effect>;
  40356. /**
  40357. * Gets the cached visibility state (ie. the latest rendered one)
  40358. * @returns the cached visibility state
  40359. */
  40360. getCachedVisibility(): Nullable<number>;
  40361. /**
  40362. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40363. * @param material defines the current material
  40364. * @param effect defines the current effect
  40365. * @param visibility defines the current visibility state
  40366. * @returns true if one parameter is not cached
  40367. */
  40368. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40369. /**
  40370. * Gets the engine associated with the scene
  40371. * @returns an Engine
  40372. */
  40373. getEngine(): Engine;
  40374. /**
  40375. * Gets the total number of vertices rendered per frame
  40376. * @returns the total number of vertices rendered per frame
  40377. */
  40378. getTotalVertices(): number;
  40379. /**
  40380. * Gets the performance counter for total vertices
  40381. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40382. */
  40383. get totalVerticesPerfCounter(): PerfCounter;
  40384. /**
  40385. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40386. * @returns the total number of active indices rendered per frame
  40387. */
  40388. getActiveIndices(): number;
  40389. /**
  40390. * Gets the performance counter for active indices
  40391. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40392. */
  40393. get totalActiveIndicesPerfCounter(): PerfCounter;
  40394. /**
  40395. * Gets the total number of active particles rendered per frame
  40396. * @returns the total number of active particles rendered per frame
  40397. */
  40398. getActiveParticles(): number;
  40399. /**
  40400. * Gets the performance counter for active particles
  40401. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40402. */
  40403. get activeParticlesPerfCounter(): PerfCounter;
  40404. /**
  40405. * Gets the total number of active bones rendered per frame
  40406. * @returns the total number of active bones rendered per frame
  40407. */
  40408. getActiveBones(): number;
  40409. /**
  40410. * Gets the performance counter for active bones
  40411. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40412. */
  40413. get activeBonesPerfCounter(): PerfCounter;
  40414. /**
  40415. * Gets the array of active meshes
  40416. * @returns an array of AbstractMesh
  40417. */
  40418. getActiveMeshes(): SmartArray<AbstractMesh>;
  40419. /**
  40420. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40421. * @returns a number
  40422. */
  40423. getAnimationRatio(): number;
  40424. /**
  40425. * Gets an unique Id for the current render phase
  40426. * @returns a number
  40427. */
  40428. getRenderId(): number;
  40429. /**
  40430. * Gets an unique Id for the current frame
  40431. * @returns a number
  40432. */
  40433. getFrameId(): number;
  40434. /** Call this function if you want to manually increment the render Id*/
  40435. incrementRenderId(): void;
  40436. private _createUbo;
  40437. /**
  40438. * Use this method to simulate a pointer move on a mesh
  40439. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40440. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40441. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40442. * @returns the current scene
  40443. */
  40444. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40445. /**
  40446. * Use this method to simulate a pointer down on a mesh
  40447. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40448. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40449. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40450. * @returns the current scene
  40451. */
  40452. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40453. /**
  40454. * Use this method to simulate a pointer up on a mesh
  40455. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40456. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40457. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40458. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40459. * @returns the current scene
  40460. */
  40461. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40462. /**
  40463. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40464. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40465. * @returns true if the pointer was captured
  40466. */
  40467. isPointerCaptured(pointerId?: number): boolean;
  40468. /**
  40469. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40470. * @param attachUp defines if you want to attach events to pointerup
  40471. * @param attachDown defines if you want to attach events to pointerdown
  40472. * @param attachMove defines if you want to attach events to pointermove
  40473. */
  40474. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40475. /** Detaches all event handlers*/
  40476. detachControl(): void;
  40477. /**
  40478. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40479. * Delay loaded resources are not taking in account
  40480. * @return true if all required resources are ready
  40481. */
  40482. isReady(): boolean;
  40483. /** Resets all cached information relative to material (including effect and visibility) */
  40484. resetCachedMaterial(): void;
  40485. /**
  40486. * Registers a function to be called before every frame render
  40487. * @param func defines the function to register
  40488. */
  40489. registerBeforeRender(func: () => void): void;
  40490. /**
  40491. * Unregisters a function called before every frame render
  40492. * @param func defines the function to unregister
  40493. */
  40494. unregisterBeforeRender(func: () => void): void;
  40495. /**
  40496. * Registers a function to be called after every frame render
  40497. * @param func defines the function to register
  40498. */
  40499. registerAfterRender(func: () => void): void;
  40500. /**
  40501. * Unregisters a function called after every frame render
  40502. * @param func defines the function to unregister
  40503. */
  40504. unregisterAfterRender(func: () => void): void;
  40505. private _executeOnceBeforeRender;
  40506. /**
  40507. * The provided function will run before render once and will be disposed afterwards.
  40508. * A timeout delay can be provided so that the function will be executed in N ms.
  40509. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40510. * @param func The function to be executed.
  40511. * @param timeout optional delay in ms
  40512. */
  40513. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40514. /** @hidden */
  40515. _addPendingData(data: any): void;
  40516. /** @hidden */
  40517. _removePendingData(data: any): void;
  40518. /**
  40519. * Returns the number of items waiting to be loaded
  40520. * @returns the number of items waiting to be loaded
  40521. */
  40522. getWaitingItemsCount(): number;
  40523. /**
  40524. * Returns a boolean indicating if the scene is still loading data
  40525. */
  40526. get isLoading(): boolean;
  40527. /**
  40528. * Registers a function to be executed when the scene is ready
  40529. * @param {Function} func - the function to be executed
  40530. */
  40531. executeWhenReady(func: () => void): void;
  40532. /**
  40533. * Returns a promise that resolves when the scene is ready
  40534. * @returns A promise that resolves when the scene is ready
  40535. */
  40536. whenReadyAsync(): Promise<void>;
  40537. /** @hidden */
  40538. _checkIsReady(): void;
  40539. /**
  40540. * Gets all animatable attached to the scene
  40541. */
  40542. get animatables(): Animatable[];
  40543. /**
  40544. * Resets the last animation time frame.
  40545. * Useful to override when animations start running when loading a scene for the first time.
  40546. */
  40547. resetLastAnimationTimeFrame(): void;
  40548. /**
  40549. * Gets the current view matrix
  40550. * @returns a Matrix
  40551. */
  40552. getViewMatrix(): Matrix;
  40553. /**
  40554. * Gets the current projection matrix
  40555. * @returns a Matrix
  40556. */
  40557. getProjectionMatrix(): Matrix;
  40558. /**
  40559. * Gets the current transform matrix
  40560. * @returns a Matrix made of View * Projection
  40561. */
  40562. getTransformMatrix(): Matrix;
  40563. /**
  40564. * Sets the current transform matrix
  40565. * @param viewL defines the View matrix to use
  40566. * @param projectionL defines the Projection matrix to use
  40567. * @param viewR defines the right View matrix to use (if provided)
  40568. * @param projectionR defines the right Projection matrix to use (if provided)
  40569. */
  40570. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40571. /**
  40572. * Gets the uniform buffer used to store scene data
  40573. * @returns a UniformBuffer
  40574. */
  40575. getSceneUniformBuffer(): UniformBuffer;
  40576. /**
  40577. * Gets an unique (relatively to the current scene) Id
  40578. * @returns an unique number for the scene
  40579. */
  40580. getUniqueId(): number;
  40581. /**
  40582. * Add a mesh to the list of scene's meshes
  40583. * @param newMesh defines the mesh to add
  40584. * @param recursive if all child meshes should also be added to the scene
  40585. */
  40586. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40587. /**
  40588. * Remove a mesh for the list of scene's meshes
  40589. * @param toRemove defines the mesh to remove
  40590. * @param recursive if all child meshes should also be removed from the scene
  40591. * @returns the index where the mesh was in the mesh list
  40592. */
  40593. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40594. /**
  40595. * Add a transform node to the list of scene's transform nodes
  40596. * @param newTransformNode defines the transform node to add
  40597. */
  40598. addTransformNode(newTransformNode: TransformNode): void;
  40599. /**
  40600. * Remove a transform node for the list of scene's transform nodes
  40601. * @param toRemove defines the transform node to remove
  40602. * @returns the index where the transform node was in the transform node list
  40603. */
  40604. removeTransformNode(toRemove: TransformNode): number;
  40605. /**
  40606. * Remove a skeleton for the list of scene's skeletons
  40607. * @param toRemove defines the skeleton to remove
  40608. * @returns the index where the skeleton was in the skeleton list
  40609. */
  40610. removeSkeleton(toRemove: Skeleton): number;
  40611. /**
  40612. * Remove a morph target for the list of scene's morph targets
  40613. * @param toRemove defines the morph target to remove
  40614. * @returns the index where the morph target was in the morph target list
  40615. */
  40616. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40617. /**
  40618. * Remove a light for the list of scene's lights
  40619. * @param toRemove defines the light to remove
  40620. * @returns the index where the light was in the light list
  40621. */
  40622. removeLight(toRemove: Light): number;
  40623. /**
  40624. * Remove a camera for the list of scene's cameras
  40625. * @param toRemove defines the camera to remove
  40626. * @returns the index where the camera was in the camera list
  40627. */
  40628. removeCamera(toRemove: Camera): number;
  40629. /**
  40630. * Remove a particle system for the list of scene's particle systems
  40631. * @param toRemove defines the particle system to remove
  40632. * @returns the index where the particle system was in the particle system list
  40633. */
  40634. removeParticleSystem(toRemove: IParticleSystem): number;
  40635. /**
  40636. * Remove a animation for the list of scene's animations
  40637. * @param toRemove defines the animation to remove
  40638. * @returns the index where the animation was in the animation list
  40639. */
  40640. removeAnimation(toRemove: Animation): number;
  40641. /**
  40642. * Will stop the animation of the given target
  40643. * @param target - the target
  40644. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40645. * @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)
  40646. */
  40647. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40648. /**
  40649. * Removes the given animation group from this scene.
  40650. * @param toRemove The animation group to remove
  40651. * @returns The index of the removed animation group
  40652. */
  40653. removeAnimationGroup(toRemove: AnimationGroup): number;
  40654. /**
  40655. * Removes the given multi-material from this scene.
  40656. * @param toRemove The multi-material to remove
  40657. * @returns The index of the removed multi-material
  40658. */
  40659. removeMultiMaterial(toRemove: MultiMaterial): number;
  40660. /**
  40661. * Removes the given material from this scene.
  40662. * @param toRemove The material to remove
  40663. * @returns The index of the removed material
  40664. */
  40665. removeMaterial(toRemove: Material): number;
  40666. /**
  40667. * Removes the given action manager from this scene.
  40668. * @param toRemove The action manager to remove
  40669. * @returns The index of the removed action manager
  40670. */
  40671. removeActionManager(toRemove: AbstractActionManager): number;
  40672. /**
  40673. * Removes the given texture from this scene.
  40674. * @param toRemove The texture to remove
  40675. * @returns The index of the removed texture
  40676. */
  40677. removeTexture(toRemove: BaseTexture): number;
  40678. /**
  40679. * Adds the given light to this scene
  40680. * @param newLight The light to add
  40681. */
  40682. addLight(newLight: Light): void;
  40683. /**
  40684. * Sorts the list list based on light priorities
  40685. */
  40686. sortLightsByPriority(): void;
  40687. /**
  40688. * Adds the given camera to this scene
  40689. * @param newCamera The camera to add
  40690. */
  40691. addCamera(newCamera: Camera): void;
  40692. /**
  40693. * Adds the given skeleton to this scene
  40694. * @param newSkeleton The skeleton to add
  40695. */
  40696. addSkeleton(newSkeleton: Skeleton): void;
  40697. /**
  40698. * Adds the given particle system to this scene
  40699. * @param newParticleSystem The particle system to add
  40700. */
  40701. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40702. /**
  40703. * Adds the given animation to this scene
  40704. * @param newAnimation The animation to add
  40705. */
  40706. addAnimation(newAnimation: Animation): void;
  40707. /**
  40708. * Adds the given animation group to this scene.
  40709. * @param newAnimationGroup The animation group to add
  40710. */
  40711. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40712. /**
  40713. * Adds the given multi-material to this scene
  40714. * @param newMultiMaterial The multi-material to add
  40715. */
  40716. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40717. /**
  40718. * Adds the given material to this scene
  40719. * @param newMaterial The material to add
  40720. */
  40721. addMaterial(newMaterial: Material): void;
  40722. /**
  40723. * Adds the given morph target to this scene
  40724. * @param newMorphTargetManager The morph target to add
  40725. */
  40726. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40727. /**
  40728. * Adds the given geometry to this scene
  40729. * @param newGeometry The geometry to add
  40730. */
  40731. addGeometry(newGeometry: Geometry): void;
  40732. /**
  40733. * Adds the given action manager to this scene
  40734. * @param newActionManager The action manager to add
  40735. */
  40736. addActionManager(newActionManager: AbstractActionManager): void;
  40737. /**
  40738. * Adds the given texture to this scene.
  40739. * @param newTexture The texture to add
  40740. */
  40741. addTexture(newTexture: BaseTexture): void;
  40742. /**
  40743. * Switch active camera
  40744. * @param newCamera defines the new active camera
  40745. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40746. */
  40747. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40748. /**
  40749. * sets the active camera of the scene using its ID
  40750. * @param id defines the camera's ID
  40751. * @return the new active camera or null if none found.
  40752. */
  40753. setActiveCameraByID(id: string): Nullable<Camera>;
  40754. /**
  40755. * sets the active camera of the scene using its name
  40756. * @param name defines the camera's name
  40757. * @returns the new active camera or null if none found.
  40758. */
  40759. setActiveCameraByName(name: string): Nullable<Camera>;
  40760. /**
  40761. * get an animation group using its name
  40762. * @param name defines the material's name
  40763. * @return the animation group or null if none found.
  40764. */
  40765. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40766. /**
  40767. * Get a material using its unique id
  40768. * @param uniqueId defines the material's unique id
  40769. * @return the material or null if none found.
  40770. */
  40771. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40772. /**
  40773. * get a material using its id
  40774. * @param id defines the material's ID
  40775. * @return the material or null if none found.
  40776. */
  40777. getMaterialByID(id: string): Nullable<Material>;
  40778. /**
  40779. * Gets a the last added material using a given id
  40780. * @param id defines the material's ID
  40781. * @return the last material with the given id or null if none found.
  40782. */
  40783. getLastMaterialByID(id: string): Nullable<Material>;
  40784. /**
  40785. * Gets a material using its name
  40786. * @param name defines the material's name
  40787. * @return the material or null if none found.
  40788. */
  40789. getMaterialByName(name: string): Nullable<Material>;
  40790. /**
  40791. * Get a texture using its unique id
  40792. * @param uniqueId defines the texture's unique id
  40793. * @return the texture or null if none found.
  40794. */
  40795. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40796. /**
  40797. * Gets a camera using its id
  40798. * @param id defines the id to look for
  40799. * @returns the camera or null if not found
  40800. */
  40801. getCameraByID(id: string): Nullable<Camera>;
  40802. /**
  40803. * Gets a camera using its unique id
  40804. * @param uniqueId defines the unique id to look for
  40805. * @returns the camera or null if not found
  40806. */
  40807. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40808. /**
  40809. * Gets a camera using its name
  40810. * @param name defines the camera's name
  40811. * @return the camera or null if none found.
  40812. */
  40813. getCameraByName(name: string): Nullable<Camera>;
  40814. /**
  40815. * Gets a bone using its id
  40816. * @param id defines the bone's id
  40817. * @return the bone or null if not found
  40818. */
  40819. getBoneByID(id: string): Nullable<Bone>;
  40820. /**
  40821. * Gets a bone using its id
  40822. * @param name defines the bone's name
  40823. * @return the bone or null if not found
  40824. */
  40825. getBoneByName(name: string): Nullable<Bone>;
  40826. /**
  40827. * Gets a light node using its name
  40828. * @param name defines the the light's name
  40829. * @return the light or null if none found.
  40830. */
  40831. getLightByName(name: string): Nullable<Light>;
  40832. /**
  40833. * Gets a light node using its id
  40834. * @param id defines the light's id
  40835. * @return the light or null if none found.
  40836. */
  40837. getLightByID(id: string): Nullable<Light>;
  40838. /**
  40839. * Gets a light node using its scene-generated unique ID
  40840. * @param uniqueId defines the light's unique id
  40841. * @return the light or null if none found.
  40842. */
  40843. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40844. /**
  40845. * Gets a particle system by id
  40846. * @param id defines the particle system id
  40847. * @return the corresponding system or null if none found
  40848. */
  40849. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40850. /**
  40851. * Gets a geometry using its ID
  40852. * @param id defines the geometry's id
  40853. * @return the geometry or null if none found.
  40854. */
  40855. getGeometryByID(id: string): Nullable<Geometry>;
  40856. private _getGeometryByUniqueID;
  40857. /**
  40858. * Add a new geometry to this scene
  40859. * @param geometry defines the geometry to be added to the scene.
  40860. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40861. * @return a boolean defining if the geometry was added or not
  40862. */
  40863. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40864. /**
  40865. * Removes an existing geometry
  40866. * @param geometry defines the geometry to be removed from the scene
  40867. * @return a boolean defining if the geometry was removed or not
  40868. */
  40869. removeGeometry(geometry: Geometry): boolean;
  40870. /**
  40871. * Gets the list of geometries attached to the scene
  40872. * @returns an array of Geometry
  40873. */
  40874. getGeometries(): Geometry[];
  40875. /**
  40876. * Gets the first added mesh found of a given ID
  40877. * @param id defines the id to search for
  40878. * @return the mesh found or null if not found at all
  40879. */
  40880. getMeshByID(id: string): Nullable<AbstractMesh>;
  40881. /**
  40882. * Gets a list of meshes using their id
  40883. * @param id defines the id to search for
  40884. * @returns a list of meshes
  40885. */
  40886. getMeshesByID(id: string): Array<AbstractMesh>;
  40887. /**
  40888. * Gets the first added transform node found of a given ID
  40889. * @param id defines the id to search for
  40890. * @return the found transform node or null if not found at all.
  40891. */
  40892. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40893. /**
  40894. * Gets a transform node with its auto-generated unique id
  40895. * @param uniqueId efines the unique id to search for
  40896. * @return the found transform node or null if not found at all.
  40897. */
  40898. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40899. /**
  40900. * Gets a list of transform nodes using their id
  40901. * @param id defines the id to search for
  40902. * @returns a list of transform nodes
  40903. */
  40904. getTransformNodesByID(id: string): Array<TransformNode>;
  40905. /**
  40906. * Gets a mesh with its auto-generated unique id
  40907. * @param uniqueId defines the unique id to search for
  40908. * @return the found mesh or null if not found at all.
  40909. */
  40910. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40911. /**
  40912. * Gets a the last added mesh using a given id
  40913. * @param id defines the id to search for
  40914. * @return the found mesh or null if not found at all.
  40915. */
  40916. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40917. /**
  40918. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40919. * @param id defines the id to search for
  40920. * @return the found node or null if not found at all
  40921. */
  40922. getLastEntryByID(id: string): Nullable<Node>;
  40923. /**
  40924. * Gets a node (Mesh, Camera, Light) using a given id
  40925. * @param id defines the id to search for
  40926. * @return the found node or null if not found at all
  40927. */
  40928. getNodeByID(id: string): Nullable<Node>;
  40929. /**
  40930. * Gets a node (Mesh, Camera, Light) using a given name
  40931. * @param name defines the name to search for
  40932. * @return the found node or null if not found at all.
  40933. */
  40934. getNodeByName(name: string): Nullable<Node>;
  40935. /**
  40936. * Gets a mesh using a given name
  40937. * @param name defines the name to search for
  40938. * @return the found mesh or null if not found at all.
  40939. */
  40940. getMeshByName(name: string): Nullable<AbstractMesh>;
  40941. /**
  40942. * Gets a transform node using a given name
  40943. * @param name defines the name to search for
  40944. * @return the found transform node or null if not found at all.
  40945. */
  40946. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40947. /**
  40948. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40949. * @param id defines the id to search for
  40950. * @return the found skeleton or null if not found at all.
  40951. */
  40952. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40953. /**
  40954. * Gets a skeleton using a given auto generated unique id
  40955. * @param uniqueId defines the unique id to search for
  40956. * @return the found skeleton or null if not found at all.
  40957. */
  40958. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40959. /**
  40960. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40961. * @param id defines the id to search for
  40962. * @return the found skeleton or null if not found at all.
  40963. */
  40964. getSkeletonById(id: string): Nullable<Skeleton>;
  40965. /**
  40966. * Gets a skeleton using a given name
  40967. * @param name defines the name to search for
  40968. * @return the found skeleton or null if not found at all.
  40969. */
  40970. getSkeletonByName(name: string): Nullable<Skeleton>;
  40971. /**
  40972. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40973. * @param id defines the id to search for
  40974. * @return the found morph target manager or null if not found at all.
  40975. */
  40976. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40977. /**
  40978. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40979. * @param id defines the id to search for
  40980. * @return the found morph target or null if not found at all.
  40981. */
  40982. getMorphTargetById(id: string): Nullable<MorphTarget>;
  40983. /**
  40984. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  40985. * @param name defines the name to search for
  40986. * @return the found morph target or null if not found at all.
  40987. */
  40988. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  40989. /**
  40990. * Gets a post process using a given name (if many are found, this function will pick the first one)
  40991. * @param name defines the name to search for
  40992. * @return the found post process or null if not found at all.
  40993. */
  40994. getPostProcessByName(name: string): Nullable<PostProcess>;
  40995. /**
  40996. * Gets a boolean indicating if the given mesh is active
  40997. * @param mesh defines the mesh to look for
  40998. * @returns true if the mesh is in the active list
  40999. */
  41000. isActiveMesh(mesh: AbstractMesh): boolean;
  41001. /**
  41002. * Return a unique id as a string which can serve as an identifier for the scene
  41003. */
  41004. get uid(): string;
  41005. /**
  41006. * Add an externaly attached data from its key.
  41007. * This method call will fail and return false, if such key already exists.
  41008. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  41009. * @param key the unique key that identifies the data
  41010. * @param data the data object to associate to the key for this Engine instance
  41011. * @return true if no such key were already present and the data was added successfully, false otherwise
  41012. */
  41013. addExternalData<T>(key: string, data: T): boolean;
  41014. /**
  41015. * Get an externaly attached data from its key
  41016. * @param key the unique key that identifies the data
  41017. * @return the associated data, if present (can be null), or undefined if not present
  41018. */
  41019. getExternalData<T>(key: string): Nullable<T>;
  41020. /**
  41021. * Get an externaly attached data from its key, create it using a factory if it's not already present
  41022. * @param key the unique key that identifies the data
  41023. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  41024. * @return the associated data, can be null if the factory returned null.
  41025. */
  41026. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  41027. /**
  41028. * Remove an externaly attached data from the Engine instance
  41029. * @param key the unique key that identifies the data
  41030. * @return true if the data was successfully removed, false if it doesn't exist
  41031. */
  41032. removeExternalData(key: string): boolean;
  41033. private _evaluateSubMesh;
  41034. /**
  41035. * Clear the processed materials smart array preventing retention point in material dispose.
  41036. */
  41037. freeProcessedMaterials(): void;
  41038. private _preventFreeActiveMeshesAndRenderingGroups;
  41039. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  41040. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  41041. * when disposing several meshes in a row or a hierarchy of meshes.
  41042. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  41043. */
  41044. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  41045. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  41046. /**
  41047. * Clear the active meshes smart array preventing retention point in mesh dispose.
  41048. */
  41049. freeActiveMeshes(): void;
  41050. /**
  41051. * Clear the info related to rendering groups preventing retention points during dispose.
  41052. */
  41053. freeRenderingGroups(): void;
  41054. /** @hidden */
  41055. _isInIntermediateRendering(): boolean;
  41056. /**
  41057. * Lambda returning the list of potentially active meshes.
  41058. */
  41059. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  41060. /**
  41061. * Lambda returning the list of potentially active sub meshes.
  41062. */
  41063. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  41064. /**
  41065. * Lambda returning the list of potentially intersecting sub meshes.
  41066. */
  41067. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  41068. /**
  41069. * Lambda returning the list of potentially colliding sub meshes.
  41070. */
  41071. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  41072. private _activeMeshesFrozen;
  41073. private _skipEvaluateActiveMeshesCompletely;
  41074. /**
  41075. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  41076. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  41077. * @returns the current scene
  41078. */
  41079. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  41080. /**
  41081. * Use this function to restart evaluating active meshes on every frame
  41082. * @returns the current scene
  41083. */
  41084. unfreezeActiveMeshes(): Scene;
  41085. private _evaluateActiveMeshes;
  41086. private _activeMesh;
  41087. /**
  41088. * Update the transform matrix to update from the current active camera
  41089. * @param force defines a boolean used to force the update even if cache is up to date
  41090. */
  41091. updateTransformMatrix(force?: boolean): void;
  41092. private _bindFrameBuffer;
  41093. /** @hidden */
  41094. _allowPostProcessClearColor: boolean;
  41095. /** @hidden */
  41096. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  41097. private _processSubCameras;
  41098. private _checkIntersections;
  41099. /** @hidden */
  41100. _advancePhysicsEngineStep(step: number): void;
  41101. /**
  41102. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  41103. */
  41104. getDeterministicFrameTime: () => number;
  41105. /** @hidden */
  41106. _animate(): void;
  41107. /** Execute all animations (for a frame) */
  41108. animate(): void;
  41109. /**
  41110. * Render the scene
  41111. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  41112. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  41113. */
  41114. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  41115. /**
  41116. * Freeze all materials
  41117. * A frozen material will not be updatable but should be faster to render
  41118. */
  41119. freezeMaterials(): void;
  41120. /**
  41121. * Unfreeze all materials
  41122. * A frozen material will not be updatable but should be faster to render
  41123. */
  41124. unfreezeMaterials(): void;
  41125. /**
  41126. * Releases all held ressources
  41127. */
  41128. dispose(): void;
  41129. /**
  41130. * Gets if the scene is already disposed
  41131. */
  41132. get isDisposed(): boolean;
  41133. /**
  41134. * Call this function to reduce memory footprint of the scene.
  41135. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41136. */
  41137. clearCachedVertexData(): void;
  41138. /**
  41139. * This function will remove the local cached buffer data from texture.
  41140. * It will save memory but will prevent the texture from being rebuilt
  41141. */
  41142. cleanCachedTextureBuffer(): void;
  41143. /**
  41144. * Get the world extend vectors with an optional filter
  41145. *
  41146. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41147. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41148. */
  41149. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41150. min: Vector3;
  41151. max: Vector3;
  41152. };
  41153. /**
  41154. * Creates a ray that can be used to pick in the scene
  41155. * @param x defines the x coordinate of the origin (on-screen)
  41156. * @param y defines the y coordinate of the origin (on-screen)
  41157. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41158. * @param camera defines the camera to use for the picking
  41159. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41160. * @returns a Ray
  41161. */
  41162. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41163. /**
  41164. * Creates a ray that can be used to pick in the scene
  41165. * @param x defines the x coordinate of the origin (on-screen)
  41166. * @param y defines the y coordinate of the origin (on-screen)
  41167. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41168. * @param result defines the ray where to store the picking ray
  41169. * @param camera defines the camera to use for the picking
  41170. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41171. * @returns the current scene
  41172. */
  41173. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41174. /**
  41175. * Creates a ray that can be used to pick in the scene
  41176. * @param x defines the x coordinate of the origin (on-screen)
  41177. * @param y defines the y coordinate of the origin (on-screen)
  41178. * @param camera defines the camera to use for the picking
  41179. * @returns a Ray
  41180. */
  41181. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41182. /**
  41183. * Creates a ray that can be used to pick in the scene
  41184. * @param x defines the x coordinate of the origin (on-screen)
  41185. * @param y defines the y coordinate of the origin (on-screen)
  41186. * @param result defines the ray where to store the picking ray
  41187. * @param camera defines the camera to use for the picking
  41188. * @returns the current scene
  41189. */
  41190. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41191. /** Launch a ray to try to pick a mesh in the scene
  41192. * @param x position on screen
  41193. * @param y position on screen
  41194. * @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
  41195. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41196. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41197. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41198. * @returns a PickingInfo
  41199. */
  41200. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41201. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41202. * @param x position on screen
  41203. * @param y position on screen
  41204. * @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
  41205. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41206. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41207. * @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)
  41208. */
  41209. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41210. /** Use the given ray to pick a mesh in the scene
  41211. * @param ray The ray to use to pick meshes
  41212. * @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
  41213. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41214. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41215. * @returns a PickingInfo
  41216. */
  41217. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41218. /**
  41219. * Launch a ray to try to pick a mesh in the scene
  41220. * @param x X position on screen
  41221. * @param y Y position on screen
  41222. * @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
  41223. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41224. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41225. * @returns an array of PickingInfo
  41226. */
  41227. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41228. /**
  41229. * Launch a ray to try to pick a mesh in the scene
  41230. * @param ray Ray to use
  41231. * @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
  41232. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41233. * @returns an array of PickingInfo
  41234. */
  41235. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41236. /**
  41237. * Force the value of meshUnderPointer
  41238. * @param mesh defines the mesh to use
  41239. * @param pointerId optional pointer id when using more than one pointer
  41240. */
  41241. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  41242. /**
  41243. * Gets the mesh under the pointer
  41244. * @returns a Mesh or null if no mesh is under the pointer
  41245. */
  41246. getPointerOverMesh(): Nullable<AbstractMesh>;
  41247. /** @hidden */
  41248. _rebuildGeometries(): void;
  41249. /** @hidden */
  41250. _rebuildTextures(): void;
  41251. private _getByTags;
  41252. /**
  41253. * Get a list of meshes by tags
  41254. * @param tagsQuery defines the tags query to use
  41255. * @param forEach defines a predicate used to filter results
  41256. * @returns an array of Mesh
  41257. */
  41258. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41259. /**
  41260. * Get a list of cameras by tags
  41261. * @param tagsQuery defines the tags query to use
  41262. * @param forEach defines a predicate used to filter results
  41263. * @returns an array of Camera
  41264. */
  41265. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41266. /**
  41267. * Get a list of lights by tags
  41268. * @param tagsQuery defines the tags query to use
  41269. * @param forEach defines a predicate used to filter results
  41270. * @returns an array of Light
  41271. */
  41272. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41273. /**
  41274. * Get a list of materials by tags
  41275. * @param tagsQuery defines the tags query to use
  41276. * @param forEach defines a predicate used to filter results
  41277. * @returns an array of Material
  41278. */
  41279. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41280. /**
  41281. * Get a list of transform nodes by tags
  41282. * @param tagsQuery defines the tags query to use
  41283. * @param forEach defines a predicate used to filter results
  41284. * @returns an array of TransformNode
  41285. */
  41286. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  41287. /**
  41288. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41289. * This allowed control for front to back rendering or reversly depending of the special needs.
  41290. *
  41291. * @param renderingGroupId The rendering group id corresponding to its index
  41292. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41293. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41294. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41295. */
  41296. 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;
  41297. /**
  41298. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41299. *
  41300. * @param renderingGroupId The rendering group id corresponding to its index
  41301. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41302. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41303. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41304. */
  41305. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41306. /**
  41307. * Gets the current auto clear configuration for one rendering group of the rendering
  41308. * manager.
  41309. * @param index the rendering group index to get the information for
  41310. * @returns The auto clear setup for the requested rendering group
  41311. */
  41312. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41313. private _blockMaterialDirtyMechanism;
  41314. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41315. get blockMaterialDirtyMechanism(): boolean;
  41316. set blockMaterialDirtyMechanism(value: boolean);
  41317. /**
  41318. * Will flag all materials as dirty to trigger new shader compilation
  41319. * @param flag defines the flag used to specify which material part must be marked as dirty
  41320. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41321. */
  41322. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41323. /** @hidden */
  41324. _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;
  41325. /** @hidden */
  41326. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41327. /** @hidden */
  41328. _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;
  41329. /** @hidden */
  41330. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41331. /** @hidden */
  41332. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41333. /** @hidden */
  41334. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41335. }
  41336. }
  41337. declare module BABYLON {
  41338. /**
  41339. * Set of assets to keep when moving a scene into an asset container.
  41340. */
  41341. export class KeepAssets extends AbstractScene {
  41342. }
  41343. /**
  41344. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41345. */
  41346. export class InstantiatedEntries {
  41347. /**
  41348. * List of new root nodes (eg. nodes with no parent)
  41349. */
  41350. rootNodes: TransformNode[];
  41351. /**
  41352. * List of new skeletons
  41353. */
  41354. skeletons: Skeleton[];
  41355. /**
  41356. * List of new animation groups
  41357. */
  41358. animationGroups: AnimationGroup[];
  41359. }
  41360. /**
  41361. * Container with a set of assets that can be added or removed from a scene.
  41362. */
  41363. export class AssetContainer extends AbstractScene {
  41364. private _wasAddedToScene;
  41365. /**
  41366. * The scene the AssetContainer belongs to.
  41367. */
  41368. scene: Scene;
  41369. /**
  41370. * Instantiates an AssetContainer.
  41371. * @param scene The scene the AssetContainer belongs to.
  41372. */
  41373. constructor(scene: Scene);
  41374. /**
  41375. * Instantiate or clone all meshes and add the new ones to the scene.
  41376. * Skeletons and animation groups will all be cloned
  41377. * @param nameFunction defines an optional function used to get new names for clones
  41378. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41379. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41380. */
  41381. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41382. /**
  41383. * Adds all the assets from the container to the scene.
  41384. */
  41385. addAllToScene(): void;
  41386. /**
  41387. * Removes all the assets in the container from the scene
  41388. */
  41389. removeAllFromScene(): void;
  41390. /**
  41391. * Disposes all the assets in the container
  41392. */
  41393. dispose(): void;
  41394. private _moveAssets;
  41395. /**
  41396. * Removes all the assets contained in the scene and adds them to the container.
  41397. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41398. */
  41399. moveAllFromScene(keepAssets?: KeepAssets): void;
  41400. /**
  41401. * 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.
  41402. * @returns the root mesh
  41403. */
  41404. createRootMesh(): Mesh;
  41405. /**
  41406. * Merge animations (direct and animation groups) from this asset container into a scene
  41407. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41408. * @param animatables set of animatables to retarget to a node from the scene
  41409. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41410. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41411. */
  41412. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41413. }
  41414. }
  41415. declare module BABYLON {
  41416. /**
  41417. * Defines how the parser contract is defined.
  41418. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41419. */
  41420. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41421. /**
  41422. * Defines how the individual parser contract is defined.
  41423. * These parser can parse an individual asset
  41424. */
  41425. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41426. /**
  41427. * Base class of the scene acting as a container for the different elements composing a scene.
  41428. * This class is dynamically extended by the different components of the scene increasing
  41429. * flexibility and reducing coupling
  41430. */
  41431. export abstract class AbstractScene {
  41432. /**
  41433. * Stores the list of available parsers in the application.
  41434. */
  41435. private static _BabylonFileParsers;
  41436. /**
  41437. * Stores the list of available individual parsers in the application.
  41438. */
  41439. private static _IndividualBabylonFileParsers;
  41440. /**
  41441. * Adds a parser in the list of available ones
  41442. * @param name Defines the name of the parser
  41443. * @param parser Defines the parser to add
  41444. */
  41445. static AddParser(name: string, parser: BabylonFileParser): void;
  41446. /**
  41447. * Gets a general parser from the list of avaialble ones
  41448. * @param name Defines the name of the parser
  41449. * @returns the requested parser or null
  41450. */
  41451. static GetParser(name: string): Nullable<BabylonFileParser>;
  41452. /**
  41453. * Adds n individual parser in the list of available ones
  41454. * @param name Defines the name of the parser
  41455. * @param parser Defines the parser to add
  41456. */
  41457. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41458. /**
  41459. * Gets an individual parser from the list of avaialble ones
  41460. * @param name Defines the name of the parser
  41461. * @returns the requested parser or null
  41462. */
  41463. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41464. /**
  41465. * Parser json data and populate both a scene and its associated container object
  41466. * @param jsonData Defines the data to parse
  41467. * @param scene Defines the scene to parse the data for
  41468. * @param container Defines the container attached to the parsing sequence
  41469. * @param rootUrl Defines the root url of the data
  41470. */
  41471. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41472. /**
  41473. * Gets the list of root nodes (ie. nodes with no parent)
  41474. */
  41475. rootNodes: Node[];
  41476. /** All of the cameras added to this scene
  41477. * @see https://doc.babylonjs.com/babylon101/cameras
  41478. */
  41479. cameras: Camera[];
  41480. /**
  41481. * All of the lights added to this scene
  41482. * @see https://doc.babylonjs.com/babylon101/lights
  41483. */
  41484. lights: Light[];
  41485. /**
  41486. * All of the (abstract) meshes added to this scene
  41487. */
  41488. meshes: AbstractMesh[];
  41489. /**
  41490. * The list of skeletons added to the scene
  41491. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41492. */
  41493. skeletons: Skeleton[];
  41494. /**
  41495. * All of the particle systems added to this scene
  41496. * @see https://doc.babylonjs.com/babylon101/particles
  41497. */
  41498. particleSystems: IParticleSystem[];
  41499. /**
  41500. * Gets a list of Animations associated with the scene
  41501. */
  41502. animations: Animation[];
  41503. /**
  41504. * All of the animation groups added to this scene
  41505. * @see https://doc.babylonjs.com/how_to/group
  41506. */
  41507. animationGroups: AnimationGroup[];
  41508. /**
  41509. * All of the multi-materials added to this scene
  41510. * @see https://doc.babylonjs.com/how_to/multi_materials
  41511. */
  41512. multiMaterials: MultiMaterial[];
  41513. /**
  41514. * All of the materials added to this scene
  41515. * In the context of a Scene, it is not supposed to be modified manually.
  41516. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41517. * Note also that the order of the Material within the array is not significant and might change.
  41518. * @see https://doc.babylonjs.com/babylon101/materials
  41519. */
  41520. materials: Material[];
  41521. /**
  41522. * The list of morph target managers added to the scene
  41523. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41524. */
  41525. morphTargetManagers: MorphTargetManager[];
  41526. /**
  41527. * The list of geometries used in the scene.
  41528. */
  41529. geometries: Geometry[];
  41530. /**
  41531. * All of the tranform nodes added to this scene
  41532. * In the context of a Scene, it is not supposed to be modified manually.
  41533. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41534. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41535. * @see https://doc.babylonjs.com/how_to/transformnode
  41536. */
  41537. transformNodes: TransformNode[];
  41538. /**
  41539. * ActionManagers available on the scene.
  41540. */
  41541. actionManagers: AbstractActionManager[];
  41542. /**
  41543. * Textures to keep.
  41544. */
  41545. textures: BaseTexture[];
  41546. /** @hidden */
  41547. protected _environmentTexture: Nullable<BaseTexture>;
  41548. /**
  41549. * Texture used in all pbr material as the reflection texture.
  41550. * As in the majority of the scene they are the same (exception for multi room and so on),
  41551. * this is easier to reference from here than from all the materials.
  41552. */
  41553. get environmentTexture(): Nullable<BaseTexture>;
  41554. set environmentTexture(value: Nullable<BaseTexture>);
  41555. /**
  41556. * The list of postprocesses added to the scene
  41557. */
  41558. postProcesses: PostProcess[];
  41559. /**
  41560. * @returns all meshes, lights, cameras, transformNodes and bones
  41561. */
  41562. getNodes(): Array<Node>;
  41563. }
  41564. }
  41565. declare module BABYLON {
  41566. /**
  41567. * Interface used to define options for Sound class
  41568. */
  41569. export interface ISoundOptions {
  41570. /**
  41571. * Does the sound autoplay once loaded.
  41572. */
  41573. autoplay?: boolean;
  41574. /**
  41575. * Does the sound loop after it finishes playing once.
  41576. */
  41577. loop?: boolean;
  41578. /**
  41579. * Sound's volume
  41580. */
  41581. volume?: number;
  41582. /**
  41583. * Is it a spatial sound?
  41584. */
  41585. spatialSound?: boolean;
  41586. /**
  41587. * Maximum distance to hear that sound
  41588. */
  41589. maxDistance?: number;
  41590. /**
  41591. * Uses user defined attenuation function
  41592. */
  41593. useCustomAttenuation?: boolean;
  41594. /**
  41595. * Define the roll off factor of spatial sounds.
  41596. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41597. */
  41598. rolloffFactor?: number;
  41599. /**
  41600. * Define the reference distance the sound should be heard perfectly.
  41601. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41602. */
  41603. refDistance?: number;
  41604. /**
  41605. * Define the distance attenuation model the sound will follow.
  41606. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41607. */
  41608. distanceModel?: string;
  41609. /**
  41610. * Defines the playback speed (1 by default)
  41611. */
  41612. playbackRate?: number;
  41613. /**
  41614. * Defines if the sound is from a streaming source
  41615. */
  41616. streaming?: boolean;
  41617. /**
  41618. * Defines an optional length (in seconds) inside the sound file
  41619. */
  41620. length?: number;
  41621. /**
  41622. * Defines an optional offset (in seconds) inside the sound file
  41623. */
  41624. offset?: number;
  41625. /**
  41626. * If true, URLs will not be required to state the audio file codec to use.
  41627. */
  41628. skipCodecCheck?: boolean;
  41629. }
  41630. /**
  41631. * Defines a sound that can be played in the application.
  41632. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41633. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41634. */
  41635. export class Sound {
  41636. /**
  41637. * The name of the sound in the scene.
  41638. */
  41639. name: string;
  41640. /**
  41641. * Does the sound autoplay once loaded.
  41642. */
  41643. autoplay: boolean;
  41644. /**
  41645. * Does the sound loop after it finishes playing once.
  41646. */
  41647. loop: boolean;
  41648. /**
  41649. * Does the sound use a custom attenuation curve to simulate the falloff
  41650. * happening when the source gets further away from the camera.
  41651. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41652. */
  41653. useCustomAttenuation: boolean;
  41654. /**
  41655. * The sound track id this sound belongs to.
  41656. */
  41657. soundTrackId: number;
  41658. /**
  41659. * Is this sound currently played.
  41660. */
  41661. isPlaying: boolean;
  41662. /**
  41663. * Is this sound currently paused.
  41664. */
  41665. isPaused: boolean;
  41666. /**
  41667. * Does this sound enables spatial sound.
  41668. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41669. */
  41670. spatialSound: boolean;
  41671. /**
  41672. * Define the reference distance the sound should be heard perfectly.
  41673. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41674. */
  41675. refDistance: number;
  41676. /**
  41677. * Define the roll off factor of spatial sounds.
  41678. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41679. */
  41680. rolloffFactor: number;
  41681. /**
  41682. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41683. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41684. */
  41685. maxDistance: number;
  41686. /**
  41687. * Define the distance attenuation model the sound will follow.
  41688. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41689. */
  41690. distanceModel: string;
  41691. /**
  41692. * @hidden
  41693. * Back Compat
  41694. **/
  41695. onended: () => any;
  41696. /**
  41697. * Gets or sets an object used to store user defined information for the sound.
  41698. */
  41699. metadata: any;
  41700. /**
  41701. * Observable event when the current playing sound finishes.
  41702. */
  41703. onEndedObservable: Observable<Sound>;
  41704. private _panningModel;
  41705. private _playbackRate;
  41706. private _streaming;
  41707. private _startTime;
  41708. private _startOffset;
  41709. private _position;
  41710. /** @hidden */
  41711. _positionInEmitterSpace: boolean;
  41712. private _localDirection;
  41713. private _volume;
  41714. private _isReadyToPlay;
  41715. private _isDirectional;
  41716. private _readyToPlayCallback;
  41717. private _audioBuffer;
  41718. private _soundSource;
  41719. private _streamingSource;
  41720. private _soundPanner;
  41721. private _soundGain;
  41722. private _inputAudioNode;
  41723. private _outputAudioNode;
  41724. private _coneInnerAngle;
  41725. private _coneOuterAngle;
  41726. private _coneOuterGain;
  41727. private _scene;
  41728. private _connectedTransformNode;
  41729. private _customAttenuationFunction;
  41730. private _registerFunc;
  41731. private _isOutputConnected;
  41732. private _htmlAudioElement;
  41733. private _urlType;
  41734. private _length?;
  41735. private _offset?;
  41736. /** @hidden */
  41737. static _SceneComponentInitialization: (scene: Scene) => void;
  41738. /**
  41739. * Create a sound and attach it to a scene
  41740. * @param name Name of your sound
  41741. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41742. * @param scene defines the scene the sound belongs to
  41743. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41744. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41745. */
  41746. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41747. /**
  41748. * Release the sound and its associated resources
  41749. */
  41750. dispose(): void;
  41751. /**
  41752. * Gets if the sounds is ready to be played or not.
  41753. * @returns true if ready, otherwise false
  41754. */
  41755. isReady(): boolean;
  41756. private _soundLoaded;
  41757. /**
  41758. * Sets the data of the sound from an audiobuffer
  41759. * @param audioBuffer The audioBuffer containing the data
  41760. */
  41761. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41762. /**
  41763. * Updates the current sounds options such as maxdistance, loop...
  41764. * @param options A JSON object containing values named as the object properties
  41765. */
  41766. updateOptions(options: ISoundOptions): void;
  41767. private _createSpatialParameters;
  41768. private _updateSpatialParameters;
  41769. /**
  41770. * Switch the panning model to HRTF:
  41771. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41772. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41773. */
  41774. switchPanningModelToHRTF(): void;
  41775. /**
  41776. * Switch the panning model to Equal Power:
  41777. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41778. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41779. */
  41780. switchPanningModelToEqualPower(): void;
  41781. private _switchPanningModel;
  41782. /**
  41783. * Connect this sound to a sound track audio node like gain...
  41784. * @param soundTrackAudioNode the sound track audio node to connect to
  41785. */
  41786. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41787. /**
  41788. * Transform this sound into a directional source
  41789. * @param coneInnerAngle Size of the inner cone in degree
  41790. * @param coneOuterAngle Size of the outer cone in degree
  41791. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41792. */
  41793. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41794. /**
  41795. * Gets or sets the inner angle for the directional cone.
  41796. */
  41797. get directionalConeInnerAngle(): number;
  41798. /**
  41799. * Gets or sets the inner angle for the directional cone.
  41800. */
  41801. set directionalConeInnerAngle(value: number);
  41802. /**
  41803. * Gets or sets the outer angle for the directional cone.
  41804. */
  41805. get directionalConeOuterAngle(): number;
  41806. /**
  41807. * Gets or sets the outer angle for the directional cone.
  41808. */
  41809. set directionalConeOuterAngle(value: number);
  41810. /**
  41811. * Sets the position of the emitter if spatial sound is enabled
  41812. * @param newPosition Defines the new posisiton
  41813. */
  41814. setPosition(newPosition: Vector3): void;
  41815. /**
  41816. * Sets the local direction of the emitter if spatial sound is enabled
  41817. * @param newLocalDirection Defines the new local direction
  41818. */
  41819. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41820. private _updateDirection;
  41821. /** @hidden */
  41822. updateDistanceFromListener(): void;
  41823. /**
  41824. * Sets a new custom attenuation function for the sound.
  41825. * @param callback Defines the function used for the attenuation
  41826. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41827. */
  41828. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41829. /**
  41830. * Play the sound
  41831. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41832. * @param offset (optional) Start the sound at a specific time in seconds
  41833. * @param length (optional) Sound duration (in seconds)
  41834. */
  41835. play(time?: number, offset?: number, length?: number): void;
  41836. private _onended;
  41837. /**
  41838. * Stop the sound
  41839. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41840. */
  41841. stop(time?: number): void;
  41842. /**
  41843. * Put the sound in pause
  41844. */
  41845. pause(): void;
  41846. /**
  41847. * Sets a dedicated volume for this sounds
  41848. * @param newVolume Define the new volume of the sound
  41849. * @param time Define time for gradual change to new volume
  41850. */
  41851. setVolume(newVolume: number, time?: number): void;
  41852. /**
  41853. * Set the sound play back rate
  41854. * @param newPlaybackRate Define the playback rate the sound should be played at
  41855. */
  41856. setPlaybackRate(newPlaybackRate: number): void;
  41857. /**
  41858. * Gets the volume of the sound.
  41859. * @returns the volume of the sound
  41860. */
  41861. getVolume(): number;
  41862. /**
  41863. * Attach the sound to a dedicated mesh
  41864. * @param transformNode The transform node to connect the sound with
  41865. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41866. */
  41867. attachToMesh(transformNode: TransformNode): void;
  41868. /**
  41869. * Detach the sound from the previously attached mesh
  41870. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41871. */
  41872. detachFromMesh(): void;
  41873. private _onRegisterAfterWorldMatrixUpdate;
  41874. /**
  41875. * Clone the current sound in the scene.
  41876. * @returns the new sound clone
  41877. */
  41878. clone(): Nullable<Sound>;
  41879. /**
  41880. * Gets the current underlying audio buffer containing the data
  41881. * @returns the audio buffer
  41882. */
  41883. getAudioBuffer(): Nullable<AudioBuffer>;
  41884. /**
  41885. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41886. * @returns the source node
  41887. */
  41888. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41889. /**
  41890. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41891. * @returns the gain node
  41892. */
  41893. getSoundGain(): Nullable<GainNode>;
  41894. /**
  41895. * Serializes the Sound in a JSON representation
  41896. * @returns the JSON representation of the sound
  41897. */
  41898. serialize(): any;
  41899. /**
  41900. * Parse a JSON representation of a sound to innstantiate in a given scene
  41901. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41902. * @param scene Define the scene the new parsed sound should be created in
  41903. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41904. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41905. * @returns the newly parsed sound
  41906. */
  41907. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41908. }
  41909. }
  41910. declare module BABYLON {
  41911. /**
  41912. * This defines an action helpful to play a defined sound on a triggered action.
  41913. */
  41914. export class PlaySoundAction extends Action {
  41915. private _sound;
  41916. /**
  41917. * Instantiate the action
  41918. * @param triggerOptions defines the trigger options
  41919. * @param sound defines the sound to play
  41920. * @param condition defines the trigger related conditions
  41921. */
  41922. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41923. /** @hidden */
  41924. _prepare(): void;
  41925. /**
  41926. * Execute the action and play the sound.
  41927. */
  41928. execute(): void;
  41929. /**
  41930. * Serializes the actions and its related information.
  41931. * @param parent defines the object to serialize in
  41932. * @returns the serialized object
  41933. */
  41934. serialize(parent: any): any;
  41935. }
  41936. /**
  41937. * This defines an action helpful to stop a defined sound on a triggered action.
  41938. */
  41939. export class StopSoundAction extends Action {
  41940. private _sound;
  41941. /**
  41942. * Instantiate the action
  41943. * @param triggerOptions defines the trigger options
  41944. * @param sound defines the sound to stop
  41945. * @param condition defines the trigger related conditions
  41946. */
  41947. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41948. /** @hidden */
  41949. _prepare(): void;
  41950. /**
  41951. * Execute the action and stop the sound.
  41952. */
  41953. execute(): void;
  41954. /**
  41955. * Serializes the actions and its related information.
  41956. * @param parent defines the object to serialize in
  41957. * @returns the serialized object
  41958. */
  41959. serialize(parent: any): any;
  41960. }
  41961. }
  41962. declare module BABYLON {
  41963. /**
  41964. * This defines an action responsible to change the value of a property
  41965. * by interpolating between its current value and the newly set one once triggered.
  41966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41967. */
  41968. export class InterpolateValueAction extends Action {
  41969. /**
  41970. * Defines the path of the property where the value should be interpolated
  41971. */
  41972. propertyPath: string;
  41973. /**
  41974. * Defines the target value at the end of the interpolation.
  41975. */
  41976. value: any;
  41977. /**
  41978. * Defines the time it will take for the property to interpolate to the value.
  41979. */
  41980. duration: number;
  41981. /**
  41982. * Defines if the other scene animations should be stopped when the action has been triggered
  41983. */
  41984. stopOtherAnimations?: boolean;
  41985. /**
  41986. * Defines a callback raised once the interpolation animation has been done.
  41987. */
  41988. onInterpolationDone?: () => void;
  41989. /**
  41990. * Observable triggered once the interpolation animation has been done.
  41991. */
  41992. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  41993. private _target;
  41994. private _effectiveTarget;
  41995. private _property;
  41996. /**
  41997. * Instantiate the action
  41998. * @param triggerOptions defines the trigger options
  41999. * @param target defines the object containing the value to interpolate
  42000. * @param propertyPath defines the path to the property in the target object
  42001. * @param value defines the target value at the end of the interpolation
  42002. * @param duration deines the time it will take for the property to interpolate to the value.
  42003. * @param condition defines the trigger related conditions
  42004. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  42005. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  42006. */
  42007. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  42008. /** @hidden */
  42009. _prepare(): void;
  42010. /**
  42011. * Execute the action starts the value interpolation.
  42012. */
  42013. execute(): void;
  42014. /**
  42015. * Serializes the actions and its related information.
  42016. * @param parent defines the object to serialize in
  42017. * @returns the serialized object
  42018. */
  42019. serialize(parent: any): any;
  42020. }
  42021. }
  42022. declare module BABYLON {
  42023. /**
  42024. * Options allowed during the creation of a sound track.
  42025. */
  42026. export interface ISoundTrackOptions {
  42027. /**
  42028. * The volume the sound track should take during creation
  42029. */
  42030. volume?: number;
  42031. /**
  42032. * Define if the sound track is the main sound track of the scene
  42033. */
  42034. mainTrack?: boolean;
  42035. }
  42036. /**
  42037. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  42038. * It will be also used in a future release to apply effects on a specific track.
  42039. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42040. */
  42041. export class SoundTrack {
  42042. /**
  42043. * The unique identifier of the sound track in the scene.
  42044. */
  42045. id: number;
  42046. /**
  42047. * The list of sounds included in the sound track.
  42048. */
  42049. soundCollection: Array<Sound>;
  42050. private _outputAudioNode;
  42051. private _scene;
  42052. private _connectedAnalyser;
  42053. private _options;
  42054. private _isInitialized;
  42055. /**
  42056. * Creates a new sound track.
  42057. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42058. * @param scene Define the scene the sound track belongs to
  42059. * @param options
  42060. */
  42061. constructor(scene: Scene, options?: ISoundTrackOptions);
  42062. private _initializeSoundTrackAudioGraph;
  42063. /**
  42064. * Release the sound track and its associated resources
  42065. */
  42066. dispose(): void;
  42067. /**
  42068. * Adds a sound to this sound track
  42069. * @param sound define the cound to add
  42070. * @ignoreNaming
  42071. */
  42072. AddSound(sound: Sound): void;
  42073. /**
  42074. * Removes a sound to this sound track
  42075. * @param sound define the cound to remove
  42076. * @ignoreNaming
  42077. */
  42078. RemoveSound(sound: Sound): void;
  42079. /**
  42080. * Set a global volume for the full sound track.
  42081. * @param newVolume Define the new volume of the sound track
  42082. */
  42083. setVolume(newVolume: number): void;
  42084. /**
  42085. * Switch the panning model to HRTF:
  42086. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42087. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42088. */
  42089. switchPanningModelToHRTF(): void;
  42090. /**
  42091. * Switch the panning model to Equal Power:
  42092. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42093. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42094. */
  42095. switchPanningModelToEqualPower(): void;
  42096. /**
  42097. * Connect the sound track to an audio analyser allowing some amazing
  42098. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42099. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42100. * @param analyser The analyser to connect to the engine
  42101. */
  42102. connectToAnalyser(analyser: Analyser): void;
  42103. }
  42104. }
  42105. declare module BABYLON {
  42106. interface AbstractScene {
  42107. /**
  42108. * The list of sounds used in the scene.
  42109. */
  42110. sounds: Nullable<Array<Sound>>;
  42111. }
  42112. interface Scene {
  42113. /**
  42114. * @hidden
  42115. * Backing field
  42116. */
  42117. _mainSoundTrack: SoundTrack;
  42118. /**
  42119. * The main sound track played by the scene.
  42120. * It cotains your primary collection of sounds.
  42121. */
  42122. mainSoundTrack: SoundTrack;
  42123. /**
  42124. * The list of sound tracks added to the scene
  42125. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42126. */
  42127. soundTracks: Nullable<Array<SoundTrack>>;
  42128. /**
  42129. * Gets a sound using a given name
  42130. * @param name defines the name to search for
  42131. * @return the found sound or null if not found at all.
  42132. */
  42133. getSoundByName(name: string): Nullable<Sound>;
  42134. /**
  42135. * Gets or sets if audio support is enabled
  42136. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42137. */
  42138. audioEnabled: boolean;
  42139. /**
  42140. * Gets or sets if audio will be output to headphones
  42141. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42142. */
  42143. headphone: boolean;
  42144. /**
  42145. * Gets or sets custom audio listener position provider
  42146. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42147. */
  42148. audioListenerPositionProvider: Nullable<() => Vector3>;
  42149. /**
  42150. * Gets or sets a refresh rate when using 3D audio positioning
  42151. */
  42152. audioPositioningRefreshRate: number;
  42153. }
  42154. /**
  42155. * Defines the sound scene component responsible to manage any sounds
  42156. * in a given scene.
  42157. */
  42158. export class AudioSceneComponent implements ISceneSerializableComponent {
  42159. private static _CameraDirectionLH;
  42160. private static _CameraDirectionRH;
  42161. /**
  42162. * The component name helpfull to identify the component in the list of scene components.
  42163. */
  42164. readonly name: string;
  42165. /**
  42166. * The scene the component belongs to.
  42167. */
  42168. scene: Scene;
  42169. private _audioEnabled;
  42170. /**
  42171. * Gets whether audio is enabled or not.
  42172. * Please use related enable/disable method to switch state.
  42173. */
  42174. get audioEnabled(): boolean;
  42175. private _headphone;
  42176. /**
  42177. * Gets whether audio is outputing to headphone or not.
  42178. * Please use the according Switch methods to change output.
  42179. */
  42180. get headphone(): boolean;
  42181. /**
  42182. * Gets or sets a refresh rate when using 3D audio positioning
  42183. */
  42184. audioPositioningRefreshRate: number;
  42185. private _audioListenerPositionProvider;
  42186. /**
  42187. * Gets the current audio listener position provider
  42188. */
  42189. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42190. /**
  42191. * Sets a custom listener position for all sounds in the scene
  42192. * By default, this is the position of the first active camera
  42193. */
  42194. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42195. /**
  42196. * Creates a new instance of the component for the given scene
  42197. * @param scene Defines the scene to register the component in
  42198. */
  42199. constructor(scene: Scene);
  42200. /**
  42201. * Registers the component in a given scene
  42202. */
  42203. register(): void;
  42204. /**
  42205. * Rebuilds the elements related to this component in case of
  42206. * context lost for instance.
  42207. */
  42208. rebuild(): void;
  42209. /**
  42210. * Serializes the component data to the specified json object
  42211. * @param serializationObject The object to serialize to
  42212. */
  42213. serialize(serializationObject: any): void;
  42214. /**
  42215. * Adds all the elements from the container to the scene
  42216. * @param container the container holding the elements
  42217. */
  42218. addFromContainer(container: AbstractScene): void;
  42219. /**
  42220. * Removes all the elements in the container from the scene
  42221. * @param container contains the elements to remove
  42222. * @param dispose if the removed element should be disposed (default: false)
  42223. */
  42224. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42225. /**
  42226. * Disposes the component and the associated ressources.
  42227. */
  42228. dispose(): void;
  42229. /**
  42230. * Disables audio in the associated scene.
  42231. */
  42232. disableAudio(): void;
  42233. /**
  42234. * Enables audio in the associated scene.
  42235. */
  42236. enableAudio(): void;
  42237. /**
  42238. * Switch audio to headphone output.
  42239. */
  42240. switchAudioModeForHeadphones(): void;
  42241. /**
  42242. * Switch audio to normal speakers.
  42243. */
  42244. switchAudioModeForNormalSpeakers(): void;
  42245. private _cachedCameraDirection;
  42246. private _cachedCameraPosition;
  42247. private _lastCheck;
  42248. private _afterRender;
  42249. }
  42250. }
  42251. declare module BABYLON {
  42252. /**
  42253. * Wraps one or more Sound objects and selects one with random weight for playback.
  42254. */
  42255. export class WeightedSound {
  42256. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42257. loop: boolean;
  42258. private _coneInnerAngle;
  42259. private _coneOuterAngle;
  42260. private _volume;
  42261. /** A Sound is currently playing. */
  42262. isPlaying: boolean;
  42263. /** A Sound is currently paused. */
  42264. isPaused: boolean;
  42265. private _sounds;
  42266. private _weights;
  42267. private _currentIndex?;
  42268. /**
  42269. * Creates a new WeightedSound from the list of sounds given.
  42270. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42271. * @param sounds Array of Sounds that will be selected from.
  42272. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42273. */
  42274. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42275. /**
  42276. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42277. */
  42278. get directionalConeInnerAngle(): number;
  42279. /**
  42280. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42281. */
  42282. set directionalConeInnerAngle(value: number);
  42283. /**
  42284. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42285. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42286. */
  42287. get directionalConeOuterAngle(): number;
  42288. /**
  42289. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42290. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42291. */
  42292. set directionalConeOuterAngle(value: number);
  42293. /**
  42294. * Playback volume.
  42295. */
  42296. get volume(): number;
  42297. /**
  42298. * Playback volume.
  42299. */
  42300. set volume(value: number);
  42301. private _onended;
  42302. /**
  42303. * Suspend playback
  42304. */
  42305. pause(): void;
  42306. /**
  42307. * Stop playback
  42308. */
  42309. stop(): void;
  42310. /**
  42311. * Start playback.
  42312. * @param startOffset Position the clip head at a specific time in seconds.
  42313. */
  42314. play(startOffset?: number): void;
  42315. }
  42316. }
  42317. declare module BABYLON {
  42318. /**
  42319. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42320. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42321. */
  42322. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42323. /**
  42324. * Gets the name of the behavior.
  42325. */
  42326. get name(): string;
  42327. /**
  42328. * The easing function used by animations
  42329. */
  42330. static EasingFunction: BackEase;
  42331. /**
  42332. * The easing mode used by animations
  42333. */
  42334. static EasingMode: number;
  42335. /**
  42336. * The duration of the animation, in milliseconds
  42337. */
  42338. transitionDuration: number;
  42339. /**
  42340. * Length of the distance animated by the transition when lower radius is reached
  42341. */
  42342. lowerRadiusTransitionRange: number;
  42343. /**
  42344. * Length of the distance animated by the transition when upper radius is reached
  42345. */
  42346. upperRadiusTransitionRange: number;
  42347. private _autoTransitionRange;
  42348. /**
  42349. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42350. */
  42351. get autoTransitionRange(): boolean;
  42352. /**
  42353. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42354. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42355. */
  42356. set autoTransitionRange(value: boolean);
  42357. private _attachedCamera;
  42358. private _onAfterCheckInputsObserver;
  42359. private _onMeshTargetChangedObserver;
  42360. /**
  42361. * Initializes the behavior.
  42362. */
  42363. init(): void;
  42364. /**
  42365. * Attaches the behavior to its arc rotate camera.
  42366. * @param camera Defines the camera to attach the behavior to
  42367. */
  42368. attach(camera: ArcRotateCamera): void;
  42369. /**
  42370. * Detaches the behavior from its current arc rotate camera.
  42371. */
  42372. detach(): void;
  42373. private _radiusIsAnimating;
  42374. private _radiusBounceTransition;
  42375. private _animatables;
  42376. private _cachedWheelPrecision;
  42377. /**
  42378. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42379. * @param radiusLimit The limit to check against.
  42380. * @return Bool to indicate if at limit.
  42381. */
  42382. private _isRadiusAtLimit;
  42383. /**
  42384. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42385. * @param radiusDelta The delta by which to animate to. Can be negative.
  42386. */
  42387. private _applyBoundRadiusAnimation;
  42388. /**
  42389. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42390. */
  42391. protected _clearAnimationLocks(): void;
  42392. /**
  42393. * Stops and removes all animations that have been applied to the camera
  42394. */
  42395. stopAllAnimations(): void;
  42396. }
  42397. }
  42398. declare module BABYLON {
  42399. /**
  42400. * 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.
  42401. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42402. */
  42403. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42404. /**
  42405. * Gets the name of the behavior.
  42406. */
  42407. get name(): string;
  42408. private _mode;
  42409. private _radiusScale;
  42410. private _positionScale;
  42411. private _defaultElevation;
  42412. private _elevationReturnTime;
  42413. private _elevationReturnWaitTime;
  42414. private _zoomStopsAnimation;
  42415. private _framingTime;
  42416. /**
  42417. * The easing function used by animations
  42418. */
  42419. static EasingFunction: ExponentialEase;
  42420. /**
  42421. * The easing mode used by animations
  42422. */
  42423. static EasingMode: number;
  42424. /**
  42425. * Sets the current mode used by the behavior
  42426. */
  42427. set mode(mode: number);
  42428. /**
  42429. * Gets current mode used by the behavior.
  42430. */
  42431. get mode(): number;
  42432. /**
  42433. * Sets the scale applied to the radius (1 by default)
  42434. */
  42435. set radiusScale(radius: number);
  42436. /**
  42437. * Gets the scale applied to the radius
  42438. */
  42439. get radiusScale(): number;
  42440. /**
  42441. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42442. */
  42443. set positionScale(scale: number);
  42444. /**
  42445. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42446. */
  42447. get positionScale(): number;
  42448. /**
  42449. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42450. * behaviour is triggered, in radians.
  42451. */
  42452. set defaultElevation(elevation: number);
  42453. /**
  42454. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42455. * behaviour is triggered, in radians.
  42456. */
  42457. get defaultElevation(): number;
  42458. /**
  42459. * Sets the time (in milliseconds) taken to return to the default beta position.
  42460. * Negative value indicates camera should not return to default.
  42461. */
  42462. set elevationReturnTime(speed: number);
  42463. /**
  42464. * Gets the time (in milliseconds) taken to return to the default beta position.
  42465. * Negative value indicates camera should not return to default.
  42466. */
  42467. get elevationReturnTime(): number;
  42468. /**
  42469. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42470. */
  42471. set elevationReturnWaitTime(time: number);
  42472. /**
  42473. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42474. */
  42475. get elevationReturnWaitTime(): number;
  42476. /**
  42477. * Sets the flag that indicates if user zooming should stop animation.
  42478. */
  42479. set zoomStopsAnimation(flag: boolean);
  42480. /**
  42481. * Gets the flag that indicates if user zooming should stop animation.
  42482. */
  42483. get zoomStopsAnimation(): boolean;
  42484. /**
  42485. * Sets the transition time when framing the mesh, in milliseconds
  42486. */
  42487. set framingTime(time: number);
  42488. /**
  42489. * Gets the transition time when framing the mesh, in milliseconds
  42490. */
  42491. get framingTime(): number;
  42492. /**
  42493. * Define if the behavior should automatically change the configured
  42494. * camera limits and sensibilities.
  42495. */
  42496. autoCorrectCameraLimitsAndSensibility: boolean;
  42497. private _onPrePointerObservableObserver;
  42498. private _onAfterCheckInputsObserver;
  42499. private _onMeshTargetChangedObserver;
  42500. private _attachedCamera;
  42501. private _isPointerDown;
  42502. private _lastInteractionTime;
  42503. /**
  42504. * Initializes the behavior.
  42505. */
  42506. init(): void;
  42507. /**
  42508. * Attaches the behavior to its arc rotate camera.
  42509. * @param camera Defines the camera to attach the behavior to
  42510. */
  42511. attach(camera: ArcRotateCamera): void;
  42512. /**
  42513. * Detaches the behavior from its current arc rotate camera.
  42514. */
  42515. detach(): void;
  42516. private _animatables;
  42517. private _betaIsAnimating;
  42518. private _betaTransition;
  42519. private _radiusTransition;
  42520. private _vectorTransition;
  42521. /**
  42522. * Targets the given mesh and updates zoom level accordingly.
  42523. * @param mesh The mesh to target.
  42524. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42525. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42526. */
  42527. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42528. /**
  42529. * Targets the given mesh with its children and updates zoom level accordingly.
  42530. * @param mesh The mesh to target.
  42531. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42532. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42533. */
  42534. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42535. /**
  42536. * Targets the given meshes with their children and updates zoom level accordingly.
  42537. * @param meshes The mesh to target.
  42538. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42539. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42540. */
  42541. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42542. /**
  42543. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42544. * @param minimumWorld Determines the smaller position of the bounding box extend
  42545. * @param maximumWorld Determines the bigger position of the bounding box extend
  42546. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42547. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42548. */
  42549. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42550. /**
  42551. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42552. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42553. * frustum width.
  42554. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42555. * to fully enclose the mesh in the viewing frustum.
  42556. */
  42557. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42558. /**
  42559. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42560. * is automatically returned to its default position (expected to be above ground plane).
  42561. */
  42562. private _maintainCameraAboveGround;
  42563. /**
  42564. * Returns the frustum slope based on the canvas ratio and camera FOV
  42565. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42566. */
  42567. private _getFrustumSlope;
  42568. /**
  42569. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42570. */
  42571. private _clearAnimationLocks;
  42572. /**
  42573. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42574. */
  42575. private _applyUserInteraction;
  42576. /**
  42577. * Stops and removes all animations that have been applied to the camera
  42578. */
  42579. stopAllAnimations(): void;
  42580. /**
  42581. * Gets a value indicating if the user is moving the camera
  42582. */
  42583. get isUserIsMoving(): boolean;
  42584. /**
  42585. * The camera can move all the way towards the mesh.
  42586. */
  42587. static IgnoreBoundsSizeMode: number;
  42588. /**
  42589. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42590. */
  42591. static FitFrustumSidesMode: number;
  42592. }
  42593. }
  42594. declare module BABYLON {
  42595. /**
  42596. * Base class for Camera Pointer Inputs.
  42597. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42598. * for example usage.
  42599. */
  42600. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42601. /**
  42602. * Defines the camera the input is attached to.
  42603. */
  42604. abstract camera: Camera;
  42605. /**
  42606. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42607. */
  42608. protected _altKey: boolean;
  42609. protected _ctrlKey: boolean;
  42610. protected _metaKey: boolean;
  42611. protected _shiftKey: boolean;
  42612. /**
  42613. * Which mouse buttons were pressed at time of last mouse event.
  42614. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42615. */
  42616. protected _buttonsPressed: number;
  42617. /**
  42618. * Defines the buttons associated with the input to handle camera move.
  42619. */
  42620. buttons: number[];
  42621. /**
  42622. * Attach the input controls to a specific dom element to get the input from.
  42623. * @param element Defines the element the controls should be listened from
  42624. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42625. */
  42626. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42627. /**
  42628. * Detach the current controls from the specified dom element.
  42629. * @param element Defines the element to stop listening the inputs from
  42630. */
  42631. detachControl(element: Nullable<HTMLElement>): void;
  42632. /**
  42633. * Gets the class name of the current input.
  42634. * @returns the class name
  42635. */
  42636. getClassName(): string;
  42637. /**
  42638. * Get the friendly name associated with the input class.
  42639. * @returns the input friendly name
  42640. */
  42641. getSimpleName(): string;
  42642. /**
  42643. * Called on pointer POINTERDOUBLETAP event.
  42644. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42645. */
  42646. protected onDoubleTap(type: string): void;
  42647. /**
  42648. * Called on pointer POINTERMOVE event if only a single touch is active.
  42649. * Override this method to provide functionality.
  42650. */
  42651. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42652. /**
  42653. * Called on pointer POINTERMOVE event if multiple touches are active.
  42654. * Override this method to provide functionality.
  42655. */
  42656. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42657. /**
  42658. * Called on JS contextmenu event.
  42659. * Override this method to provide functionality.
  42660. */
  42661. protected onContextMenu(evt: PointerEvent): void;
  42662. /**
  42663. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42664. * press.
  42665. * Override this method to provide functionality.
  42666. */
  42667. protected onButtonDown(evt: PointerEvent): void;
  42668. /**
  42669. * Called each time a new POINTERUP event occurs. Ie, for each button
  42670. * release.
  42671. * Override this method to provide functionality.
  42672. */
  42673. protected onButtonUp(evt: PointerEvent): void;
  42674. /**
  42675. * Called when window becomes inactive.
  42676. * Override this method to provide functionality.
  42677. */
  42678. protected onLostFocus(): void;
  42679. private _pointerInput;
  42680. private _observer;
  42681. private _onLostFocus;
  42682. private pointA;
  42683. private pointB;
  42684. }
  42685. }
  42686. declare module BABYLON {
  42687. /**
  42688. * Manage the pointers inputs to control an arc rotate camera.
  42689. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42690. */
  42691. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42692. /**
  42693. * Defines the camera the input is attached to.
  42694. */
  42695. camera: ArcRotateCamera;
  42696. /**
  42697. * Gets the class name of the current input.
  42698. * @returns the class name
  42699. */
  42700. getClassName(): string;
  42701. /**
  42702. * Defines the buttons associated with the input to handle camera move.
  42703. */
  42704. buttons: number[];
  42705. /**
  42706. * Defines the pointer angular sensibility along the X axis or how fast is
  42707. * the camera rotating.
  42708. */
  42709. angularSensibilityX: number;
  42710. /**
  42711. * Defines the pointer angular sensibility along the Y axis or how fast is
  42712. * the camera rotating.
  42713. */
  42714. angularSensibilityY: number;
  42715. /**
  42716. * Defines the pointer pinch precision or how fast is the camera zooming.
  42717. */
  42718. pinchPrecision: number;
  42719. /**
  42720. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42721. * from 0.
  42722. * It defines the percentage of current camera.radius to use as delta when
  42723. * pinch zoom is used.
  42724. */
  42725. pinchDeltaPercentage: number;
  42726. /**
  42727. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42728. * that any object in the plane at the camera's target point will scale
  42729. * perfectly with finger motion.
  42730. * Overrides pinchDeltaPercentage and pinchPrecision.
  42731. */
  42732. useNaturalPinchZoom: boolean;
  42733. /**
  42734. * Defines the pointer panning sensibility or how fast is the camera moving.
  42735. */
  42736. panningSensibility: number;
  42737. /**
  42738. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42739. */
  42740. multiTouchPanning: boolean;
  42741. /**
  42742. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42743. * zoom (pinch) through multitouch.
  42744. */
  42745. multiTouchPanAndZoom: boolean;
  42746. /**
  42747. * Revers pinch action direction.
  42748. */
  42749. pinchInwards: boolean;
  42750. private _isPanClick;
  42751. private _twoFingerActivityCount;
  42752. private _isPinching;
  42753. /**
  42754. * Called on pointer POINTERMOVE event if only a single touch is active.
  42755. */
  42756. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42757. /**
  42758. * Called on pointer POINTERDOUBLETAP event.
  42759. */
  42760. protected onDoubleTap(type: string): void;
  42761. /**
  42762. * Called on pointer POINTERMOVE event if multiple touches are active.
  42763. */
  42764. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42765. /**
  42766. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42767. * press.
  42768. */
  42769. protected onButtonDown(evt: PointerEvent): void;
  42770. /**
  42771. * Called each time a new POINTERUP event occurs. Ie, for each button
  42772. * release.
  42773. */
  42774. protected onButtonUp(evt: PointerEvent): void;
  42775. /**
  42776. * Called when window becomes inactive.
  42777. */
  42778. protected onLostFocus(): void;
  42779. }
  42780. }
  42781. declare module BABYLON {
  42782. /**
  42783. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42784. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42785. */
  42786. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42787. /**
  42788. * Defines the camera the input is attached to.
  42789. */
  42790. camera: ArcRotateCamera;
  42791. /**
  42792. * Defines the list of key codes associated with the up action (increase alpha)
  42793. */
  42794. keysUp: number[];
  42795. /**
  42796. * Defines the list of key codes associated with the down action (decrease alpha)
  42797. */
  42798. keysDown: number[];
  42799. /**
  42800. * Defines the list of key codes associated with the left action (increase beta)
  42801. */
  42802. keysLeft: number[];
  42803. /**
  42804. * Defines the list of key codes associated with the right action (decrease beta)
  42805. */
  42806. keysRight: number[];
  42807. /**
  42808. * Defines the list of key codes associated with the reset action.
  42809. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42810. */
  42811. keysReset: number[];
  42812. /**
  42813. * Defines the panning sensibility of the inputs.
  42814. * (How fast is the camera panning)
  42815. */
  42816. panningSensibility: number;
  42817. /**
  42818. * Defines the zooming sensibility of the inputs.
  42819. * (How fast is the camera zooming)
  42820. */
  42821. zoomingSensibility: number;
  42822. /**
  42823. * Defines whether maintaining the alt key down switch the movement mode from
  42824. * orientation to zoom.
  42825. */
  42826. useAltToZoom: boolean;
  42827. /**
  42828. * Rotation speed of the camera
  42829. */
  42830. angularSpeed: number;
  42831. private _keys;
  42832. private _ctrlPressed;
  42833. private _altPressed;
  42834. private _onCanvasBlurObserver;
  42835. private _onKeyboardObserver;
  42836. private _engine;
  42837. private _scene;
  42838. /**
  42839. * Attach the input controls to a specific dom element to get the input from.
  42840. * @param element Defines the element the controls should be listened from
  42841. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42842. */
  42843. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42844. /**
  42845. * Detach the current controls from the specified dom element.
  42846. * @param element Defines the element to stop listening the inputs from
  42847. */
  42848. detachControl(element: Nullable<HTMLElement>): void;
  42849. /**
  42850. * Update the current camera state depending on the inputs that have been used this frame.
  42851. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42852. */
  42853. checkInputs(): void;
  42854. /**
  42855. * Gets the class name of the current intput.
  42856. * @returns the class name
  42857. */
  42858. getClassName(): string;
  42859. /**
  42860. * Get the friendly name associated with the input class.
  42861. * @returns the input friendly name
  42862. */
  42863. getSimpleName(): string;
  42864. }
  42865. }
  42866. declare module BABYLON {
  42867. /**
  42868. * Manage the mouse wheel inputs to control an arc rotate camera.
  42869. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42870. */
  42871. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42872. /**
  42873. * Defines the camera the input is attached to.
  42874. */
  42875. camera: ArcRotateCamera;
  42876. /**
  42877. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42878. */
  42879. wheelPrecision: number;
  42880. /**
  42881. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42882. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42883. */
  42884. wheelDeltaPercentage: number;
  42885. private _wheel;
  42886. private _observer;
  42887. private computeDeltaFromMouseWheelLegacyEvent;
  42888. /**
  42889. * Attach the input controls to a specific dom element to get the input from.
  42890. * @param element Defines the element the controls should be listened from
  42891. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42892. */
  42893. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42894. /**
  42895. * Detach the current controls from the specified dom element.
  42896. * @param element Defines the element to stop listening the inputs from
  42897. */
  42898. detachControl(element: Nullable<HTMLElement>): void;
  42899. /**
  42900. * Gets the class name of the current intput.
  42901. * @returns the class name
  42902. */
  42903. getClassName(): string;
  42904. /**
  42905. * Get the friendly name associated with the input class.
  42906. * @returns the input friendly name
  42907. */
  42908. getSimpleName(): string;
  42909. }
  42910. }
  42911. declare module BABYLON {
  42912. /**
  42913. * Default Inputs manager for the ArcRotateCamera.
  42914. * It groups all the default supported inputs for ease of use.
  42915. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42916. */
  42917. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  42918. /**
  42919. * Instantiates a new ArcRotateCameraInputsManager.
  42920. * @param camera Defines the camera the inputs belong to
  42921. */
  42922. constructor(camera: ArcRotateCamera);
  42923. /**
  42924. * Add mouse wheel input support to the input manager.
  42925. * @returns the current input manager
  42926. */
  42927. addMouseWheel(): ArcRotateCameraInputsManager;
  42928. /**
  42929. * Add pointers input support to the input manager.
  42930. * @returns the current input manager
  42931. */
  42932. addPointers(): ArcRotateCameraInputsManager;
  42933. /**
  42934. * Add keyboard input support to the input manager.
  42935. * @returns the current input manager
  42936. */
  42937. addKeyboard(): ArcRotateCameraInputsManager;
  42938. }
  42939. }
  42940. declare module BABYLON {
  42941. /**
  42942. * This represents an orbital type of camera.
  42943. *
  42944. * 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.
  42945. * 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.
  42946. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  42947. */
  42948. export class ArcRotateCamera extends TargetCamera {
  42949. /**
  42950. * Defines the rotation angle of the camera along the longitudinal axis.
  42951. */
  42952. alpha: number;
  42953. /**
  42954. * Defines the rotation angle of the camera along the latitudinal axis.
  42955. */
  42956. beta: number;
  42957. /**
  42958. * Defines the radius of the camera from it s target point.
  42959. */
  42960. radius: number;
  42961. protected _target: Vector3;
  42962. protected _targetHost: Nullable<AbstractMesh>;
  42963. /**
  42964. * Defines the target point of the camera.
  42965. * The camera looks towards it form the radius distance.
  42966. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  42967. */
  42968. get target(): Vector3;
  42969. set target(value: Vector3);
  42970. /**
  42971. * Define the current local position of the camera in the scene
  42972. */
  42973. get position(): Vector3;
  42974. set position(newPosition: Vector3);
  42975. protected _upToYMatrix: Matrix;
  42976. protected _YToUpMatrix: Matrix;
  42977. /**
  42978. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  42979. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  42980. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  42981. */
  42982. set upVector(vec: Vector3);
  42983. get upVector(): Vector3;
  42984. /**
  42985. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  42986. */
  42987. setMatUp(): void;
  42988. /**
  42989. * Current inertia value on the longitudinal axis.
  42990. * The bigger this number the longer it will take for the camera to stop.
  42991. */
  42992. inertialAlphaOffset: number;
  42993. /**
  42994. * Current inertia value on the latitudinal axis.
  42995. * The bigger this number the longer it will take for the camera to stop.
  42996. */
  42997. inertialBetaOffset: number;
  42998. /**
  42999. * Current inertia value on the radius axis.
  43000. * The bigger this number the longer it will take for the camera to stop.
  43001. */
  43002. inertialRadiusOffset: number;
  43003. /**
  43004. * Minimum allowed angle on the longitudinal axis.
  43005. * This can help limiting how the Camera is able to move in the scene.
  43006. */
  43007. lowerAlphaLimit: Nullable<number>;
  43008. /**
  43009. * Maximum allowed angle on the longitudinal axis.
  43010. * This can help limiting how the Camera is able to move in the scene.
  43011. */
  43012. upperAlphaLimit: Nullable<number>;
  43013. /**
  43014. * Minimum allowed angle on the latitudinal axis.
  43015. * This can help limiting how the Camera is able to move in the scene.
  43016. */
  43017. lowerBetaLimit: number;
  43018. /**
  43019. * Maximum allowed angle on the latitudinal axis.
  43020. * This can help limiting how the Camera is able to move in the scene.
  43021. */
  43022. upperBetaLimit: number;
  43023. /**
  43024. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  43025. * This can help limiting how the Camera is able to move in the scene.
  43026. */
  43027. lowerRadiusLimit: Nullable<number>;
  43028. /**
  43029. * Maximum allowed distance of the camera to the target (The camera can not get further).
  43030. * This can help limiting how the Camera is able to move in the scene.
  43031. */
  43032. upperRadiusLimit: Nullable<number>;
  43033. /**
  43034. * Defines the current inertia value used during panning of the camera along the X axis.
  43035. */
  43036. inertialPanningX: number;
  43037. /**
  43038. * Defines the current inertia value used during panning of the camera along the Y axis.
  43039. */
  43040. inertialPanningY: number;
  43041. /**
  43042. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  43043. * Basically if your fingers moves away from more than this distance you will be considered
  43044. * in pinch mode.
  43045. */
  43046. pinchToPanMaxDistance: number;
  43047. /**
  43048. * Defines the maximum distance the camera can pan.
  43049. * This could help keeping the cammera always in your scene.
  43050. */
  43051. panningDistanceLimit: Nullable<number>;
  43052. /**
  43053. * Defines the target of the camera before paning.
  43054. */
  43055. panningOriginTarget: Vector3;
  43056. /**
  43057. * Defines the value of the inertia used during panning.
  43058. * 0 would mean stop inertia and one would mean no decelleration at all.
  43059. */
  43060. panningInertia: number;
  43061. /**
  43062. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  43063. */
  43064. get angularSensibilityX(): number;
  43065. set angularSensibilityX(value: number);
  43066. /**
  43067. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  43068. */
  43069. get angularSensibilityY(): number;
  43070. set angularSensibilityY(value: number);
  43071. /**
  43072. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  43073. */
  43074. get pinchPrecision(): number;
  43075. set pinchPrecision(value: number);
  43076. /**
  43077. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  43078. * It will be used instead of pinchDeltaPrecision if different from 0.
  43079. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43080. */
  43081. get pinchDeltaPercentage(): number;
  43082. set pinchDeltaPercentage(value: number);
  43083. /**
  43084. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  43085. * and pinch delta percentage.
  43086. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43087. * that any object in the plane at the camera's target point will scale
  43088. * perfectly with finger motion.
  43089. */
  43090. get useNaturalPinchZoom(): boolean;
  43091. set useNaturalPinchZoom(value: boolean);
  43092. /**
  43093. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  43094. */
  43095. get panningSensibility(): number;
  43096. set panningSensibility(value: number);
  43097. /**
  43098. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  43099. */
  43100. get keysUp(): number[];
  43101. set keysUp(value: number[]);
  43102. /**
  43103. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  43104. */
  43105. get keysDown(): number[];
  43106. set keysDown(value: number[]);
  43107. /**
  43108. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  43109. */
  43110. get keysLeft(): number[];
  43111. set keysLeft(value: number[]);
  43112. /**
  43113. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  43114. */
  43115. get keysRight(): number[];
  43116. set keysRight(value: number[]);
  43117. /**
  43118. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43119. */
  43120. get wheelPrecision(): number;
  43121. set wheelPrecision(value: number);
  43122. /**
  43123. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43124. * It will be used instead of pinchDeltaPrecision if different from 0.
  43125. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43126. */
  43127. get wheelDeltaPercentage(): number;
  43128. set wheelDeltaPercentage(value: number);
  43129. /**
  43130. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43131. */
  43132. zoomOnFactor: number;
  43133. /**
  43134. * Defines a screen offset for the camera position.
  43135. */
  43136. targetScreenOffset: Vector2;
  43137. /**
  43138. * Allows the camera to be completely reversed.
  43139. * If false the camera can not arrive upside down.
  43140. */
  43141. allowUpsideDown: boolean;
  43142. /**
  43143. * Define if double tap/click is used to restore the previously saved state of the camera.
  43144. */
  43145. useInputToRestoreState: boolean;
  43146. /** @hidden */
  43147. _viewMatrix: Matrix;
  43148. /** @hidden */
  43149. _useCtrlForPanning: boolean;
  43150. /** @hidden */
  43151. _panningMouseButton: number;
  43152. /**
  43153. * Defines the input associated to the camera.
  43154. */
  43155. inputs: ArcRotateCameraInputsManager;
  43156. /** @hidden */
  43157. _reset: () => void;
  43158. /**
  43159. * Defines the allowed panning axis.
  43160. */
  43161. panningAxis: Vector3;
  43162. protected _localDirection: Vector3;
  43163. protected _transformedDirection: Vector3;
  43164. private _bouncingBehavior;
  43165. /**
  43166. * Gets the bouncing behavior of the camera if it has been enabled.
  43167. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43168. */
  43169. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43170. /**
  43171. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43172. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43173. */
  43174. get useBouncingBehavior(): boolean;
  43175. set useBouncingBehavior(value: boolean);
  43176. private _framingBehavior;
  43177. /**
  43178. * Gets the framing behavior of the camera if it has been enabled.
  43179. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43180. */
  43181. get framingBehavior(): Nullable<FramingBehavior>;
  43182. /**
  43183. * Defines if the framing behavior of the camera is enabled on the camera.
  43184. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43185. */
  43186. get useFramingBehavior(): boolean;
  43187. set useFramingBehavior(value: boolean);
  43188. private _autoRotationBehavior;
  43189. /**
  43190. * Gets the auto rotation behavior of the camera if it has been enabled.
  43191. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43192. */
  43193. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43194. /**
  43195. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43196. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43197. */
  43198. get useAutoRotationBehavior(): boolean;
  43199. set useAutoRotationBehavior(value: boolean);
  43200. /**
  43201. * Observable triggered when the mesh target has been changed on the camera.
  43202. */
  43203. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43204. /**
  43205. * Event raised when the camera is colliding with a mesh.
  43206. */
  43207. onCollide: (collidedMesh: AbstractMesh) => void;
  43208. /**
  43209. * Defines whether the camera should check collision with the objects oh the scene.
  43210. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43211. */
  43212. checkCollisions: boolean;
  43213. /**
  43214. * Defines the collision radius of the camera.
  43215. * This simulates a sphere around the camera.
  43216. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43217. */
  43218. collisionRadius: Vector3;
  43219. protected _collider: Collider;
  43220. protected _previousPosition: Vector3;
  43221. protected _collisionVelocity: Vector3;
  43222. protected _newPosition: Vector3;
  43223. protected _previousAlpha: number;
  43224. protected _previousBeta: number;
  43225. protected _previousRadius: number;
  43226. protected _collisionTriggered: boolean;
  43227. protected _targetBoundingCenter: Nullable<Vector3>;
  43228. private _computationVector;
  43229. /**
  43230. * Instantiates a new ArcRotateCamera in a given scene
  43231. * @param name Defines the name of the camera
  43232. * @param alpha Defines the camera rotation along the logitudinal axis
  43233. * @param beta Defines the camera rotation along the latitudinal axis
  43234. * @param radius Defines the camera distance from its target
  43235. * @param target Defines the camera target
  43236. * @param scene Defines the scene the camera belongs to
  43237. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43238. */
  43239. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43240. /** @hidden */
  43241. _initCache(): void;
  43242. /** @hidden */
  43243. _updateCache(ignoreParentClass?: boolean): void;
  43244. protected _getTargetPosition(): Vector3;
  43245. private _storedAlpha;
  43246. private _storedBeta;
  43247. private _storedRadius;
  43248. private _storedTarget;
  43249. private _storedTargetScreenOffset;
  43250. /**
  43251. * Stores the current state of the camera (alpha, beta, radius and target)
  43252. * @returns the camera itself
  43253. */
  43254. storeState(): Camera;
  43255. /**
  43256. * @hidden
  43257. * Restored camera state. You must call storeState() first
  43258. */
  43259. _restoreStateValues(): boolean;
  43260. /** @hidden */
  43261. _isSynchronizedViewMatrix(): boolean;
  43262. /**
  43263. * Attached controls to the current camera.
  43264. * @param element Defines the element the controls should be listened from
  43265. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43266. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43267. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43268. */
  43269. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43270. /**
  43271. * Detach the current controls from the camera.
  43272. * The camera will stop reacting to inputs.
  43273. * @param element Defines the element to stop listening the inputs from
  43274. */
  43275. detachControl(element: HTMLElement): void;
  43276. /** @hidden */
  43277. _checkInputs(): void;
  43278. protected _checkLimits(): void;
  43279. /**
  43280. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43281. */
  43282. rebuildAnglesAndRadius(): void;
  43283. /**
  43284. * Use a position to define the current camera related information like alpha, beta and radius
  43285. * @param position Defines the position to set the camera at
  43286. */
  43287. setPosition(position: Vector3): void;
  43288. /**
  43289. * Defines the target the camera should look at.
  43290. * This will automatically adapt alpha beta and radius to fit within the new target.
  43291. * @param target Defines the new target as a Vector or a mesh
  43292. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43293. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43294. */
  43295. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43296. /** @hidden */
  43297. _getViewMatrix(): Matrix;
  43298. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43299. /**
  43300. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43301. * @param meshes Defines the mesh to zoom on
  43302. * @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)
  43303. */
  43304. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43305. /**
  43306. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43307. * The target will be changed but the radius
  43308. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43309. * @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)
  43310. */
  43311. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43312. min: Vector3;
  43313. max: Vector3;
  43314. distance: number;
  43315. }, doNotUpdateMaxZ?: boolean): void;
  43316. /**
  43317. * @override
  43318. * Override Camera.createRigCamera
  43319. */
  43320. createRigCamera(name: string, cameraIndex: number): Camera;
  43321. /**
  43322. * @hidden
  43323. * @override
  43324. * Override Camera._updateRigCameras
  43325. */
  43326. _updateRigCameras(): void;
  43327. /**
  43328. * Destroy the camera and release the current resources hold by it.
  43329. */
  43330. dispose(): void;
  43331. /**
  43332. * Gets the current object class name.
  43333. * @return the class name
  43334. */
  43335. getClassName(): string;
  43336. }
  43337. }
  43338. declare module BABYLON {
  43339. /**
  43340. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43341. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43342. */
  43343. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43344. /**
  43345. * Gets the name of the behavior.
  43346. */
  43347. get name(): string;
  43348. private _zoomStopsAnimation;
  43349. private _idleRotationSpeed;
  43350. private _idleRotationWaitTime;
  43351. private _idleRotationSpinupTime;
  43352. /**
  43353. * Sets the flag that indicates if user zooming should stop animation.
  43354. */
  43355. set zoomStopsAnimation(flag: boolean);
  43356. /**
  43357. * Gets the flag that indicates if user zooming should stop animation.
  43358. */
  43359. get zoomStopsAnimation(): boolean;
  43360. /**
  43361. * Sets the default speed at which the camera rotates around the model.
  43362. */
  43363. set idleRotationSpeed(speed: number);
  43364. /**
  43365. * Gets the default speed at which the camera rotates around the model.
  43366. */
  43367. get idleRotationSpeed(): number;
  43368. /**
  43369. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43370. */
  43371. set idleRotationWaitTime(time: number);
  43372. /**
  43373. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43374. */
  43375. get idleRotationWaitTime(): number;
  43376. /**
  43377. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43378. */
  43379. set idleRotationSpinupTime(time: number);
  43380. /**
  43381. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43382. */
  43383. get idleRotationSpinupTime(): number;
  43384. /**
  43385. * Gets a value indicating if the camera is currently rotating because of this behavior
  43386. */
  43387. get rotationInProgress(): boolean;
  43388. private _onPrePointerObservableObserver;
  43389. private _onAfterCheckInputsObserver;
  43390. private _attachedCamera;
  43391. private _isPointerDown;
  43392. private _lastFrameTime;
  43393. private _lastInteractionTime;
  43394. private _cameraRotationSpeed;
  43395. /**
  43396. * Initializes the behavior.
  43397. */
  43398. init(): void;
  43399. /**
  43400. * Attaches the behavior to its arc rotate camera.
  43401. * @param camera Defines the camera to attach the behavior to
  43402. */
  43403. attach(camera: ArcRotateCamera): void;
  43404. /**
  43405. * Detaches the behavior from its current arc rotate camera.
  43406. */
  43407. detach(): void;
  43408. /**
  43409. * Returns true if user is scrolling.
  43410. * @return true if user is scrolling.
  43411. */
  43412. private _userIsZooming;
  43413. private _lastFrameRadius;
  43414. private _shouldAnimationStopForInteraction;
  43415. /**
  43416. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43417. */
  43418. private _applyUserInteraction;
  43419. private _userIsMoving;
  43420. }
  43421. }
  43422. declare module BABYLON {
  43423. /**
  43424. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43425. */
  43426. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43427. private ui;
  43428. /**
  43429. * The name of the behavior
  43430. */
  43431. name: string;
  43432. /**
  43433. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43434. */
  43435. distanceAwayFromFace: number;
  43436. /**
  43437. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43438. */
  43439. distanceAwayFromBottomOfFace: number;
  43440. private _faceVectors;
  43441. private _target;
  43442. private _scene;
  43443. private _onRenderObserver;
  43444. private _tmpMatrix;
  43445. private _tmpVector;
  43446. /**
  43447. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43448. * @param ui The transform node that should be attched to the mesh
  43449. */
  43450. constructor(ui: TransformNode);
  43451. /**
  43452. * Initializes the behavior
  43453. */
  43454. init(): void;
  43455. private _closestFace;
  43456. private _zeroVector;
  43457. private _lookAtTmpMatrix;
  43458. private _lookAtToRef;
  43459. /**
  43460. * Attaches the AttachToBoxBehavior to the passed in mesh
  43461. * @param target The mesh that the specified node will be attached to
  43462. */
  43463. attach(target: Mesh): void;
  43464. /**
  43465. * Detaches the behavior from the mesh
  43466. */
  43467. detach(): void;
  43468. }
  43469. }
  43470. declare module BABYLON {
  43471. /**
  43472. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43473. */
  43474. export class FadeInOutBehavior implements Behavior<Mesh> {
  43475. /**
  43476. * Time in milliseconds to delay before fading in (Default: 0)
  43477. */
  43478. delay: number;
  43479. /**
  43480. * Time in milliseconds for the mesh to fade in (Default: 300)
  43481. */
  43482. fadeInTime: number;
  43483. private _millisecondsPerFrame;
  43484. private _hovered;
  43485. private _hoverValue;
  43486. private _ownerNode;
  43487. /**
  43488. * Instatiates the FadeInOutBehavior
  43489. */
  43490. constructor();
  43491. /**
  43492. * The name of the behavior
  43493. */
  43494. get name(): string;
  43495. /**
  43496. * Initializes the behavior
  43497. */
  43498. init(): void;
  43499. /**
  43500. * Attaches the fade behavior on the passed in mesh
  43501. * @param ownerNode The mesh that will be faded in/out once attached
  43502. */
  43503. attach(ownerNode: Mesh): void;
  43504. /**
  43505. * Detaches the behavior from the mesh
  43506. */
  43507. detach(): void;
  43508. /**
  43509. * Triggers the mesh to begin fading in or out
  43510. * @param value if the object should fade in or out (true to fade in)
  43511. */
  43512. fadeIn(value: boolean): void;
  43513. private _update;
  43514. private _setAllVisibility;
  43515. }
  43516. }
  43517. declare module BABYLON {
  43518. /**
  43519. * Class containing a set of static utilities functions for managing Pivots
  43520. * @hidden
  43521. */
  43522. export class PivotTools {
  43523. private static _PivotCached;
  43524. private static _OldPivotPoint;
  43525. private static _PivotTranslation;
  43526. private static _PivotTmpVector;
  43527. private static _PivotPostMultiplyPivotMatrix;
  43528. /** @hidden */
  43529. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43530. /** @hidden */
  43531. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43532. }
  43533. }
  43534. declare module BABYLON {
  43535. /**
  43536. * Class containing static functions to help procedurally build meshes
  43537. */
  43538. export class PlaneBuilder {
  43539. /**
  43540. * Creates a plane mesh
  43541. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43542. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43543. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43544. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43545. * * 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
  43546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43547. * @param name defines the name of the mesh
  43548. * @param options defines the options used to create the mesh
  43549. * @param scene defines the hosting scene
  43550. * @returns the plane mesh
  43551. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43552. */
  43553. static CreatePlane(name: string, options: {
  43554. size?: number;
  43555. width?: number;
  43556. height?: number;
  43557. sideOrientation?: number;
  43558. frontUVs?: Vector4;
  43559. backUVs?: Vector4;
  43560. updatable?: boolean;
  43561. sourcePlane?: Plane;
  43562. }, scene?: Nullable<Scene>): Mesh;
  43563. }
  43564. }
  43565. declare module BABYLON {
  43566. /**
  43567. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43568. */
  43569. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43570. private static _AnyMouseID;
  43571. /**
  43572. * Abstract mesh the behavior is set on
  43573. */
  43574. attachedNode: AbstractMesh;
  43575. private _dragPlane;
  43576. private _scene;
  43577. private _pointerObserver;
  43578. private _beforeRenderObserver;
  43579. private static _planeScene;
  43580. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43581. /**
  43582. * 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)
  43583. */
  43584. maxDragAngle: number;
  43585. /**
  43586. * @hidden
  43587. */
  43588. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43589. /**
  43590. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43591. */
  43592. currentDraggingPointerID: number;
  43593. /**
  43594. * The last position where the pointer hit the drag plane in world space
  43595. */
  43596. lastDragPosition: Vector3;
  43597. /**
  43598. * If the behavior is currently in a dragging state
  43599. */
  43600. dragging: boolean;
  43601. /**
  43602. * 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)
  43603. */
  43604. dragDeltaRatio: number;
  43605. /**
  43606. * If the drag plane orientation should be updated during the dragging (Default: true)
  43607. */
  43608. updateDragPlane: boolean;
  43609. private _debugMode;
  43610. private _moving;
  43611. /**
  43612. * Fires each time the attached mesh is dragged with the pointer
  43613. * * delta between last drag position and current drag position in world space
  43614. * * dragDistance along the drag axis
  43615. * * dragPlaneNormal normal of the current drag plane used during the drag
  43616. * * dragPlanePoint in world space where the drag intersects the drag plane
  43617. */
  43618. onDragObservable: Observable<{
  43619. delta: Vector3;
  43620. dragPlanePoint: Vector3;
  43621. dragPlaneNormal: Vector3;
  43622. dragDistance: number;
  43623. pointerId: number;
  43624. }>;
  43625. /**
  43626. * Fires each time a drag begins (eg. mouse down on mesh)
  43627. */
  43628. onDragStartObservable: Observable<{
  43629. dragPlanePoint: Vector3;
  43630. pointerId: number;
  43631. }>;
  43632. /**
  43633. * Fires each time a drag ends (eg. mouse release after drag)
  43634. */
  43635. onDragEndObservable: Observable<{
  43636. dragPlanePoint: Vector3;
  43637. pointerId: number;
  43638. }>;
  43639. /**
  43640. * If the attached mesh should be moved when dragged
  43641. */
  43642. moveAttached: boolean;
  43643. /**
  43644. * If the drag behavior will react to drag events (Default: true)
  43645. */
  43646. enabled: boolean;
  43647. /**
  43648. * If pointer events should start and release the drag (Default: true)
  43649. */
  43650. startAndReleaseDragOnPointerEvents: boolean;
  43651. /**
  43652. * If camera controls should be detached during the drag
  43653. */
  43654. detachCameraControls: boolean;
  43655. /**
  43656. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43657. */
  43658. useObjectOrientationForDragging: boolean;
  43659. private _options;
  43660. /**
  43661. * Gets the options used by the behavior
  43662. */
  43663. get options(): {
  43664. dragAxis?: Vector3;
  43665. dragPlaneNormal?: Vector3;
  43666. };
  43667. /**
  43668. * Sets the options used by the behavior
  43669. */
  43670. set options(options: {
  43671. dragAxis?: Vector3;
  43672. dragPlaneNormal?: Vector3;
  43673. });
  43674. /**
  43675. * Creates a pointer drag behavior that can be attached to a mesh
  43676. * @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)
  43677. */
  43678. constructor(options?: {
  43679. dragAxis?: Vector3;
  43680. dragPlaneNormal?: Vector3;
  43681. });
  43682. /**
  43683. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43684. */
  43685. validateDrag: (targetPosition: Vector3) => boolean;
  43686. /**
  43687. * The name of the behavior
  43688. */
  43689. get name(): string;
  43690. /**
  43691. * Initializes the behavior
  43692. */
  43693. init(): void;
  43694. private _tmpVector;
  43695. private _alternatePickedPoint;
  43696. private _worldDragAxis;
  43697. private _targetPosition;
  43698. private _attachedElement;
  43699. /**
  43700. * Attaches the drag behavior the passed in mesh
  43701. * @param ownerNode The mesh that will be dragged around once attached
  43702. * @param predicate Predicate to use for pick filtering
  43703. */
  43704. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43705. /**
  43706. * Force relase the drag action by code.
  43707. */
  43708. releaseDrag(): void;
  43709. private _startDragRay;
  43710. private _lastPointerRay;
  43711. /**
  43712. * Simulates the start of a pointer drag event on the behavior
  43713. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43714. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43715. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43716. */
  43717. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43718. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43719. private _dragDelta;
  43720. protected _moveDrag(ray: Ray): void;
  43721. private _pickWithRayOnDragPlane;
  43722. private _pointA;
  43723. private _pointC;
  43724. private _localAxis;
  43725. private _lookAt;
  43726. private _updateDragPlanePosition;
  43727. /**
  43728. * Detaches the behavior from the mesh
  43729. */
  43730. detach(): void;
  43731. }
  43732. }
  43733. declare module BABYLON {
  43734. /**
  43735. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43736. */
  43737. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43738. private _dragBehaviorA;
  43739. private _dragBehaviorB;
  43740. private _startDistance;
  43741. private _initialScale;
  43742. private _targetScale;
  43743. private _ownerNode;
  43744. private _sceneRenderObserver;
  43745. /**
  43746. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43747. */
  43748. constructor();
  43749. /**
  43750. * The name of the behavior
  43751. */
  43752. get name(): string;
  43753. /**
  43754. * Initializes the behavior
  43755. */
  43756. init(): void;
  43757. private _getCurrentDistance;
  43758. /**
  43759. * Attaches the scale behavior the passed in mesh
  43760. * @param ownerNode The mesh that will be scaled around once attached
  43761. */
  43762. attach(ownerNode: Mesh): void;
  43763. /**
  43764. * Detaches the behavior from the mesh
  43765. */
  43766. detach(): void;
  43767. }
  43768. }
  43769. declare module BABYLON {
  43770. /**
  43771. * 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
  43772. */
  43773. export class SixDofDragBehavior implements Behavior<Mesh> {
  43774. private static _virtualScene;
  43775. private _ownerNode;
  43776. private _sceneRenderObserver;
  43777. private _scene;
  43778. private _targetPosition;
  43779. private _virtualOriginMesh;
  43780. private _virtualDragMesh;
  43781. private _pointerObserver;
  43782. private _moving;
  43783. private _startingOrientation;
  43784. private _attachedElement;
  43785. /**
  43786. * 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)
  43787. */
  43788. private zDragFactor;
  43789. /**
  43790. * If the object should rotate to face the drag origin
  43791. */
  43792. rotateDraggedObject: boolean;
  43793. /**
  43794. * If the behavior is currently in a dragging state
  43795. */
  43796. dragging: boolean;
  43797. /**
  43798. * 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)
  43799. */
  43800. dragDeltaRatio: number;
  43801. /**
  43802. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43803. */
  43804. currentDraggingPointerID: number;
  43805. /**
  43806. * If camera controls should be detached during the drag
  43807. */
  43808. detachCameraControls: boolean;
  43809. /**
  43810. * Fires each time a drag starts
  43811. */
  43812. onDragStartObservable: Observable<{}>;
  43813. /**
  43814. * Fires each time a drag ends (eg. mouse release after drag)
  43815. */
  43816. onDragEndObservable: Observable<{}>;
  43817. /**
  43818. * 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
  43819. */
  43820. constructor();
  43821. /**
  43822. * The name of the behavior
  43823. */
  43824. get name(): string;
  43825. /**
  43826. * Initializes the behavior
  43827. */
  43828. init(): void;
  43829. /**
  43830. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43831. */
  43832. private get _pointerCamera();
  43833. /**
  43834. * Attaches the scale behavior the passed in mesh
  43835. * @param ownerNode The mesh that will be scaled around once attached
  43836. */
  43837. attach(ownerNode: Mesh): void;
  43838. /**
  43839. * Detaches the behavior from the mesh
  43840. */
  43841. detach(): void;
  43842. }
  43843. }
  43844. declare module BABYLON {
  43845. /**
  43846. * Class used to apply inverse kinematics to bones
  43847. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43848. */
  43849. export class BoneIKController {
  43850. private static _tmpVecs;
  43851. private static _tmpQuat;
  43852. private static _tmpMats;
  43853. /**
  43854. * Gets or sets the target mesh
  43855. */
  43856. targetMesh: AbstractMesh;
  43857. /** Gets or sets the mesh used as pole */
  43858. poleTargetMesh: AbstractMesh;
  43859. /**
  43860. * Gets or sets the bone used as pole
  43861. */
  43862. poleTargetBone: Nullable<Bone>;
  43863. /**
  43864. * Gets or sets the target position
  43865. */
  43866. targetPosition: Vector3;
  43867. /**
  43868. * Gets or sets the pole target position
  43869. */
  43870. poleTargetPosition: Vector3;
  43871. /**
  43872. * Gets or sets the pole target local offset
  43873. */
  43874. poleTargetLocalOffset: Vector3;
  43875. /**
  43876. * Gets or sets the pole angle
  43877. */
  43878. poleAngle: number;
  43879. /**
  43880. * Gets or sets the mesh associated with the controller
  43881. */
  43882. mesh: AbstractMesh;
  43883. /**
  43884. * 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)
  43885. */
  43886. slerpAmount: number;
  43887. private _bone1Quat;
  43888. private _bone1Mat;
  43889. private _bone2Ang;
  43890. private _bone1;
  43891. private _bone2;
  43892. private _bone1Length;
  43893. private _bone2Length;
  43894. private _maxAngle;
  43895. private _maxReach;
  43896. private _rightHandedSystem;
  43897. private _bendAxis;
  43898. private _slerping;
  43899. private _adjustRoll;
  43900. /**
  43901. * Gets or sets maximum allowed angle
  43902. */
  43903. get maxAngle(): number;
  43904. set maxAngle(value: number);
  43905. /**
  43906. * Creates a new BoneIKController
  43907. * @param mesh defines the mesh to control
  43908. * @param bone defines the bone to control
  43909. * @param options defines options to set up the controller
  43910. */
  43911. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  43912. targetMesh?: AbstractMesh;
  43913. poleTargetMesh?: AbstractMesh;
  43914. poleTargetBone?: Bone;
  43915. poleTargetLocalOffset?: Vector3;
  43916. poleAngle?: number;
  43917. bendAxis?: Vector3;
  43918. maxAngle?: number;
  43919. slerpAmount?: number;
  43920. });
  43921. private _setMaxAngle;
  43922. /**
  43923. * Force the controller to update the bones
  43924. */
  43925. update(): void;
  43926. }
  43927. }
  43928. declare module BABYLON {
  43929. /**
  43930. * Class used to make a bone look toward a point in space
  43931. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  43932. */
  43933. export class BoneLookController {
  43934. private static _tmpVecs;
  43935. private static _tmpQuat;
  43936. private static _tmpMats;
  43937. /**
  43938. * The target Vector3 that the bone will look at
  43939. */
  43940. target: Vector3;
  43941. /**
  43942. * The mesh that the bone is attached to
  43943. */
  43944. mesh: AbstractMesh;
  43945. /**
  43946. * The bone that will be looking to the target
  43947. */
  43948. bone: Bone;
  43949. /**
  43950. * The up axis of the coordinate system that is used when the bone is rotated
  43951. */
  43952. upAxis: Vector3;
  43953. /**
  43954. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  43955. */
  43956. upAxisSpace: Space;
  43957. /**
  43958. * Used to make an adjustment to the yaw of the bone
  43959. */
  43960. adjustYaw: number;
  43961. /**
  43962. * Used to make an adjustment to the pitch of the bone
  43963. */
  43964. adjustPitch: number;
  43965. /**
  43966. * Used to make an adjustment to the roll of the bone
  43967. */
  43968. adjustRoll: number;
  43969. /**
  43970. * 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)
  43971. */
  43972. slerpAmount: number;
  43973. private _minYaw;
  43974. private _maxYaw;
  43975. private _minPitch;
  43976. private _maxPitch;
  43977. private _minYawSin;
  43978. private _minYawCos;
  43979. private _maxYawSin;
  43980. private _maxYawCos;
  43981. private _midYawConstraint;
  43982. private _minPitchTan;
  43983. private _maxPitchTan;
  43984. private _boneQuat;
  43985. private _slerping;
  43986. private _transformYawPitch;
  43987. private _transformYawPitchInv;
  43988. private _firstFrameSkipped;
  43989. private _yawRange;
  43990. private _fowardAxis;
  43991. /**
  43992. * Gets or sets the minimum yaw angle that the bone can look to
  43993. */
  43994. get minYaw(): number;
  43995. set minYaw(value: number);
  43996. /**
  43997. * Gets or sets the maximum yaw angle that the bone can look to
  43998. */
  43999. get maxYaw(): number;
  44000. set maxYaw(value: number);
  44001. /**
  44002. * Gets or sets the minimum pitch angle that the bone can look to
  44003. */
  44004. get minPitch(): number;
  44005. set minPitch(value: number);
  44006. /**
  44007. * Gets or sets the maximum pitch angle that the bone can look to
  44008. */
  44009. get maxPitch(): number;
  44010. set maxPitch(value: number);
  44011. /**
  44012. * Create a BoneLookController
  44013. * @param mesh the mesh that the bone belongs to
  44014. * @param bone the bone that will be looking to the target
  44015. * @param target the target Vector3 to look at
  44016. * @param options optional settings:
  44017. * * maxYaw: the maximum angle the bone will yaw to
  44018. * * minYaw: the minimum angle the bone will yaw to
  44019. * * maxPitch: the maximum angle the bone will pitch to
  44020. * * minPitch: the minimum angle the bone will yaw to
  44021. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  44022. * * upAxis: the up axis of the coordinate system
  44023. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  44024. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  44025. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  44026. * * adjustYaw: used to make an adjustment to the yaw of the bone
  44027. * * adjustPitch: used to make an adjustment to the pitch of the bone
  44028. * * adjustRoll: used to make an adjustment to the roll of the bone
  44029. **/
  44030. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  44031. maxYaw?: number;
  44032. minYaw?: number;
  44033. maxPitch?: number;
  44034. minPitch?: number;
  44035. slerpAmount?: number;
  44036. upAxis?: Vector3;
  44037. upAxisSpace?: Space;
  44038. yawAxis?: Vector3;
  44039. pitchAxis?: Vector3;
  44040. adjustYaw?: number;
  44041. adjustPitch?: number;
  44042. adjustRoll?: number;
  44043. });
  44044. /**
  44045. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  44046. */
  44047. update(): void;
  44048. private _getAngleDiff;
  44049. private _getAngleBetween;
  44050. private _isAngleBetween;
  44051. }
  44052. }
  44053. declare module BABYLON {
  44054. /**
  44055. * Manage the gamepad inputs to control an arc rotate camera.
  44056. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44057. */
  44058. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  44059. /**
  44060. * Defines the camera the input is attached to.
  44061. */
  44062. camera: ArcRotateCamera;
  44063. /**
  44064. * Defines the gamepad the input is gathering event from.
  44065. */
  44066. gamepad: Nullable<Gamepad>;
  44067. /**
  44068. * Defines the gamepad rotation sensiblity.
  44069. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44070. */
  44071. gamepadRotationSensibility: number;
  44072. /**
  44073. * Defines the gamepad move sensiblity.
  44074. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44075. */
  44076. gamepadMoveSensibility: number;
  44077. private _yAxisScale;
  44078. /**
  44079. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44080. */
  44081. get invertYAxis(): boolean;
  44082. set invertYAxis(value: boolean);
  44083. private _onGamepadConnectedObserver;
  44084. private _onGamepadDisconnectedObserver;
  44085. /**
  44086. * Attach the input controls to a specific dom element to get the input from.
  44087. * @param element Defines the element the controls should be listened from
  44088. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44089. */
  44090. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44091. /**
  44092. * Detach the current controls from the specified dom element.
  44093. * @param element Defines the element to stop listening the inputs from
  44094. */
  44095. detachControl(element: Nullable<HTMLElement>): void;
  44096. /**
  44097. * Update the current camera state depending on the inputs that have been used this frame.
  44098. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44099. */
  44100. checkInputs(): void;
  44101. /**
  44102. * Gets the class name of the current intput.
  44103. * @returns the class name
  44104. */
  44105. getClassName(): string;
  44106. /**
  44107. * Get the friendly name associated with the input class.
  44108. * @returns the input friendly name
  44109. */
  44110. getSimpleName(): string;
  44111. }
  44112. }
  44113. declare module BABYLON {
  44114. interface ArcRotateCameraInputsManager {
  44115. /**
  44116. * Add orientation input support to the input manager.
  44117. * @returns the current input manager
  44118. */
  44119. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44120. }
  44121. /**
  44122. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44123. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44124. */
  44125. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44126. /**
  44127. * Defines the camera the input is attached to.
  44128. */
  44129. camera: ArcRotateCamera;
  44130. /**
  44131. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44132. */
  44133. alphaCorrection: number;
  44134. /**
  44135. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44136. */
  44137. gammaCorrection: number;
  44138. private _alpha;
  44139. private _gamma;
  44140. private _dirty;
  44141. private _deviceOrientationHandler;
  44142. /**
  44143. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44144. */
  44145. constructor();
  44146. /**
  44147. * Attach the input controls to a specific dom element to get the input from.
  44148. * @param element Defines the element the controls should be listened from
  44149. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44150. */
  44151. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44152. /** @hidden */
  44153. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44154. /**
  44155. * Update the current camera state depending on the inputs that have been used this frame.
  44156. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44157. */
  44158. checkInputs(): void;
  44159. /**
  44160. * Detach the current controls from the specified dom element.
  44161. * @param element Defines the element to stop listening the inputs from
  44162. */
  44163. detachControl(element: Nullable<HTMLElement>): void;
  44164. /**
  44165. * Gets the class name of the current intput.
  44166. * @returns the class name
  44167. */
  44168. getClassName(): string;
  44169. /**
  44170. * Get the friendly name associated with the input class.
  44171. * @returns the input friendly name
  44172. */
  44173. getSimpleName(): string;
  44174. }
  44175. }
  44176. declare module BABYLON {
  44177. /**
  44178. * Listen to mouse events to control the camera.
  44179. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44180. */
  44181. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44182. /**
  44183. * Defines the camera the input is attached to.
  44184. */
  44185. camera: FlyCamera;
  44186. /**
  44187. * Defines if touch is enabled. (Default is true.)
  44188. */
  44189. touchEnabled: boolean;
  44190. /**
  44191. * Defines the buttons associated with the input to handle camera rotation.
  44192. */
  44193. buttons: number[];
  44194. /**
  44195. * Assign buttons for Yaw control.
  44196. */
  44197. buttonsYaw: number[];
  44198. /**
  44199. * Assign buttons for Pitch control.
  44200. */
  44201. buttonsPitch: number[];
  44202. /**
  44203. * Assign buttons for Roll control.
  44204. */
  44205. buttonsRoll: number[];
  44206. /**
  44207. * Detect if any button is being pressed while mouse is moved.
  44208. * -1 = Mouse locked.
  44209. * 0 = Left button.
  44210. * 1 = Middle Button.
  44211. * 2 = Right Button.
  44212. */
  44213. activeButton: number;
  44214. /**
  44215. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44216. * Higher values reduce its sensitivity.
  44217. */
  44218. angularSensibility: number;
  44219. private _mousemoveCallback;
  44220. private _observer;
  44221. private _rollObserver;
  44222. private previousPosition;
  44223. private noPreventDefault;
  44224. private element;
  44225. /**
  44226. * Listen to mouse events to control the camera.
  44227. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44228. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44229. */
  44230. constructor(touchEnabled?: boolean);
  44231. /**
  44232. * Attach the mouse control to the HTML DOM element.
  44233. * @param element Defines the element that listens to the input events.
  44234. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44235. */
  44236. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44237. /**
  44238. * Detach the current controls from the specified dom element.
  44239. * @param element Defines the element to stop listening the inputs from
  44240. */
  44241. detachControl(element: Nullable<HTMLElement>): void;
  44242. /**
  44243. * Gets the class name of the current input.
  44244. * @returns the class name.
  44245. */
  44246. getClassName(): string;
  44247. /**
  44248. * Get the friendly name associated with the input class.
  44249. * @returns the input's friendly name.
  44250. */
  44251. getSimpleName(): string;
  44252. private _pointerInput;
  44253. private _onMouseMove;
  44254. /**
  44255. * Rotate camera by mouse offset.
  44256. */
  44257. private rotateCamera;
  44258. }
  44259. }
  44260. declare module BABYLON {
  44261. /**
  44262. * Default Inputs manager for the FlyCamera.
  44263. * It groups all the default supported inputs for ease of use.
  44264. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44265. */
  44266. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44267. /**
  44268. * Instantiates a new FlyCameraInputsManager.
  44269. * @param camera Defines the camera the inputs belong to.
  44270. */
  44271. constructor(camera: FlyCamera);
  44272. /**
  44273. * Add keyboard input support to the input manager.
  44274. * @returns the new FlyCameraKeyboardMoveInput().
  44275. */
  44276. addKeyboard(): FlyCameraInputsManager;
  44277. /**
  44278. * Add mouse input support to the input manager.
  44279. * @param touchEnabled Enable touch screen support.
  44280. * @returns the new FlyCameraMouseInput().
  44281. */
  44282. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44283. }
  44284. }
  44285. declare module BABYLON {
  44286. /**
  44287. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44288. * such as in a 3D Space Shooter or a Flight Simulator.
  44289. */
  44290. export class FlyCamera extends TargetCamera {
  44291. /**
  44292. * Define the collision ellipsoid of the camera.
  44293. * This is helpful for simulating a camera body, like a player's body.
  44294. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44295. */
  44296. ellipsoid: Vector3;
  44297. /**
  44298. * Define an offset for the position of the ellipsoid around the camera.
  44299. * This can be helpful if the camera is attached away from the player's body center,
  44300. * such as at its head.
  44301. */
  44302. ellipsoidOffset: Vector3;
  44303. /**
  44304. * Enable or disable collisions of the camera with the rest of the scene objects.
  44305. */
  44306. checkCollisions: boolean;
  44307. /**
  44308. * Enable or disable gravity on the camera.
  44309. */
  44310. applyGravity: boolean;
  44311. /**
  44312. * Define the current direction the camera is moving to.
  44313. */
  44314. cameraDirection: Vector3;
  44315. /**
  44316. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44317. * This overrides and empties cameraRotation.
  44318. */
  44319. rotationQuaternion: Quaternion;
  44320. /**
  44321. * Track Roll to maintain the wanted Rolling when looking around.
  44322. */
  44323. _trackRoll: number;
  44324. /**
  44325. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44326. */
  44327. rollCorrect: number;
  44328. /**
  44329. * Mimic a banked turn, Rolling the camera when Yawing.
  44330. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44331. */
  44332. bankedTurn: boolean;
  44333. /**
  44334. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44335. */
  44336. bankedTurnLimit: number;
  44337. /**
  44338. * Value of 0 disables the banked Roll.
  44339. * Value of 1 is equal to the Yaw angle in radians.
  44340. */
  44341. bankedTurnMultiplier: number;
  44342. /**
  44343. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44344. */
  44345. inputs: FlyCameraInputsManager;
  44346. /**
  44347. * Gets the input sensibility for mouse input.
  44348. * Higher values reduce sensitivity.
  44349. */
  44350. get angularSensibility(): number;
  44351. /**
  44352. * Sets the input sensibility for a mouse input.
  44353. * Higher values reduce sensitivity.
  44354. */
  44355. set angularSensibility(value: number);
  44356. /**
  44357. * Get the keys for camera movement forward.
  44358. */
  44359. get keysForward(): number[];
  44360. /**
  44361. * Set the keys for camera movement forward.
  44362. */
  44363. set keysForward(value: number[]);
  44364. /**
  44365. * Get the keys for camera movement backward.
  44366. */
  44367. get keysBackward(): number[];
  44368. set keysBackward(value: number[]);
  44369. /**
  44370. * Get the keys for camera movement up.
  44371. */
  44372. get keysUp(): number[];
  44373. /**
  44374. * Set the keys for camera movement up.
  44375. */
  44376. set keysUp(value: number[]);
  44377. /**
  44378. * Get the keys for camera movement down.
  44379. */
  44380. get keysDown(): number[];
  44381. /**
  44382. * Set the keys for camera movement down.
  44383. */
  44384. set keysDown(value: number[]);
  44385. /**
  44386. * Get the keys for camera movement left.
  44387. */
  44388. get keysLeft(): number[];
  44389. /**
  44390. * Set the keys for camera movement left.
  44391. */
  44392. set keysLeft(value: number[]);
  44393. /**
  44394. * Set the keys for camera movement right.
  44395. */
  44396. get keysRight(): number[];
  44397. /**
  44398. * Set the keys for camera movement right.
  44399. */
  44400. set keysRight(value: number[]);
  44401. /**
  44402. * Event raised when the camera collides with a mesh in the scene.
  44403. */
  44404. onCollide: (collidedMesh: AbstractMesh) => void;
  44405. private _collider;
  44406. private _needMoveForGravity;
  44407. private _oldPosition;
  44408. private _diffPosition;
  44409. private _newPosition;
  44410. /** @hidden */
  44411. _localDirection: Vector3;
  44412. /** @hidden */
  44413. _transformedDirection: Vector3;
  44414. /**
  44415. * Instantiates a FlyCamera.
  44416. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44417. * such as in a 3D Space Shooter or a Flight Simulator.
  44418. * @param name Define the name of the camera in the scene.
  44419. * @param position Define the starting position of the camera in the scene.
  44420. * @param scene Define the scene the camera belongs to.
  44421. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44422. */
  44423. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44424. /**
  44425. * Attach a control to the HTML DOM element.
  44426. * @param element Defines the element that listens to the input events.
  44427. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44428. */
  44429. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44430. /**
  44431. * Detach a control from the HTML DOM element.
  44432. * The camera will stop reacting to that input.
  44433. * @param element Defines the element that listens to the input events.
  44434. */
  44435. detachControl(element: HTMLElement): void;
  44436. private _collisionMask;
  44437. /**
  44438. * Get the mask that the camera ignores in collision events.
  44439. */
  44440. get collisionMask(): number;
  44441. /**
  44442. * Set the mask that the camera ignores in collision events.
  44443. */
  44444. set collisionMask(mask: number);
  44445. /** @hidden */
  44446. _collideWithWorld(displacement: Vector3): void;
  44447. /** @hidden */
  44448. private _onCollisionPositionChange;
  44449. /** @hidden */
  44450. _checkInputs(): void;
  44451. /** @hidden */
  44452. _decideIfNeedsToMove(): boolean;
  44453. /** @hidden */
  44454. _updatePosition(): void;
  44455. /**
  44456. * Restore the Roll to its target value at the rate specified.
  44457. * @param rate - Higher means slower restoring.
  44458. * @hidden
  44459. */
  44460. restoreRoll(rate: number): void;
  44461. /**
  44462. * Destroy the camera and release the current resources held by it.
  44463. */
  44464. dispose(): void;
  44465. /**
  44466. * Get the current object class name.
  44467. * @returns the class name.
  44468. */
  44469. getClassName(): string;
  44470. }
  44471. }
  44472. declare module BABYLON {
  44473. /**
  44474. * Listen to keyboard events to control the camera.
  44475. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44476. */
  44477. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44478. /**
  44479. * Defines the camera the input is attached to.
  44480. */
  44481. camera: FlyCamera;
  44482. /**
  44483. * The list of keyboard keys used to control the forward move of the camera.
  44484. */
  44485. keysForward: number[];
  44486. /**
  44487. * The list of keyboard keys used to control the backward move of the camera.
  44488. */
  44489. keysBackward: number[];
  44490. /**
  44491. * The list of keyboard keys used to control the forward move of the camera.
  44492. */
  44493. keysUp: number[];
  44494. /**
  44495. * The list of keyboard keys used to control the backward move of the camera.
  44496. */
  44497. keysDown: number[];
  44498. /**
  44499. * The list of keyboard keys used to control the right strafe move of the camera.
  44500. */
  44501. keysRight: number[];
  44502. /**
  44503. * The list of keyboard keys used to control the left strafe move of the camera.
  44504. */
  44505. keysLeft: number[];
  44506. private _keys;
  44507. private _onCanvasBlurObserver;
  44508. private _onKeyboardObserver;
  44509. private _engine;
  44510. private _scene;
  44511. /**
  44512. * Attach the input controls to a specific dom element to get the input from.
  44513. * @param element Defines the element the controls should be listened from
  44514. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44515. */
  44516. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44517. /**
  44518. * Detach the current controls from the specified dom element.
  44519. * @param element Defines the element to stop listening the inputs from
  44520. */
  44521. detachControl(element: Nullable<HTMLElement>): void;
  44522. /**
  44523. * Gets the class name of the current intput.
  44524. * @returns the class name
  44525. */
  44526. getClassName(): string;
  44527. /** @hidden */
  44528. _onLostFocus(e: FocusEvent): void;
  44529. /**
  44530. * Get the friendly name associated with the input class.
  44531. * @returns the input friendly name
  44532. */
  44533. getSimpleName(): string;
  44534. /**
  44535. * Update the current camera state depending on the inputs that have been used this frame.
  44536. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44537. */
  44538. checkInputs(): void;
  44539. }
  44540. }
  44541. declare module BABYLON {
  44542. /**
  44543. * Manage the mouse wheel inputs to control a follow camera.
  44544. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44545. */
  44546. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44547. /**
  44548. * Defines the camera the input is attached to.
  44549. */
  44550. camera: FollowCamera;
  44551. /**
  44552. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44553. */
  44554. axisControlRadius: boolean;
  44555. /**
  44556. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44557. */
  44558. axisControlHeight: boolean;
  44559. /**
  44560. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44561. */
  44562. axisControlRotation: boolean;
  44563. /**
  44564. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44565. * relation to mouseWheel events.
  44566. */
  44567. wheelPrecision: number;
  44568. /**
  44569. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44570. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44571. */
  44572. wheelDeltaPercentage: number;
  44573. private _wheel;
  44574. private _observer;
  44575. /**
  44576. * Attach the input controls to a specific dom element to get the input from.
  44577. * @param element Defines the element the controls should be listened from
  44578. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44579. */
  44580. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44581. /**
  44582. * Detach the current controls from the specified dom element.
  44583. * @param element Defines the element to stop listening the inputs from
  44584. */
  44585. detachControl(element: Nullable<HTMLElement>): void;
  44586. /**
  44587. * Gets the class name of the current intput.
  44588. * @returns the class name
  44589. */
  44590. getClassName(): string;
  44591. /**
  44592. * Get the friendly name associated with the input class.
  44593. * @returns the input friendly name
  44594. */
  44595. getSimpleName(): string;
  44596. }
  44597. }
  44598. declare module BABYLON {
  44599. /**
  44600. * Manage the pointers inputs to control an follow camera.
  44601. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44602. */
  44603. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44604. /**
  44605. * Defines the camera the input is attached to.
  44606. */
  44607. camera: FollowCamera;
  44608. /**
  44609. * Gets the class name of the current input.
  44610. * @returns the class name
  44611. */
  44612. getClassName(): string;
  44613. /**
  44614. * Defines the pointer angular sensibility along the X axis or how fast is
  44615. * the camera rotating.
  44616. * A negative number will reverse the axis direction.
  44617. */
  44618. angularSensibilityX: number;
  44619. /**
  44620. * Defines the pointer angular sensibility along the Y axis or how fast is
  44621. * the camera rotating.
  44622. * A negative number will reverse the axis direction.
  44623. */
  44624. angularSensibilityY: number;
  44625. /**
  44626. * Defines the pointer pinch precision or how fast is the camera zooming.
  44627. * A negative number will reverse the axis direction.
  44628. */
  44629. pinchPrecision: number;
  44630. /**
  44631. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44632. * from 0.
  44633. * It defines the percentage of current camera.radius to use as delta when
  44634. * pinch zoom is used.
  44635. */
  44636. pinchDeltaPercentage: number;
  44637. /**
  44638. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44639. */
  44640. axisXControlRadius: boolean;
  44641. /**
  44642. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44643. */
  44644. axisXControlHeight: boolean;
  44645. /**
  44646. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44647. */
  44648. axisXControlRotation: boolean;
  44649. /**
  44650. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44651. */
  44652. axisYControlRadius: boolean;
  44653. /**
  44654. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44655. */
  44656. axisYControlHeight: boolean;
  44657. /**
  44658. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44659. */
  44660. axisYControlRotation: boolean;
  44661. /**
  44662. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44663. */
  44664. axisPinchControlRadius: boolean;
  44665. /**
  44666. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44667. */
  44668. axisPinchControlHeight: boolean;
  44669. /**
  44670. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44671. */
  44672. axisPinchControlRotation: boolean;
  44673. /**
  44674. * Log error messages if basic misconfiguration has occurred.
  44675. */
  44676. warningEnable: boolean;
  44677. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44678. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44679. private _warningCounter;
  44680. private _warning;
  44681. }
  44682. }
  44683. declare module BABYLON {
  44684. /**
  44685. * Default Inputs manager for the FollowCamera.
  44686. * It groups all the default supported inputs for ease of use.
  44687. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44688. */
  44689. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44690. /**
  44691. * Instantiates a new FollowCameraInputsManager.
  44692. * @param camera Defines the camera the inputs belong to
  44693. */
  44694. constructor(camera: FollowCamera);
  44695. /**
  44696. * Add keyboard input support to the input manager.
  44697. * @returns the current input manager
  44698. */
  44699. addKeyboard(): FollowCameraInputsManager;
  44700. /**
  44701. * Add mouse wheel input support to the input manager.
  44702. * @returns the current input manager
  44703. */
  44704. addMouseWheel(): FollowCameraInputsManager;
  44705. /**
  44706. * Add pointers input support to the input manager.
  44707. * @returns the current input manager
  44708. */
  44709. addPointers(): FollowCameraInputsManager;
  44710. /**
  44711. * Add orientation input support to the input manager.
  44712. * @returns the current input manager
  44713. */
  44714. addVRDeviceOrientation(): FollowCameraInputsManager;
  44715. }
  44716. }
  44717. declare module BABYLON {
  44718. /**
  44719. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44720. * an arc rotate version arcFollowCamera are available.
  44721. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44722. */
  44723. export class FollowCamera extends TargetCamera {
  44724. /**
  44725. * Distance the follow camera should follow an object at
  44726. */
  44727. radius: number;
  44728. /**
  44729. * Minimum allowed distance of the camera to the axis of rotation
  44730. * (The camera can not get closer).
  44731. * This can help limiting how the Camera is able to move in the scene.
  44732. */
  44733. lowerRadiusLimit: Nullable<number>;
  44734. /**
  44735. * Maximum allowed distance of the camera to the axis of rotation
  44736. * (The camera can not get further).
  44737. * This can help limiting how the Camera is able to move in the scene.
  44738. */
  44739. upperRadiusLimit: Nullable<number>;
  44740. /**
  44741. * Define a rotation offset between the camera and the object it follows
  44742. */
  44743. rotationOffset: number;
  44744. /**
  44745. * Minimum allowed angle to camera position relative to target object.
  44746. * This can help limiting how the Camera is able to move in the scene.
  44747. */
  44748. lowerRotationOffsetLimit: Nullable<number>;
  44749. /**
  44750. * Maximum allowed angle to camera position relative to target object.
  44751. * This can help limiting how the Camera is able to move in the scene.
  44752. */
  44753. upperRotationOffsetLimit: Nullable<number>;
  44754. /**
  44755. * Define a height offset between the camera and the object it follows.
  44756. * It can help following an object from the top (like a car chaing a plane)
  44757. */
  44758. heightOffset: number;
  44759. /**
  44760. * Minimum allowed height of camera position relative to target object.
  44761. * This can help limiting how the Camera is able to move in the scene.
  44762. */
  44763. lowerHeightOffsetLimit: Nullable<number>;
  44764. /**
  44765. * Maximum allowed height of camera position relative to target object.
  44766. * This can help limiting how the Camera is able to move in the scene.
  44767. */
  44768. upperHeightOffsetLimit: Nullable<number>;
  44769. /**
  44770. * Define how fast the camera can accelerate to follow it s target.
  44771. */
  44772. cameraAcceleration: number;
  44773. /**
  44774. * Define the speed limit of the camera following an object.
  44775. */
  44776. maxCameraSpeed: number;
  44777. /**
  44778. * Define the target of the camera.
  44779. */
  44780. lockedTarget: Nullable<AbstractMesh>;
  44781. /**
  44782. * Defines the input associated with the camera.
  44783. */
  44784. inputs: FollowCameraInputsManager;
  44785. /**
  44786. * Instantiates the follow camera.
  44787. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44788. * @param name Define the name of the camera in the scene
  44789. * @param position Define the position of the camera
  44790. * @param scene Define the scene the camera belong to
  44791. * @param lockedTarget Define the target of the camera
  44792. */
  44793. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44794. private _follow;
  44795. /**
  44796. * Attached controls to the current camera.
  44797. * @param element Defines the element the controls should be listened from
  44798. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44799. */
  44800. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44801. /**
  44802. * Detach the current controls from the camera.
  44803. * The camera will stop reacting to inputs.
  44804. * @param element Defines the element to stop listening the inputs from
  44805. */
  44806. detachControl(element: HTMLElement): void;
  44807. /** @hidden */
  44808. _checkInputs(): void;
  44809. private _checkLimits;
  44810. /**
  44811. * Gets the camera class name.
  44812. * @returns the class name
  44813. */
  44814. getClassName(): string;
  44815. }
  44816. /**
  44817. * Arc Rotate version of the follow camera.
  44818. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44819. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44820. */
  44821. export class ArcFollowCamera extends TargetCamera {
  44822. /** The longitudinal angle of the camera */
  44823. alpha: number;
  44824. /** The latitudinal angle of the camera */
  44825. beta: number;
  44826. /** The radius of the camera from its target */
  44827. radius: number;
  44828. private _cartesianCoordinates;
  44829. /** Define the camera target (the mesh it should follow) */
  44830. private _meshTarget;
  44831. /**
  44832. * Instantiates a new ArcFollowCamera
  44833. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44834. * @param name Define the name of the camera
  44835. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44836. * @param beta Define the rotation angle of the camera around the elevation axis
  44837. * @param radius Define the radius of the camera from its target point
  44838. * @param target Define the target of the camera
  44839. * @param scene Define the scene the camera belongs to
  44840. */
  44841. constructor(name: string,
  44842. /** The longitudinal angle of the camera */
  44843. alpha: number,
  44844. /** The latitudinal angle of the camera */
  44845. beta: number,
  44846. /** The radius of the camera from its target */
  44847. radius: number,
  44848. /** Define the camera target (the mesh it should follow) */
  44849. target: Nullable<AbstractMesh>, scene: Scene);
  44850. private _follow;
  44851. /** @hidden */
  44852. _checkInputs(): void;
  44853. /**
  44854. * Returns the class name of the object.
  44855. * It is mostly used internally for serialization purposes.
  44856. */
  44857. getClassName(): string;
  44858. }
  44859. }
  44860. declare module BABYLON {
  44861. /**
  44862. * Manage the keyboard inputs to control the movement of a follow camera.
  44863. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44864. */
  44865. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44866. /**
  44867. * Defines the camera the input is attached to.
  44868. */
  44869. camera: FollowCamera;
  44870. /**
  44871. * Defines the list of key codes associated with the up action (increase heightOffset)
  44872. */
  44873. keysHeightOffsetIncr: number[];
  44874. /**
  44875. * Defines the list of key codes associated with the down action (decrease heightOffset)
  44876. */
  44877. keysHeightOffsetDecr: number[];
  44878. /**
  44879. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  44880. */
  44881. keysHeightOffsetModifierAlt: boolean;
  44882. /**
  44883. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  44884. */
  44885. keysHeightOffsetModifierCtrl: boolean;
  44886. /**
  44887. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  44888. */
  44889. keysHeightOffsetModifierShift: boolean;
  44890. /**
  44891. * Defines the list of key codes associated with the left action (increase rotationOffset)
  44892. */
  44893. keysRotationOffsetIncr: number[];
  44894. /**
  44895. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  44896. */
  44897. keysRotationOffsetDecr: number[];
  44898. /**
  44899. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  44900. */
  44901. keysRotationOffsetModifierAlt: boolean;
  44902. /**
  44903. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  44904. */
  44905. keysRotationOffsetModifierCtrl: boolean;
  44906. /**
  44907. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  44908. */
  44909. keysRotationOffsetModifierShift: boolean;
  44910. /**
  44911. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  44912. */
  44913. keysRadiusIncr: number[];
  44914. /**
  44915. * Defines the list of key codes associated with the zoom-out action (increase radius)
  44916. */
  44917. keysRadiusDecr: number[];
  44918. /**
  44919. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  44920. */
  44921. keysRadiusModifierAlt: boolean;
  44922. /**
  44923. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  44924. */
  44925. keysRadiusModifierCtrl: boolean;
  44926. /**
  44927. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  44928. */
  44929. keysRadiusModifierShift: boolean;
  44930. /**
  44931. * Defines the rate of change of heightOffset.
  44932. */
  44933. heightSensibility: number;
  44934. /**
  44935. * Defines the rate of change of rotationOffset.
  44936. */
  44937. rotationSensibility: number;
  44938. /**
  44939. * Defines the rate of change of radius.
  44940. */
  44941. radiusSensibility: number;
  44942. private _keys;
  44943. private _ctrlPressed;
  44944. private _altPressed;
  44945. private _shiftPressed;
  44946. private _onCanvasBlurObserver;
  44947. private _onKeyboardObserver;
  44948. private _engine;
  44949. private _scene;
  44950. /**
  44951. * Attach the input controls to a specific dom element to get the input from.
  44952. * @param element Defines the element the controls should be listened from
  44953. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44954. */
  44955. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44956. /**
  44957. * Detach the current controls from the specified dom element.
  44958. * @param element Defines the element to stop listening the inputs from
  44959. */
  44960. detachControl(element: Nullable<HTMLElement>): void;
  44961. /**
  44962. * Update the current camera state depending on the inputs that have been used this frame.
  44963. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44964. */
  44965. checkInputs(): void;
  44966. /**
  44967. * Gets the class name of the current input.
  44968. * @returns the class name
  44969. */
  44970. getClassName(): string;
  44971. /**
  44972. * Get the friendly name associated with the input class.
  44973. * @returns the input friendly name
  44974. */
  44975. getSimpleName(): string;
  44976. /**
  44977. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44978. * allow modification of the heightOffset value.
  44979. */
  44980. private _modifierHeightOffset;
  44981. /**
  44982. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44983. * allow modification of the rotationOffset value.
  44984. */
  44985. private _modifierRotationOffset;
  44986. /**
  44987. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44988. * allow modification of the radius value.
  44989. */
  44990. private _modifierRadius;
  44991. }
  44992. }
  44993. declare module BABYLON {
  44994. interface FreeCameraInputsManager {
  44995. /**
  44996. * @hidden
  44997. */
  44998. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  44999. /**
  45000. * Add orientation input support to the input manager.
  45001. * @returns the current input manager
  45002. */
  45003. addDeviceOrientation(): FreeCameraInputsManager;
  45004. }
  45005. /**
  45006. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  45007. * Screen rotation is taken into account.
  45008. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45009. */
  45010. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  45011. private _camera;
  45012. private _screenOrientationAngle;
  45013. private _constantTranform;
  45014. private _screenQuaternion;
  45015. private _alpha;
  45016. private _beta;
  45017. private _gamma;
  45018. /**
  45019. * Can be used to detect if a device orientation sensor is available on a device
  45020. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  45021. * @returns a promise that will resolve on orientation change
  45022. */
  45023. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  45024. /**
  45025. * @hidden
  45026. */
  45027. _onDeviceOrientationChangedObservable: Observable<void>;
  45028. /**
  45029. * Instantiates a new input
  45030. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45031. */
  45032. constructor();
  45033. /**
  45034. * Define the camera controlled by the input.
  45035. */
  45036. get camera(): FreeCamera;
  45037. set camera(camera: FreeCamera);
  45038. /**
  45039. * Attach the input controls to a specific dom element to get the input from.
  45040. * @param element Defines the element the controls should be listened from
  45041. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45042. */
  45043. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45044. private _orientationChanged;
  45045. private _deviceOrientation;
  45046. /**
  45047. * Detach the current controls from the specified dom element.
  45048. * @param element Defines the element to stop listening the inputs from
  45049. */
  45050. detachControl(element: Nullable<HTMLElement>): void;
  45051. /**
  45052. * Update the current camera state depending on the inputs that have been used this frame.
  45053. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45054. */
  45055. checkInputs(): void;
  45056. /**
  45057. * Gets the class name of the current intput.
  45058. * @returns the class name
  45059. */
  45060. getClassName(): string;
  45061. /**
  45062. * Get the friendly name associated with the input class.
  45063. * @returns the input friendly name
  45064. */
  45065. getSimpleName(): string;
  45066. }
  45067. }
  45068. declare module BABYLON {
  45069. /**
  45070. * Manage the gamepad inputs to control a free camera.
  45071. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45072. */
  45073. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  45074. /**
  45075. * Define the camera the input is attached to.
  45076. */
  45077. camera: FreeCamera;
  45078. /**
  45079. * Define the Gamepad controlling the input
  45080. */
  45081. gamepad: Nullable<Gamepad>;
  45082. /**
  45083. * Defines the gamepad rotation sensiblity.
  45084. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45085. */
  45086. gamepadAngularSensibility: number;
  45087. /**
  45088. * Defines the gamepad move sensiblity.
  45089. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45090. */
  45091. gamepadMoveSensibility: number;
  45092. private _yAxisScale;
  45093. /**
  45094. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45095. */
  45096. get invertYAxis(): boolean;
  45097. set invertYAxis(value: boolean);
  45098. private _onGamepadConnectedObserver;
  45099. private _onGamepadDisconnectedObserver;
  45100. private _cameraTransform;
  45101. private _deltaTransform;
  45102. private _vector3;
  45103. private _vector2;
  45104. /**
  45105. * Attach the input controls to a specific dom element to get the input from.
  45106. * @param element Defines the element the controls should be listened from
  45107. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45108. */
  45109. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45110. /**
  45111. * Detach the current controls from the specified dom element.
  45112. * @param element Defines the element to stop listening the inputs from
  45113. */
  45114. detachControl(element: Nullable<HTMLElement>): void;
  45115. /**
  45116. * Update the current camera state depending on the inputs that have been used this frame.
  45117. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45118. */
  45119. checkInputs(): void;
  45120. /**
  45121. * Gets the class name of the current intput.
  45122. * @returns the class name
  45123. */
  45124. getClassName(): string;
  45125. /**
  45126. * Get the friendly name associated with the input class.
  45127. * @returns the input friendly name
  45128. */
  45129. getSimpleName(): string;
  45130. }
  45131. }
  45132. declare module BABYLON {
  45133. /**
  45134. * Defines the potential axis of a Joystick
  45135. */
  45136. export enum JoystickAxis {
  45137. /** X axis */
  45138. X = 0,
  45139. /** Y axis */
  45140. Y = 1,
  45141. /** Z axis */
  45142. Z = 2
  45143. }
  45144. /**
  45145. * Represents the different customization options available
  45146. * for VirtualJoystick
  45147. */
  45148. interface VirtualJoystickCustomizations {
  45149. /**
  45150. * Size of the joystick's puck
  45151. */
  45152. puckSize: number;
  45153. /**
  45154. * Size of the joystick's container
  45155. */
  45156. containerSize: number;
  45157. /**
  45158. * Color of the joystick && puck
  45159. */
  45160. color: string;
  45161. /**
  45162. * Image URL for the joystick's puck
  45163. */
  45164. puckImage?: string;
  45165. /**
  45166. * Image URL for the joystick's container
  45167. */
  45168. containerImage?: string;
  45169. /**
  45170. * Defines the unmoving position of the joystick container
  45171. */
  45172. position?: {
  45173. x: number;
  45174. y: number;
  45175. };
  45176. /**
  45177. * Defines whether or not the joystick container is always visible
  45178. */
  45179. alwaysVisible: boolean;
  45180. /**
  45181. * Defines whether or not to limit the movement of the puck to the joystick's container
  45182. */
  45183. limitToContainer: boolean;
  45184. }
  45185. /**
  45186. * Class used to define virtual joystick (used in touch mode)
  45187. */
  45188. export class VirtualJoystick {
  45189. /**
  45190. * Gets or sets a boolean indicating that left and right values must be inverted
  45191. */
  45192. reverseLeftRight: boolean;
  45193. /**
  45194. * Gets or sets a boolean indicating that up and down values must be inverted
  45195. */
  45196. reverseUpDown: boolean;
  45197. /**
  45198. * Gets the offset value for the position (ie. the change of the position value)
  45199. */
  45200. deltaPosition: Vector3;
  45201. /**
  45202. * Gets a boolean indicating if the virtual joystick was pressed
  45203. */
  45204. pressed: boolean;
  45205. /**
  45206. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45207. */
  45208. static Canvas: Nullable<HTMLCanvasElement>;
  45209. /**
  45210. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  45211. */
  45212. limitToContainer: boolean;
  45213. private static _globalJoystickIndex;
  45214. private static _alwaysVisibleSticks;
  45215. private static vjCanvasContext;
  45216. private static vjCanvasWidth;
  45217. private static vjCanvasHeight;
  45218. private static halfWidth;
  45219. private static _GetDefaultOptions;
  45220. private _action;
  45221. private _axisTargetedByLeftAndRight;
  45222. private _axisTargetedByUpAndDown;
  45223. private _joystickSensibility;
  45224. private _inversedSensibility;
  45225. private _joystickPointerID;
  45226. private _joystickColor;
  45227. private _joystickPointerPos;
  45228. private _joystickPreviousPointerPos;
  45229. private _joystickPointerStartPos;
  45230. private _deltaJoystickVector;
  45231. private _leftJoystick;
  45232. private _touches;
  45233. private _joystickPosition;
  45234. private _alwaysVisible;
  45235. private _puckImage;
  45236. private _containerImage;
  45237. private _joystickPuckSize;
  45238. private _joystickContainerSize;
  45239. private _clearPuckSize;
  45240. private _clearContainerSize;
  45241. private _clearPuckSizeOffset;
  45242. private _clearContainerSizeOffset;
  45243. private _onPointerDownHandlerRef;
  45244. private _onPointerMoveHandlerRef;
  45245. private _onPointerUpHandlerRef;
  45246. private _onResize;
  45247. /**
  45248. * Creates a new virtual joystick
  45249. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45250. * @param customizations Defines the options we want to customize the VirtualJoystick
  45251. */
  45252. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  45253. /**
  45254. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45255. * @param newJoystickSensibility defines the new sensibility
  45256. */
  45257. setJoystickSensibility(newJoystickSensibility: number): void;
  45258. private _onPointerDown;
  45259. private _onPointerMove;
  45260. private _onPointerUp;
  45261. /**
  45262. * Change the color of the virtual joystick
  45263. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45264. */
  45265. setJoystickColor(newColor: string): void;
  45266. /**
  45267. * Size of the joystick's container
  45268. */
  45269. set containerSize(newSize: number);
  45270. get containerSize(): number;
  45271. /**
  45272. * Size of the joystick's puck
  45273. */
  45274. set puckSize(newSize: number);
  45275. get puckSize(): number;
  45276. /**
  45277. * Clears the set position of the joystick
  45278. */
  45279. clearPosition(): void;
  45280. /**
  45281. * Defines whether or not the joystick container is always visible
  45282. */
  45283. set alwaysVisible(value: boolean);
  45284. get alwaysVisible(): boolean;
  45285. /**
  45286. * Sets the constant position of the Joystick container
  45287. * @param x X axis coordinate
  45288. * @param y Y axis coordinate
  45289. */
  45290. setPosition(x: number, y: number): void;
  45291. /**
  45292. * Defines a callback to call when the joystick is touched
  45293. * @param action defines the callback
  45294. */
  45295. setActionOnTouch(action: () => any): void;
  45296. /**
  45297. * Defines which axis you'd like to control for left & right
  45298. * @param axis defines the axis to use
  45299. */
  45300. setAxisForLeftRight(axis: JoystickAxis): void;
  45301. /**
  45302. * Defines which axis you'd like to control for up & down
  45303. * @param axis defines the axis to use
  45304. */
  45305. setAxisForUpDown(axis: JoystickAxis): void;
  45306. /**
  45307. * Clears the canvas from the previous puck / container draw
  45308. */
  45309. private _clearPreviousDraw;
  45310. /**
  45311. * Loads `urlPath` to be used for the container's image
  45312. * @param urlPath defines the urlPath of an image to use
  45313. */
  45314. setContainerImage(urlPath: string): void;
  45315. /**
  45316. * Loads `urlPath` to be used for the puck's image
  45317. * @param urlPath defines the urlPath of an image to use
  45318. */
  45319. setPuckImage(urlPath: string): void;
  45320. /**
  45321. * Draws the Virtual Joystick's container
  45322. */
  45323. private _drawContainer;
  45324. /**
  45325. * Draws the Virtual Joystick's puck
  45326. */
  45327. private _drawPuck;
  45328. private _drawVirtualJoystick;
  45329. /**
  45330. * Release internal HTML canvas
  45331. */
  45332. releaseCanvas(): void;
  45333. }
  45334. }
  45335. declare module BABYLON {
  45336. interface FreeCameraInputsManager {
  45337. /**
  45338. * Add virtual joystick input support to the input manager.
  45339. * @returns the current input manager
  45340. */
  45341. addVirtualJoystick(): FreeCameraInputsManager;
  45342. }
  45343. /**
  45344. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45345. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45346. */
  45347. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45348. /**
  45349. * Defines the camera the input is attached to.
  45350. */
  45351. camera: FreeCamera;
  45352. private _leftjoystick;
  45353. private _rightjoystick;
  45354. /**
  45355. * Gets the left stick of the virtual joystick.
  45356. * @returns The virtual Joystick
  45357. */
  45358. getLeftJoystick(): VirtualJoystick;
  45359. /**
  45360. * Gets the right stick of the virtual joystick.
  45361. * @returns The virtual Joystick
  45362. */
  45363. getRightJoystick(): VirtualJoystick;
  45364. /**
  45365. * Update the current camera state depending on the inputs that have been used this frame.
  45366. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45367. */
  45368. checkInputs(): void;
  45369. /**
  45370. * Attach the input controls to a specific dom element to get the input from.
  45371. * @param element Defines the element the controls should be listened from
  45372. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45373. */
  45374. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45375. /**
  45376. * Detach the current controls from the specified dom element.
  45377. * @param element Defines the element to stop listening the inputs from
  45378. */
  45379. detachControl(element: Nullable<HTMLElement>): void;
  45380. /**
  45381. * Gets the class name of the current intput.
  45382. * @returns the class name
  45383. */
  45384. getClassName(): string;
  45385. /**
  45386. * Get the friendly name associated with the input class.
  45387. * @returns the input friendly name
  45388. */
  45389. getSimpleName(): string;
  45390. }
  45391. }
  45392. declare module BABYLON {
  45393. /**
  45394. * This represents a FPS type of camera controlled by touch.
  45395. * This is like a universal camera minus the Gamepad controls.
  45396. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45397. */
  45398. export class TouchCamera extends FreeCamera {
  45399. /**
  45400. * Defines the touch sensibility for rotation.
  45401. * The higher the faster.
  45402. */
  45403. get touchAngularSensibility(): number;
  45404. set touchAngularSensibility(value: number);
  45405. /**
  45406. * Defines the touch sensibility for move.
  45407. * The higher the faster.
  45408. */
  45409. get touchMoveSensibility(): number;
  45410. set touchMoveSensibility(value: number);
  45411. /**
  45412. * Instantiates a new touch camera.
  45413. * This represents a FPS type of camera controlled by touch.
  45414. * This is like a universal camera minus the Gamepad controls.
  45415. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45416. * @param name Define the name of the camera in the scene
  45417. * @param position Define the start position of the camera in the scene
  45418. * @param scene Define the scene the camera belongs to
  45419. */
  45420. constructor(name: string, position: Vector3, scene: Scene);
  45421. /**
  45422. * Gets the current object class name.
  45423. * @return the class name
  45424. */
  45425. getClassName(): string;
  45426. /** @hidden */
  45427. _setupInputs(): void;
  45428. }
  45429. }
  45430. declare module BABYLON {
  45431. /**
  45432. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45433. * being tilted forward or back and left or right.
  45434. */
  45435. export class DeviceOrientationCamera extends FreeCamera {
  45436. private _initialQuaternion;
  45437. private _quaternionCache;
  45438. private _tmpDragQuaternion;
  45439. private _disablePointerInputWhenUsingDeviceOrientation;
  45440. /**
  45441. * Creates a new device orientation camera
  45442. * @param name The name of the camera
  45443. * @param position The start position camera
  45444. * @param scene The scene the camera belongs to
  45445. */
  45446. constructor(name: string, position: Vector3, scene: Scene);
  45447. /**
  45448. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45449. */
  45450. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45451. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45452. private _dragFactor;
  45453. /**
  45454. * Enabled turning on the y axis when the orientation sensor is active
  45455. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45456. */
  45457. enableHorizontalDragging(dragFactor?: number): void;
  45458. /**
  45459. * Gets the current instance class name ("DeviceOrientationCamera").
  45460. * This helps avoiding instanceof at run time.
  45461. * @returns the class name
  45462. */
  45463. getClassName(): string;
  45464. /**
  45465. * @hidden
  45466. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45467. */
  45468. _checkInputs(): void;
  45469. /**
  45470. * Reset the camera to its default orientation on the specified axis only.
  45471. * @param axis The axis to reset
  45472. */
  45473. resetToCurrentRotation(axis?: Axis): void;
  45474. }
  45475. }
  45476. declare module BABYLON {
  45477. /**
  45478. * Defines supported buttons for XBox360 compatible gamepads
  45479. */
  45480. export enum Xbox360Button {
  45481. /** A */
  45482. A = 0,
  45483. /** B */
  45484. B = 1,
  45485. /** X */
  45486. X = 2,
  45487. /** Y */
  45488. Y = 3,
  45489. /** Left button */
  45490. LB = 4,
  45491. /** Right button */
  45492. RB = 5,
  45493. /** Back */
  45494. Back = 8,
  45495. /** Start */
  45496. Start = 9,
  45497. /** Left stick */
  45498. LeftStick = 10,
  45499. /** Right stick */
  45500. RightStick = 11
  45501. }
  45502. /** Defines values for XBox360 DPad */
  45503. export enum Xbox360Dpad {
  45504. /** Up */
  45505. Up = 12,
  45506. /** Down */
  45507. Down = 13,
  45508. /** Left */
  45509. Left = 14,
  45510. /** Right */
  45511. Right = 15
  45512. }
  45513. /**
  45514. * Defines a XBox360 gamepad
  45515. */
  45516. export class Xbox360Pad extends Gamepad {
  45517. private _leftTrigger;
  45518. private _rightTrigger;
  45519. private _onlefttriggerchanged;
  45520. private _onrighttriggerchanged;
  45521. private _onbuttondown;
  45522. private _onbuttonup;
  45523. private _ondpaddown;
  45524. private _ondpadup;
  45525. /** Observable raised when a button is pressed */
  45526. onButtonDownObservable: Observable<Xbox360Button>;
  45527. /** Observable raised when a button is released */
  45528. onButtonUpObservable: Observable<Xbox360Button>;
  45529. /** Observable raised when a pad is pressed */
  45530. onPadDownObservable: Observable<Xbox360Dpad>;
  45531. /** Observable raised when a pad is released */
  45532. onPadUpObservable: Observable<Xbox360Dpad>;
  45533. private _buttonA;
  45534. private _buttonB;
  45535. private _buttonX;
  45536. private _buttonY;
  45537. private _buttonBack;
  45538. private _buttonStart;
  45539. private _buttonLB;
  45540. private _buttonRB;
  45541. private _buttonLeftStick;
  45542. private _buttonRightStick;
  45543. private _dPadUp;
  45544. private _dPadDown;
  45545. private _dPadLeft;
  45546. private _dPadRight;
  45547. private _isXboxOnePad;
  45548. /**
  45549. * Creates a new XBox360 gamepad object
  45550. * @param id defines the id of this gamepad
  45551. * @param index defines its index
  45552. * @param gamepad defines the internal HTML gamepad object
  45553. * @param xboxOne defines if it is a XBox One gamepad
  45554. */
  45555. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45556. /**
  45557. * Defines the callback to call when left trigger is pressed
  45558. * @param callback defines the callback to use
  45559. */
  45560. onlefttriggerchanged(callback: (value: number) => void): void;
  45561. /**
  45562. * Defines the callback to call when right trigger is pressed
  45563. * @param callback defines the callback to use
  45564. */
  45565. onrighttriggerchanged(callback: (value: number) => void): void;
  45566. /**
  45567. * Gets the left trigger value
  45568. */
  45569. get leftTrigger(): number;
  45570. /**
  45571. * Sets the left trigger value
  45572. */
  45573. set leftTrigger(newValue: number);
  45574. /**
  45575. * Gets the right trigger value
  45576. */
  45577. get rightTrigger(): number;
  45578. /**
  45579. * Sets the right trigger value
  45580. */
  45581. set rightTrigger(newValue: number);
  45582. /**
  45583. * Defines the callback to call when a button is pressed
  45584. * @param callback defines the callback to use
  45585. */
  45586. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45587. /**
  45588. * Defines the callback to call when a button is released
  45589. * @param callback defines the callback to use
  45590. */
  45591. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45592. /**
  45593. * Defines the callback to call when a pad is pressed
  45594. * @param callback defines the callback to use
  45595. */
  45596. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45597. /**
  45598. * Defines the callback to call when a pad is released
  45599. * @param callback defines the callback to use
  45600. */
  45601. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45602. private _setButtonValue;
  45603. private _setDPadValue;
  45604. /**
  45605. * Gets the value of the `A` button
  45606. */
  45607. get buttonA(): number;
  45608. /**
  45609. * Sets the value of the `A` button
  45610. */
  45611. set buttonA(value: number);
  45612. /**
  45613. * Gets the value of the `B` button
  45614. */
  45615. get buttonB(): number;
  45616. /**
  45617. * Sets the value of the `B` button
  45618. */
  45619. set buttonB(value: number);
  45620. /**
  45621. * Gets the value of the `X` button
  45622. */
  45623. get buttonX(): number;
  45624. /**
  45625. * Sets the value of the `X` button
  45626. */
  45627. set buttonX(value: number);
  45628. /**
  45629. * Gets the value of the `Y` button
  45630. */
  45631. get buttonY(): number;
  45632. /**
  45633. * Sets the value of the `Y` button
  45634. */
  45635. set buttonY(value: number);
  45636. /**
  45637. * Gets the value of the `Start` button
  45638. */
  45639. get buttonStart(): number;
  45640. /**
  45641. * Sets the value of the `Start` button
  45642. */
  45643. set buttonStart(value: number);
  45644. /**
  45645. * Gets the value of the `Back` button
  45646. */
  45647. get buttonBack(): number;
  45648. /**
  45649. * Sets the value of the `Back` button
  45650. */
  45651. set buttonBack(value: number);
  45652. /**
  45653. * Gets the value of the `Left` button
  45654. */
  45655. get buttonLB(): number;
  45656. /**
  45657. * Sets the value of the `Left` button
  45658. */
  45659. set buttonLB(value: number);
  45660. /**
  45661. * Gets the value of the `Right` button
  45662. */
  45663. get buttonRB(): number;
  45664. /**
  45665. * Sets the value of the `Right` button
  45666. */
  45667. set buttonRB(value: number);
  45668. /**
  45669. * Gets the value of the Left joystick
  45670. */
  45671. get buttonLeftStick(): number;
  45672. /**
  45673. * Sets the value of the Left joystick
  45674. */
  45675. set buttonLeftStick(value: number);
  45676. /**
  45677. * Gets the value of the Right joystick
  45678. */
  45679. get buttonRightStick(): number;
  45680. /**
  45681. * Sets the value of the Right joystick
  45682. */
  45683. set buttonRightStick(value: number);
  45684. /**
  45685. * Gets the value of D-pad up
  45686. */
  45687. get dPadUp(): number;
  45688. /**
  45689. * Sets the value of D-pad up
  45690. */
  45691. set dPadUp(value: number);
  45692. /**
  45693. * Gets the value of D-pad down
  45694. */
  45695. get dPadDown(): number;
  45696. /**
  45697. * Sets the value of D-pad down
  45698. */
  45699. set dPadDown(value: number);
  45700. /**
  45701. * Gets the value of D-pad left
  45702. */
  45703. get dPadLeft(): number;
  45704. /**
  45705. * Sets the value of D-pad left
  45706. */
  45707. set dPadLeft(value: number);
  45708. /**
  45709. * Gets the value of D-pad right
  45710. */
  45711. get dPadRight(): number;
  45712. /**
  45713. * Sets the value of D-pad right
  45714. */
  45715. set dPadRight(value: number);
  45716. /**
  45717. * Force the gamepad to synchronize with device values
  45718. */
  45719. update(): void;
  45720. /**
  45721. * Disposes the gamepad
  45722. */
  45723. dispose(): void;
  45724. }
  45725. }
  45726. declare module BABYLON {
  45727. /**
  45728. * Defines supported buttons for DualShock compatible gamepads
  45729. */
  45730. export enum DualShockButton {
  45731. /** Cross */
  45732. Cross = 0,
  45733. /** Circle */
  45734. Circle = 1,
  45735. /** Square */
  45736. Square = 2,
  45737. /** Triangle */
  45738. Triangle = 3,
  45739. /** L1 */
  45740. L1 = 4,
  45741. /** R1 */
  45742. R1 = 5,
  45743. /** Share */
  45744. Share = 8,
  45745. /** Options */
  45746. Options = 9,
  45747. /** Left stick */
  45748. LeftStick = 10,
  45749. /** Right stick */
  45750. RightStick = 11
  45751. }
  45752. /** Defines values for DualShock DPad */
  45753. export enum DualShockDpad {
  45754. /** Up */
  45755. Up = 12,
  45756. /** Down */
  45757. Down = 13,
  45758. /** Left */
  45759. Left = 14,
  45760. /** Right */
  45761. Right = 15
  45762. }
  45763. /**
  45764. * Defines a DualShock gamepad
  45765. */
  45766. export class DualShockPad extends Gamepad {
  45767. private _leftTrigger;
  45768. private _rightTrigger;
  45769. private _onlefttriggerchanged;
  45770. private _onrighttriggerchanged;
  45771. private _onbuttondown;
  45772. private _onbuttonup;
  45773. private _ondpaddown;
  45774. private _ondpadup;
  45775. /** Observable raised when a button is pressed */
  45776. onButtonDownObservable: Observable<DualShockButton>;
  45777. /** Observable raised when a button is released */
  45778. onButtonUpObservable: Observable<DualShockButton>;
  45779. /** Observable raised when a pad is pressed */
  45780. onPadDownObservable: Observable<DualShockDpad>;
  45781. /** Observable raised when a pad is released */
  45782. onPadUpObservable: Observable<DualShockDpad>;
  45783. private _buttonCross;
  45784. private _buttonCircle;
  45785. private _buttonSquare;
  45786. private _buttonTriangle;
  45787. private _buttonShare;
  45788. private _buttonOptions;
  45789. private _buttonL1;
  45790. private _buttonR1;
  45791. private _buttonLeftStick;
  45792. private _buttonRightStick;
  45793. private _dPadUp;
  45794. private _dPadDown;
  45795. private _dPadLeft;
  45796. private _dPadRight;
  45797. /**
  45798. * Creates a new DualShock gamepad object
  45799. * @param id defines the id of this gamepad
  45800. * @param index defines its index
  45801. * @param gamepad defines the internal HTML gamepad object
  45802. */
  45803. constructor(id: string, index: number, gamepad: any);
  45804. /**
  45805. * Defines the callback to call when left trigger is pressed
  45806. * @param callback defines the callback to use
  45807. */
  45808. onlefttriggerchanged(callback: (value: number) => void): void;
  45809. /**
  45810. * Defines the callback to call when right trigger is pressed
  45811. * @param callback defines the callback to use
  45812. */
  45813. onrighttriggerchanged(callback: (value: number) => void): void;
  45814. /**
  45815. * Gets the left trigger value
  45816. */
  45817. get leftTrigger(): number;
  45818. /**
  45819. * Sets the left trigger value
  45820. */
  45821. set leftTrigger(newValue: number);
  45822. /**
  45823. * Gets the right trigger value
  45824. */
  45825. get rightTrigger(): number;
  45826. /**
  45827. * Sets the right trigger value
  45828. */
  45829. set rightTrigger(newValue: number);
  45830. /**
  45831. * Defines the callback to call when a button is pressed
  45832. * @param callback defines the callback to use
  45833. */
  45834. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45835. /**
  45836. * Defines the callback to call when a button is released
  45837. * @param callback defines the callback to use
  45838. */
  45839. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45840. /**
  45841. * Defines the callback to call when a pad is pressed
  45842. * @param callback defines the callback to use
  45843. */
  45844. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45845. /**
  45846. * Defines the callback to call when a pad is released
  45847. * @param callback defines the callback to use
  45848. */
  45849. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45850. private _setButtonValue;
  45851. private _setDPadValue;
  45852. /**
  45853. * Gets the value of the `Cross` button
  45854. */
  45855. get buttonCross(): number;
  45856. /**
  45857. * Sets the value of the `Cross` button
  45858. */
  45859. set buttonCross(value: number);
  45860. /**
  45861. * Gets the value of the `Circle` button
  45862. */
  45863. get buttonCircle(): number;
  45864. /**
  45865. * Sets the value of the `Circle` button
  45866. */
  45867. set buttonCircle(value: number);
  45868. /**
  45869. * Gets the value of the `Square` button
  45870. */
  45871. get buttonSquare(): number;
  45872. /**
  45873. * Sets the value of the `Square` button
  45874. */
  45875. set buttonSquare(value: number);
  45876. /**
  45877. * Gets the value of the `Triangle` button
  45878. */
  45879. get buttonTriangle(): number;
  45880. /**
  45881. * Sets the value of the `Triangle` button
  45882. */
  45883. set buttonTriangle(value: number);
  45884. /**
  45885. * Gets the value of the `Options` button
  45886. */
  45887. get buttonOptions(): number;
  45888. /**
  45889. * Sets the value of the `Options` button
  45890. */
  45891. set buttonOptions(value: number);
  45892. /**
  45893. * Gets the value of the `Share` button
  45894. */
  45895. get buttonShare(): number;
  45896. /**
  45897. * Sets the value of the `Share` button
  45898. */
  45899. set buttonShare(value: number);
  45900. /**
  45901. * Gets the value of the `L1` button
  45902. */
  45903. get buttonL1(): number;
  45904. /**
  45905. * Sets the value of the `L1` button
  45906. */
  45907. set buttonL1(value: number);
  45908. /**
  45909. * Gets the value of the `R1` button
  45910. */
  45911. get buttonR1(): number;
  45912. /**
  45913. * Sets the value of the `R1` button
  45914. */
  45915. set buttonR1(value: number);
  45916. /**
  45917. * Gets the value of the Left joystick
  45918. */
  45919. get buttonLeftStick(): number;
  45920. /**
  45921. * Sets the value of the Left joystick
  45922. */
  45923. set buttonLeftStick(value: number);
  45924. /**
  45925. * Gets the value of the Right joystick
  45926. */
  45927. get buttonRightStick(): number;
  45928. /**
  45929. * Sets the value of the Right joystick
  45930. */
  45931. set buttonRightStick(value: number);
  45932. /**
  45933. * Gets the value of D-pad up
  45934. */
  45935. get dPadUp(): number;
  45936. /**
  45937. * Sets the value of D-pad up
  45938. */
  45939. set dPadUp(value: number);
  45940. /**
  45941. * Gets the value of D-pad down
  45942. */
  45943. get dPadDown(): number;
  45944. /**
  45945. * Sets the value of D-pad down
  45946. */
  45947. set dPadDown(value: number);
  45948. /**
  45949. * Gets the value of D-pad left
  45950. */
  45951. get dPadLeft(): number;
  45952. /**
  45953. * Sets the value of D-pad left
  45954. */
  45955. set dPadLeft(value: number);
  45956. /**
  45957. * Gets the value of D-pad right
  45958. */
  45959. get dPadRight(): number;
  45960. /**
  45961. * Sets the value of D-pad right
  45962. */
  45963. set dPadRight(value: number);
  45964. /**
  45965. * Force the gamepad to synchronize with device values
  45966. */
  45967. update(): void;
  45968. /**
  45969. * Disposes the gamepad
  45970. */
  45971. dispose(): void;
  45972. }
  45973. }
  45974. declare module BABYLON {
  45975. /**
  45976. * Manager for handling gamepads
  45977. */
  45978. export class GamepadManager {
  45979. private _scene?;
  45980. private _babylonGamepads;
  45981. private _oneGamepadConnected;
  45982. /** @hidden */
  45983. _isMonitoring: boolean;
  45984. private _gamepadEventSupported;
  45985. private _gamepadSupport?;
  45986. /**
  45987. * observable to be triggered when the gamepad controller has been connected
  45988. */
  45989. onGamepadConnectedObservable: Observable<Gamepad>;
  45990. /**
  45991. * observable to be triggered when the gamepad controller has been disconnected
  45992. */
  45993. onGamepadDisconnectedObservable: Observable<Gamepad>;
  45994. private _onGamepadConnectedEvent;
  45995. private _onGamepadDisconnectedEvent;
  45996. /**
  45997. * Initializes the gamepad manager
  45998. * @param _scene BabylonJS scene
  45999. */
  46000. constructor(_scene?: Scene | undefined);
  46001. /**
  46002. * The gamepads in the game pad manager
  46003. */
  46004. get gamepads(): Gamepad[];
  46005. /**
  46006. * Get the gamepad controllers based on type
  46007. * @param type The type of gamepad controller
  46008. * @returns Nullable gamepad
  46009. */
  46010. getGamepadByType(type?: number): Nullable<Gamepad>;
  46011. /**
  46012. * Disposes the gamepad manager
  46013. */
  46014. dispose(): void;
  46015. private _addNewGamepad;
  46016. private _startMonitoringGamepads;
  46017. private _stopMonitoringGamepads;
  46018. /** @hidden */
  46019. _checkGamepadsStatus(): void;
  46020. private _updateGamepadObjects;
  46021. }
  46022. }
  46023. declare module BABYLON {
  46024. interface Scene {
  46025. /** @hidden */
  46026. _gamepadManager: Nullable<GamepadManager>;
  46027. /**
  46028. * Gets the gamepad manager associated with the scene
  46029. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  46030. */
  46031. gamepadManager: GamepadManager;
  46032. }
  46033. /**
  46034. * Interface representing a free camera inputs manager
  46035. */
  46036. interface FreeCameraInputsManager {
  46037. /**
  46038. * Adds gamepad input support to the FreeCameraInputsManager.
  46039. * @returns the FreeCameraInputsManager
  46040. */
  46041. addGamepad(): FreeCameraInputsManager;
  46042. }
  46043. /**
  46044. * Interface representing an arc rotate camera inputs manager
  46045. */
  46046. interface ArcRotateCameraInputsManager {
  46047. /**
  46048. * Adds gamepad input support to the ArcRotateCamera InputManager.
  46049. * @returns the camera inputs manager
  46050. */
  46051. addGamepad(): ArcRotateCameraInputsManager;
  46052. }
  46053. /**
  46054. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  46055. */
  46056. export class GamepadSystemSceneComponent implements ISceneComponent {
  46057. /**
  46058. * The component name helpfull to identify the component in the list of scene components.
  46059. */
  46060. readonly name: string;
  46061. /**
  46062. * The scene the component belongs to.
  46063. */
  46064. scene: Scene;
  46065. /**
  46066. * Creates a new instance of the component for the given scene
  46067. * @param scene Defines the scene to register the component in
  46068. */
  46069. constructor(scene: Scene);
  46070. /**
  46071. * Registers the component in a given scene
  46072. */
  46073. register(): void;
  46074. /**
  46075. * Rebuilds the elements related to this component in case of
  46076. * context lost for instance.
  46077. */
  46078. rebuild(): void;
  46079. /**
  46080. * Disposes the component and the associated ressources
  46081. */
  46082. dispose(): void;
  46083. private _beforeCameraUpdate;
  46084. }
  46085. }
  46086. declare module BABYLON {
  46087. /**
  46088. * 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,
  46089. * which still works and will still be found in many Playgrounds.
  46090. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46091. */
  46092. export class UniversalCamera extends TouchCamera {
  46093. /**
  46094. * Defines the gamepad rotation sensiblity.
  46095. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46096. */
  46097. get gamepadAngularSensibility(): number;
  46098. set gamepadAngularSensibility(value: number);
  46099. /**
  46100. * Defines the gamepad move sensiblity.
  46101. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46102. */
  46103. get gamepadMoveSensibility(): number;
  46104. set gamepadMoveSensibility(value: number);
  46105. /**
  46106. * 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,
  46107. * which still works and will still be found in many Playgrounds.
  46108. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46109. * @param name Define the name of the camera in the scene
  46110. * @param position Define the start position of the camera in the scene
  46111. * @param scene Define the scene the camera belongs to
  46112. */
  46113. constructor(name: string, position: Vector3, scene: Scene);
  46114. /**
  46115. * Gets the current object class name.
  46116. * @return the class name
  46117. */
  46118. getClassName(): string;
  46119. }
  46120. }
  46121. declare module BABYLON {
  46122. /**
  46123. * This represents a FPS type of camera. This is only here for back compat purpose.
  46124. * Please use the UniversalCamera instead as both are identical.
  46125. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46126. */
  46127. export class GamepadCamera extends UniversalCamera {
  46128. /**
  46129. * Instantiates a new Gamepad Camera
  46130. * This represents a FPS type of camera. This is only here for back compat purpose.
  46131. * Please use the UniversalCamera instead as both are identical.
  46132. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46133. * @param name Define the name of the camera in the scene
  46134. * @param position Define the start position of the camera in the scene
  46135. * @param scene Define the scene the camera belongs to
  46136. */
  46137. constructor(name: string, position: Vector3, scene: Scene);
  46138. /**
  46139. * Gets the current object class name.
  46140. * @return the class name
  46141. */
  46142. getClassName(): string;
  46143. }
  46144. }
  46145. declare module BABYLON {
  46146. /** @hidden */
  46147. export var passPixelShader: {
  46148. name: string;
  46149. shader: string;
  46150. };
  46151. }
  46152. declare module BABYLON {
  46153. /** @hidden */
  46154. export var passCubePixelShader: {
  46155. name: string;
  46156. shader: string;
  46157. };
  46158. }
  46159. declare module BABYLON {
  46160. /**
  46161. * PassPostProcess which produces an output the same as it's input
  46162. */
  46163. export class PassPostProcess extends PostProcess {
  46164. /**
  46165. * Gets a string identifying the name of the class
  46166. * @returns "PassPostProcess" string
  46167. */
  46168. getClassName(): string;
  46169. /**
  46170. * Creates the PassPostProcess
  46171. * @param name The name of the effect.
  46172. * @param options The required width/height ratio to downsize to before computing the render pass.
  46173. * @param camera The camera to apply the render pass to.
  46174. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46175. * @param engine The engine which the post process will be applied. (default: current engine)
  46176. * @param reusable If the post process can be reused on the same frame. (default: false)
  46177. * @param textureType The type of texture to be used when performing the post processing.
  46178. * @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)
  46179. */
  46180. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46181. /** @hidden */
  46182. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  46183. }
  46184. /**
  46185. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46186. */
  46187. export class PassCubePostProcess extends PostProcess {
  46188. private _face;
  46189. /**
  46190. * Gets or sets the cube face to display.
  46191. * * 0 is +X
  46192. * * 1 is -X
  46193. * * 2 is +Y
  46194. * * 3 is -Y
  46195. * * 4 is +Z
  46196. * * 5 is -Z
  46197. */
  46198. get face(): number;
  46199. set face(value: number);
  46200. /**
  46201. * Gets a string identifying the name of the class
  46202. * @returns "PassCubePostProcess" string
  46203. */
  46204. getClassName(): string;
  46205. /**
  46206. * Creates the PassCubePostProcess
  46207. * @param name The name of the effect.
  46208. * @param options The required width/height ratio to downsize to before computing the render pass.
  46209. * @param camera The camera to apply the render pass to.
  46210. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46211. * @param engine The engine which the post process will be applied. (default: current engine)
  46212. * @param reusable If the post process can be reused on the same frame. (default: false)
  46213. * @param textureType The type of texture to be used when performing the post processing.
  46214. * @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)
  46215. */
  46216. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46217. /** @hidden */
  46218. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  46219. }
  46220. }
  46221. declare module BABYLON {
  46222. /** @hidden */
  46223. export var anaglyphPixelShader: {
  46224. name: string;
  46225. shader: string;
  46226. };
  46227. }
  46228. declare module BABYLON {
  46229. /**
  46230. * Postprocess used to generate anaglyphic rendering
  46231. */
  46232. export class AnaglyphPostProcess extends PostProcess {
  46233. private _passedProcess;
  46234. /**
  46235. * Gets a string identifying the name of the class
  46236. * @returns "AnaglyphPostProcess" string
  46237. */
  46238. getClassName(): string;
  46239. /**
  46240. * Creates a new AnaglyphPostProcess
  46241. * @param name defines postprocess name
  46242. * @param options defines creation options or target ratio scale
  46243. * @param rigCameras defines cameras using this postprocess
  46244. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46245. * @param engine defines hosting engine
  46246. * @param reusable defines if the postprocess will be reused multiple times per frame
  46247. */
  46248. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46249. }
  46250. }
  46251. declare module BABYLON {
  46252. /**
  46253. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46254. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46255. */
  46256. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46257. /**
  46258. * Creates a new AnaglyphArcRotateCamera
  46259. * @param name defines camera name
  46260. * @param alpha defines alpha angle (in radians)
  46261. * @param beta defines beta angle (in radians)
  46262. * @param radius defines radius
  46263. * @param target defines camera target
  46264. * @param interaxialDistance defines distance between each color axis
  46265. * @param scene defines the hosting scene
  46266. */
  46267. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46268. /**
  46269. * Gets camera class name
  46270. * @returns AnaglyphArcRotateCamera
  46271. */
  46272. getClassName(): string;
  46273. }
  46274. }
  46275. declare module BABYLON {
  46276. /**
  46277. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46278. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46279. */
  46280. export class AnaglyphFreeCamera extends FreeCamera {
  46281. /**
  46282. * Creates a new AnaglyphFreeCamera
  46283. * @param name defines camera name
  46284. * @param position defines initial position
  46285. * @param interaxialDistance defines distance between each color axis
  46286. * @param scene defines the hosting scene
  46287. */
  46288. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46289. /**
  46290. * Gets camera class name
  46291. * @returns AnaglyphFreeCamera
  46292. */
  46293. getClassName(): string;
  46294. }
  46295. }
  46296. declare module BABYLON {
  46297. /**
  46298. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46299. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46300. */
  46301. export class AnaglyphGamepadCamera extends GamepadCamera {
  46302. /**
  46303. * Creates a new AnaglyphGamepadCamera
  46304. * @param name defines camera name
  46305. * @param position defines initial position
  46306. * @param interaxialDistance defines distance between each color axis
  46307. * @param scene defines the hosting scene
  46308. */
  46309. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46310. /**
  46311. * Gets camera class name
  46312. * @returns AnaglyphGamepadCamera
  46313. */
  46314. getClassName(): string;
  46315. }
  46316. }
  46317. declare module BABYLON {
  46318. /**
  46319. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46320. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46321. */
  46322. export class AnaglyphUniversalCamera extends UniversalCamera {
  46323. /**
  46324. * Creates a new AnaglyphUniversalCamera
  46325. * @param name defines camera name
  46326. * @param position defines initial position
  46327. * @param interaxialDistance defines distance between each color axis
  46328. * @param scene defines the hosting scene
  46329. */
  46330. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46331. /**
  46332. * Gets camera class name
  46333. * @returns AnaglyphUniversalCamera
  46334. */
  46335. getClassName(): string;
  46336. }
  46337. }
  46338. declare module BABYLON {
  46339. /**
  46340. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46341. * @see https://doc.babylonjs.com/features/cameras
  46342. */
  46343. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46344. /**
  46345. * Creates a new StereoscopicArcRotateCamera
  46346. * @param name defines camera name
  46347. * @param alpha defines alpha angle (in radians)
  46348. * @param beta defines beta angle (in radians)
  46349. * @param radius defines radius
  46350. * @param target defines camera target
  46351. * @param interaxialDistance defines distance between each color axis
  46352. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46353. * @param scene defines the hosting scene
  46354. */
  46355. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46356. /**
  46357. * Gets camera class name
  46358. * @returns StereoscopicArcRotateCamera
  46359. */
  46360. getClassName(): string;
  46361. }
  46362. }
  46363. declare module BABYLON {
  46364. /**
  46365. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46366. * @see https://doc.babylonjs.com/features/cameras
  46367. */
  46368. export class StereoscopicFreeCamera extends FreeCamera {
  46369. /**
  46370. * Creates a new StereoscopicFreeCamera
  46371. * @param name defines camera name
  46372. * @param position defines initial position
  46373. * @param interaxialDistance defines distance between each color axis
  46374. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46375. * @param scene defines the hosting scene
  46376. */
  46377. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46378. /**
  46379. * Gets camera class name
  46380. * @returns StereoscopicFreeCamera
  46381. */
  46382. getClassName(): string;
  46383. }
  46384. }
  46385. declare module BABYLON {
  46386. /**
  46387. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46388. * @see https://doc.babylonjs.com/features/cameras
  46389. */
  46390. export class StereoscopicGamepadCamera extends GamepadCamera {
  46391. /**
  46392. * Creates a new StereoscopicGamepadCamera
  46393. * @param name defines camera name
  46394. * @param position defines initial position
  46395. * @param interaxialDistance defines distance between each color axis
  46396. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46397. * @param scene defines the hosting scene
  46398. */
  46399. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46400. /**
  46401. * Gets camera class name
  46402. * @returns StereoscopicGamepadCamera
  46403. */
  46404. getClassName(): string;
  46405. }
  46406. }
  46407. declare module BABYLON {
  46408. /**
  46409. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46410. * @see https://doc.babylonjs.com/features/cameras
  46411. */
  46412. export class StereoscopicUniversalCamera extends UniversalCamera {
  46413. /**
  46414. * Creates a new StereoscopicUniversalCamera
  46415. * @param name defines camera name
  46416. * @param position defines initial position
  46417. * @param interaxialDistance defines distance between each color axis
  46418. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46419. * @param scene defines the hosting scene
  46420. */
  46421. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46422. /**
  46423. * Gets camera class name
  46424. * @returns StereoscopicUniversalCamera
  46425. */
  46426. getClassName(): string;
  46427. }
  46428. }
  46429. declare module BABYLON {
  46430. /**
  46431. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46432. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46433. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46434. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46435. */
  46436. export class VirtualJoysticksCamera extends FreeCamera {
  46437. /**
  46438. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46439. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46440. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46441. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46442. * @param name Define the name of the camera in the scene
  46443. * @param position Define the start position of the camera in the scene
  46444. * @param scene Define the scene the camera belongs to
  46445. */
  46446. constructor(name: string, position: Vector3, scene: Scene);
  46447. /**
  46448. * Gets the current object class name.
  46449. * @return the class name
  46450. */
  46451. getClassName(): string;
  46452. }
  46453. }
  46454. declare module BABYLON {
  46455. /**
  46456. * This represents all the required metrics to create a VR camera.
  46457. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46458. */
  46459. export class VRCameraMetrics {
  46460. /**
  46461. * Define the horizontal resolution off the screen.
  46462. */
  46463. hResolution: number;
  46464. /**
  46465. * Define the vertical resolution off the screen.
  46466. */
  46467. vResolution: number;
  46468. /**
  46469. * Define the horizontal screen size.
  46470. */
  46471. hScreenSize: number;
  46472. /**
  46473. * Define the vertical screen size.
  46474. */
  46475. vScreenSize: number;
  46476. /**
  46477. * Define the vertical screen center position.
  46478. */
  46479. vScreenCenter: number;
  46480. /**
  46481. * Define the distance of the eyes to the screen.
  46482. */
  46483. eyeToScreenDistance: number;
  46484. /**
  46485. * Define the distance between both lenses
  46486. */
  46487. lensSeparationDistance: number;
  46488. /**
  46489. * Define the distance between both viewer's eyes.
  46490. */
  46491. interpupillaryDistance: number;
  46492. /**
  46493. * Define the distortion factor of the VR postprocess.
  46494. * Please, touch with care.
  46495. */
  46496. distortionK: number[];
  46497. /**
  46498. * Define the chromatic aberration correction factors for the VR post process.
  46499. */
  46500. chromaAbCorrection: number[];
  46501. /**
  46502. * Define the scale factor of the post process.
  46503. * The smaller the better but the slower.
  46504. */
  46505. postProcessScaleFactor: number;
  46506. /**
  46507. * Define an offset for the lens center.
  46508. */
  46509. lensCenterOffset: number;
  46510. /**
  46511. * Define if the current vr camera should compensate the distortion of the lense or not.
  46512. */
  46513. compensateDistortion: boolean;
  46514. /**
  46515. * Defines if multiview should be enabled when rendering (Default: false)
  46516. */
  46517. multiviewEnabled: boolean;
  46518. /**
  46519. * Gets the rendering aspect ratio based on the provided resolutions.
  46520. */
  46521. get aspectRatio(): number;
  46522. /**
  46523. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46524. */
  46525. get aspectRatioFov(): number;
  46526. /**
  46527. * @hidden
  46528. */
  46529. get leftHMatrix(): Matrix;
  46530. /**
  46531. * @hidden
  46532. */
  46533. get rightHMatrix(): Matrix;
  46534. /**
  46535. * @hidden
  46536. */
  46537. get leftPreViewMatrix(): Matrix;
  46538. /**
  46539. * @hidden
  46540. */
  46541. get rightPreViewMatrix(): Matrix;
  46542. /**
  46543. * Get the default VRMetrics based on the most generic setup.
  46544. * @returns the default vr metrics
  46545. */
  46546. static GetDefault(): VRCameraMetrics;
  46547. }
  46548. }
  46549. declare module BABYLON {
  46550. /** @hidden */
  46551. export var vrDistortionCorrectionPixelShader: {
  46552. name: string;
  46553. shader: string;
  46554. };
  46555. }
  46556. declare module BABYLON {
  46557. /**
  46558. * VRDistortionCorrectionPostProcess used for mobile VR
  46559. */
  46560. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46561. private _isRightEye;
  46562. private _distortionFactors;
  46563. private _postProcessScaleFactor;
  46564. private _lensCenterOffset;
  46565. private _scaleIn;
  46566. private _scaleFactor;
  46567. private _lensCenter;
  46568. /**
  46569. * Gets a string identifying the name of the class
  46570. * @returns "VRDistortionCorrectionPostProcess" string
  46571. */
  46572. getClassName(): string;
  46573. /**
  46574. * Initializes the VRDistortionCorrectionPostProcess
  46575. * @param name The name of the effect.
  46576. * @param camera The camera to apply the render pass to.
  46577. * @param isRightEye If this is for the right eye distortion
  46578. * @param vrMetrics All the required metrics for the VR camera
  46579. */
  46580. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46581. }
  46582. }
  46583. declare module BABYLON {
  46584. /**
  46585. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46586. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46587. */
  46588. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46589. /**
  46590. * Creates a new VRDeviceOrientationArcRotateCamera
  46591. * @param name defines camera name
  46592. * @param alpha defines the camera rotation along the logitudinal axis
  46593. * @param beta defines the camera rotation along the latitudinal axis
  46594. * @param radius defines the camera distance from its target
  46595. * @param target defines the camera target
  46596. * @param scene defines the scene the camera belongs to
  46597. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46598. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46599. */
  46600. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46601. /**
  46602. * Gets camera class name
  46603. * @returns VRDeviceOrientationArcRotateCamera
  46604. */
  46605. getClassName(): string;
  46606. }
  46607. }
  46608. declare module BABYLON {
  46609. /**
  46610. * Camera used to simulate VR rendering (based on FreeCamera)
  46611. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46612. */
  46613. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46614. /**
  46615. * Creates a new VRDeviceOrientationFreeCamera
  46616. * @param name defines camera name
  46617. * @param position defines the start position of the camera
  46618. * @param scene defines the scene the camera belongs to
  46619. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46620. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46621. */
  46622. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46623. /**
  46624. * Gets camera class name
  46625. * @returns VRDeviceOrientationFreeCamera
  46626. */
  46627. getClassName(): string;
  46628. }
  46629. }
  46630. declare module BABYLON {
  46631. /**
  46632. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46633. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46634. */
  46635. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46636. /**
  46637. * Creates a new VRDeviceOrientationGamepadCamera
  46638. * @param name defines camera name
  46639. * @param position defines the start position of the camera
  46640. * @param scene defines the scene the camera belongs to
  46641. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46642. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46643. */
  46644. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46645. /**
  46646. * Gets camera class name
  46647. * @returns VRDeviceOrientationGamepadCamera
  46648. */
  46649. getClassName(): string;
  46650. }
  46651. }
  46652. declare module BABYLON {
  46653. /**
  46654. * A class extending Texture allowing drawing on a texture
  46655. * @see https://doc.babylonjs.com/how_to/dynamictexture
  46656. */
  46657. export class DynamicTexture extends Texture {
  46658. private _generateMipMaps;
  46659. private _canvas;
  46660. private _context;
  46661. /**
  46662. * Creates a DynamicTexture
  46663. * @param name defines the name of the texture
  46664. * @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
  46665. * @param scene defines the scene where you want the texture
  46666. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46667. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  46668. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  46669. */
  46670. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46671. /**
  46672. * Get the current class name of the texture useful for serialization or dynamic coding.
  46673. * @returns "DynamicTexture"
  46674. */
  46675. getClassName(): string;
  46676. /**
  46677. * Gets the current state of canRescale
  46678. */
  46679. get canRescale(): boolean;
  46680. private _recreate;
  46681. /**
  46682. * Scales the texture
  46683. * @param ratio the scale factor to apply to both width and height
  46684. */
  46685. scale(ratio: number): void;
  46686. /**
  46687. * Resizes the texture
  46688. * @param width the new width
  46689. * @param height the new height
  46690. */
  46691. scaleTo(width: number, height: number): void;
  46692. /**
  46693. * Gets the context of the canvas used by the texture
  46694. * @returns the canvas context of the dynamic texture
  46695. */
  46696. getContext(): CanvasRenderingContext2D;
  46697. /**
  46698. * Clears the texture
  46699. */
  46700. clear(): void;
  46701. /**
  46702. * Updates the texture
  46703. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46704. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46705. */
  46706. update(invertY?: boolean, premulAlpha?: boolean): void;
  46707. /**
  46708. * Draws text onto the texture
  46709. * @param text defines the text to be drawn
  46710. * @param x defines the placement of the text from the left
  46711. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46712. * @param font defines the font to be used with font-style, font-size, font-name
  46713. * @param color defines the color used for the text
  46714. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46715. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46716. * @param update defines whether texture is immediately update (default is true)
  46717. */
  46718. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  46719. /**
  46720. * Clones the texture
  46721. * @returns the clone of the texture.
  46722. */
  46723. clone(): DynamicTexture;
  46724. /**
  46725. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46726. * @returns a serialized dynamic texture object
  46727. */
  46728. serialize(): any;
  46729. private _IsCanvasElement;
  46730. /** @hidden */
  46731. _rebuild(): void;
  46732. }
  46733. }
  46734. declare module BABYLON {
  46735. /**
  46736. * Class containing static functions to help procedurally build meshes
  46737. */
  46738. export class GroundBuilder {
  46739. /**
  46740. * Creates a ground mesh
  46741. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46742. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46744. * @param name defines the name of the mesh
  46745. * @param options defines the options used to create the mesh
  46746. * @param scene defines the hosting scene
  46747. * @returns the ground mesh
  46748. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46749. */
  46750. static CreateGround(name: string, options: {
  46751. width?: number;
  46752. height?: number;
  46753. subdivisions?: number;
  46754. subdivisionsX?: number;
  46755. subdivisionsY?: number;
  46756. updatable?: boolean;
  46757. }, scene: any): Mesh;
  46758. /**
  46759. * Creates a tiled ground mesh
  46760. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46761. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46762. * * 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
  46763. * * 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
  46764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46765. * @param name defines the name of the mesh
  46766. * @param options defines the options used to create the mesh
  46767. * @param scene defines the hosting scene
  46768. * @returns the tiled ground mesh
  46769. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46770. */
  46771. static CreateTiledGround(name: string, options: {
  46772. xmin: number;
  46773. zmin: number;
  46774. xmax: number;
  46775. zmax: number;
  46776. subdivisions?: {
  46777. w: number;
  46778. h: number;
  46779. };
  46780. precision?: {
  46781. w: number;
  46782. h: number;
  46783. };
  46784. updatable?: boolean;
  46785. }, scene?: Nullable<Scene>): Mesh;
  46786. /**
  46787. * Creates a ground mesh from a height map
  46788. * * The parameter `url` sets the URL of the height map image resource.
  46789. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46790. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46791. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46792. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46793. * * 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.
  46794. * * 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).
  46795. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  46796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46797. * @param name defines the name of the mesh
  46798. * @param url defines the url to the height map
  46799. * @param options defines the options used to create the mesh
  46800. * @param scene defines the hosting scene
  46801. * @returns the ground mesh
  46802. * @see https://doc.babylonjs.com/babylon101/height_map
  46803. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  46804. */
  46805. static CreateGroundFromHeightMap(name: string, url: string, options: {
  46806. width?: number;
  46807. height?: number;
  46808. subdivisions?: number;
  46809. minHeight?: number;
  46810. maxHeight?: number;
  46811. colorFilter?: Color3;
  46812. alphaFilter?: number;
  46813. updatable?: boolean;
  46814. onReady?: (mesh: GroundMesh) => void;
  46815. }, scene?: Nullable<Scene>): GroundMesh;
  46816. }
  46817. }
  46818. declare module BABYLON {
  46819. /**
  46820. * Class containing static functions to help procedurally build meshes
  46821. */
  46822. export class TorusBuilder {
  46823. /**
  46824. * Creates a torus mesh
  46825. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46826. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46827. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46828. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46829. * * 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
  46830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46831. * @param name defines the name of the mesh
  46832. * @param options defines the options used to create the mesh
  46833. * @param scene defines the hosting scene
  46834. * @returns the torus mesh
  46835. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46836. */
  46837. static CreateTorus(name: string, options: {
  46838. diameter?: number;
  46839. thickness?: number;
  46840. tessellation?: number;
  46841. updatable?: boolean;
  46842. sideOrientation?: number;
  46843. frontUVs?: Vector4;
  46844. backUVs?: Vector4;
  46845. }, scene: any): Mesh;
  46846. }
  46847. }
  46848. declare module BABYLON {
  46849. /**
  46850. * Class containing static functions to help procedurally build meshes
  46851. */
  46852. export class CylinderBuilder {
  46853. /**
  46854. * Creates a cylinder or a cone mesh
  46855. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46856. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46857. * * 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.
  46858. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46859. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46860. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46861. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46862. * * 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).
  46863. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46864. * * 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).
  46865. * * 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
  46866. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46867. * * 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
  46868. * * 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.
  46869. * * If `enclose` is false, a ring surface is one element.
  46870. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46871. * * 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
  46872. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46873. * * 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
  46874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46875. * @param name defines the name of the mesh
  46876. * @param options defines the options used to create the mesh
  46877. * @param scene defines the hosting scene
  46878. * @returns the cylinder mesh
  46879. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46880. */
  46881. static CreateCylinder(name: string, options: {
  46882. height?: number;
  46883. diameterTop?: number;
  46884. diameterBottom?: number;
  46885. diameter?: number;
  46886. tessellation?: number;
  46887. subdivisions?: number;
  46888. arc?: number;
  46889. faceColors?: Color4[];
  46890. faceUV?: Vector4[];
  46891. updatable?: boolean;
  46892. hasRings?: boolean;
  46893. enclose?: boolean;
  46894. cap?: number;
  46895. sideOrientation?: number;
  46896. frontUVs?: Vector4;
  46897. backUVs?: Vector4;
  46898. }, scene: any): Mesh;
  46899. }
  46900. }
  46901. declare module BABYLON {
  46902. /**
  46903. * States of the webXR experience
  46904. */
  46905. export enum WebXRState {
  46906. /**
  46907. * Transitioning to being in XR mode
  46908. */
  46909. ENTERING_XR = 0,
  46910. /**
  46911. * Transitioning to non XR mode
  46912. */
  46913. EXITING_XR = 1,
  46914. /**
  46915. * In XR mode and presenting
  46916. */
  46917. IN_XR = 2,
  46918. /**
  46919. * Not entered XR mode
  46920. */
  46921. NOT_IN_XR = 3
  46922. }
  46923. /**
  46924. * Abstraction of the XR render target
  46925. */
  46926. export interface WebXRRenderTarget extends IDisposable {
  46927. /**
  46928. * xrpresent context of the canvas which can be used to display/mirror xr content
  46929. */
  46930. canvasContext: WebGLRenderingContext;
  46931. /**
  46932. * xr layer for the canvas
  46933. */
  46934. xrLayer: Nullable<XRWebGLLayer>;
  46935. /**
  46936. * Initializes the xr layer for the session
  46937. * @param xrSession xr session
  46938. * @returns a promise that will resolve once the XR Layer has been created
  46939. */
  46940. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46941. }
  46942. }
  46943. declare module BABYLON {
  46944. /**
  46945. * COnfiguration object for WebXR output canvas
  46946. */
  46947. export class WebXRManagedOutputCanvasOptions {
  46948. /**
  46949. * An optional canvas in case you wish to create it yourself and provide it here.
  46950. * If not provided, a new canvas will be created
  46951. */
  46952. canvasElement?: HTMLCanvasElement;
  46953. /**
  46954. * Options for this XR Layer output
  46955. */
  46956. canvasOptions?: XRWebGLLayerOptions;
  46957. /**
  46958. * CSS styling for a newly created canvas (if not provided)
  46959. */
  46960. newCanvasCssStyle?: string;
  46961. /**
  46962. * Get the default values of the configuration object
  46963. * @param engine defines the engine to use (can be null)
  46964. * @returns default values of this configuration object
  46965. */
  46966. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  46967. }
  46968. /**
  46969. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  46970. */
  46971. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  46972. private _options;
  46973. private _canvas;
  46974. private _engine;
  46975. private _originalCanvasSize;
  46976. /**
  46977. * Rendering context of the canvas which can be used to display/mirror xr content
  46978. */
  46979. canvasContext: WebGLRenderingContext;
  46980. /**
  46981. * xr layer for the canvas
  46982. */
  46983. xrLayer: Nullable<XRWebGLLayer>;
  46984. /**
  46985. * Obseervers registered here will be triggered when the xr layer was initialized
  46986. */
  46987. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  46988. /**
  46989. * Initializes the canvas to be added/removed upon entering/exiting xr
  46990. * @param _xrSessionManager The XR Session manager
  46991. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  46992. */
  46993. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  46994. /**
  46995. * Disposes of the object
  46996. */
  46997. dispose(): void;
  46998. /**
  46999. * Initializes the xr layer for the session
  47000. * @param xrSession xr session
  47001. * @returns a promise that will resolve once the XR Layer has been created
  47002. */
  47003. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47004. private _addCanvas;
  47005. private _removeCanvas;
  47006. private _setCanvasSize;
  47007. private _setManagedOutputCanvas;
  47008. }
  47009. }
  47010. declare module BABYLON {
  47011. /**
  47012. * Manages an XRSession to work with Babylon's engine
  47013. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  47014. */
  47015. export class WebXRSessionManager implements IDisposable {
  47016. /** The scene which the session should be created for */
  47017. scene: Scene;
  47018. private _referenceSpace;
  47019. private _rttProvider;
  47020. private _sessionEnded;
  47021. private _xrNavigator;
  47022. private baseLayer;
  47023. /**
  47024. * The base reference space from which the session started. good if you want to reset your
  47025. * reference space
  47026. */
  47027. baseReferenceSpace: XRReferenceSpace;
  47028. /**
  47029. * Current XR frame
  47030. */
  47031. currentFrame: Nullable<XRFrame>;
  47032. /** WebXR timestamp updated every frame */
  47033. currentTimestamp: number;
  47034. /**
  47035. * Used just in case of a failure to initialize an immersive session.
  47036. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  47037. */
  47038. defaultHeightCompensation: number;
  47039. /**
  47040. * Fires every time a new xrFrame arrives which can be used to update the camera
  47041. */
  47042. onXRFrameObservable: Observable<XRFrame>;
  47043. /**
  47044. * Fires when the reference space changed
  47045. */
  47046. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  47047. /**
  47048. * Fires when the xr session is ended either by the device or manually done
  47049. */
  47050. onXRSessionEnded: Observable<any>;
  47051. /**
  47052. * Fires when the xr session is ended either by the device or manually done
  47053. */
  47054. onXRSessionInit: Observable<XRSession>;
  47055. /**
  47056. * Underlying xr session
  47057. */
  47058. session: XRSession;
  47059. /**
  47060. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  47061. * or get the offset the player is currently at.
  47062. */
  47063. viewerReferenceSpace: XRReferenceSpace;
  47064. /**
  47065. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  47066. * @param scene The scene which the session should be created for
  47067. */
  47068. constructor(
  47069. /** The scene which the session should be created for */
  47070. scene: Scene);
  47071. /**
  47072. * The current reference space used in this session. This reference space can constantly change!
  47073. * It is mainly used to offset the camera's position.
  47074. */
  47075. get referenceSpace(): XRReferenceSpace;
  47076. /**
  47077. * Set a new reference space and triggers the observable
  47078. */
  47079. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  47080. /**
  47081. * Disposes of the session manager
  47082. */
  47083. dispose(): void;
  47084. /**
  47085. * Stops the xrSession and restores the render loop
  47086. * @returns Promise which resolves after it exits XR
  47087. */
  47088. exitXRAsync(): Promise<void>;
  47089. /**
  47090. * Gets the correct render target texture to be rendered this frame for this eye
  47091. * @param eye the eye for which to get the render target
  47092. * @returns the render target for the specified eye
  47093. */
  47094. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  47095. /**
  47096. * Creates a WebXRRenderTarget object for the XR session
  47097. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  47098. * @param options optional options to provide when creating a new render target
  47099. * @returns a WebXR render target to which the session can render
  47100. */
  47101. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  47102. /**
  47103. * Initializes the manager
  47104. * After initialization enterXR can be called to start an XR session
  47105. * @returns Promise which resolves after it is initialized
  47106. */
  47107. initializeAsync(): Promise<void>;
  47108. /**
  47109. * Initializes an xr session
  47110. * @param xrSessionMode mode to initialize
  47111. * @param xrSessionInit defines optional and required values to pass to the session builder
  47112. * @returns a promise which will resolve once the session has been initialized
  47113. */
  47114. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  47115. /**
  47116. * Checks if a session would be supported for the creation options specified
  47117. * @param sessionMode session mode to check if supported eg. immersive-vr
  47118. * @returns A Promise that resolves to true if supported and false if not
  47119. */
  47120. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47121. /**
  47122. * Resets the reference space to the one started the session
  47123. */
  47124. resetReferenceSpace(): void;
  47125. /**
  47126. * Starts rendering to the xr layer
  47127. */
  47128. runXRRenderLoop(): void;
  47129. /**
  47130. * Sets the reference space on the xr session
  47131. * @param referenceSpaceType space to set
  47132. * @returns a promise that will resolve once the reference space has been set
  47133. */
  47134. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47135. /**
  47136. * Updates the render state of the session
  47137. * @param state state to set
  47138. * @returns a promise that resolves once the render state has been updated
  47139. */
  47140. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47141. /**
  47142. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47143. * @param sessionMode defines the session to test
  47144. * @returns a promise with boolean as final value
  47145. */
  47146. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47147. private _createRenderTargetTexture;
  47148. }
  47149. }
  47150. declare module BABYLON {
  47151. /**
  47152. * WebXR Camera which holds the views for the xrSession
  47153. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47154. */
  47155. export class WebXRCamera extends FreeCamera {
  47156. private _xrSessionManager;
  47157. private _firstFrame;
  47158. private _referenceQuaternion;
  47159. private _referencedPosition;
  47160. private _xrInvPositionCache;
  47161. private _xrInvQuaternionCache;
  47162. /**
  47163. * Observable raised before camera teleportation
  47164. */
  47165. onBeforeCameraTeleport: Observable<Vector3>;
  47166. /**
  47167. * Observable raised after camera teleportation
  47168. */
  47169. onAfterCameraTeleport: Observable<Vector3>;
  47170. /**
  47171. * Should position compensation execute on first frame.
  47172. * This is used when copying the position from a native (non XR) camera
  47173. */
  47174. compensateOnFirstFrame: boolean;
  47175. /**
  47176. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47177. * @param name the name of the camera
  47178. * @param scene the scene to add the camera to
  47179. * @param _xrSessionManager a constructed xr session manager
  47180. */
  47181. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47182. /**
  47183. * Return the user's height, unrelated to the current ground.
  47184. * This will be the y position of this camera, when ground level is 0.
  47185. */
  47186. get realWorldHeight(): number;
  47187. /** @hidden */
  47188. _updateForDualEyeDebugging(): void;
  47189. /**
  47190. * Sets this camera's transformation based on a non-vr camera
  47191. * @param otherCamera the non-vr camera to copy the transformation from
  47192. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47193. */
  47194. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47195. /**
  47196. * Gets the current instance class name ("WebXRCamera").
  47197. * @returns the class name
  47198. */
  47199. getClassName(): string;
  47200. private _rotate180;
  47201. private _updateFromXRSession;
  47202. private _updateNumberOfRigCameras;
  47203. private _updateReferenceSpace;
  47204. private _updateReferenceSpaceOffset;
  47205. }
  47206. }
  47207. declare module BABYLON {
  47208. /**
  47209. * Defining the interface required for a (webxr) feature
  47210. */
  47211. export interface IWebXRFeature extends IDisposable {
  47212. /**
  47213. * Is this feature attached
  47214. */
  47215. attached: boolean;
  47216. /**
  47217. * Should auto-attach be disabled?
  47218. */
  47219. disableAutoAttach: boolean;
  47220. /**
  47221. * Attach the feature to the session
  47222. * Will usually be called by the features manager
  47223. *
  47224. * @param force should attachment be forced (even when already attached)
  47225. * @returns true if successful.
  47226. */
  47227. attach(force?: boolean): boolean;
  47228. /**
  47229. * Detach the feature from the session
  47230. * Will usually be called by the features manager
  47231. *
  47232. * @returns true if successful.
  47233. */
  47234. detach(): boolean;
  47235. /**
  47236. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  47237. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  47238. *
  47239. * @returns whether or not the feature is compatible in this environment
  47240. */
  47241. isCompatible(): boolean;
  47242. /**
  47243. * Was this feature disposed;
  47244. */
  47245. isDisposed: boolean;
  47246. /**
  47247. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  47248. */
  47249. xrNativeFeatureName?: string;
  47250. /**
  47251. * A list of (Babylon WebXR) features this feature depends on
  47252. */
  47253. dependsOn?: string[];
  47254. }
  47255. /**
  47256. * A list of the currently available features without referencing them
  47257. */
  47258. export class WebXRFeatureName {
  47259. /**
  47260. * The name of the anchor system feature
  47261. */
  47262. static readonly ANCHOR_SYSTEM: string;
  47263. /**
  47264. * The name of the background remover feature
  47265. */
  47266. static readonly BACKGROUND_REMOVER: string;
  47267. /**
  47268. * The name of the hit test feature
  47269. */
  47270. static readonly HIT_TEST: string;
  47271. /**
  47272. * physics impostors for xr controllers feature
  47273. */
  47274. static readonly PHYSICS_CONTROLLERS: string;
  47275. /**
  47276. * The name of the plane detection feature
  47277. */
  47278. static readonly PLANE_DETECTION: string;
  47279. /**
  47280. * The name of the pointer selection feature
  47281. */
  47282. static readonly POINTER_SELECTION: string;
  47283. /**
  47284. * The name of the teleportation feature
  47285. */
  47286. static readonly TELEPORTATION: string;
  47287. /**
  47288. * The name of the feature points feature.
  47289. */
  47290. static readonly FEATURE_POINTS: string;
  47291. /**
  47292. * The name of the hand tracking feature.
  47293. */
  47294. static readonly HAND_TRACKING: string;
  47295. }
  47296. /**
  47297. * Defining the constructor of a feature. Used to register the modules.
  47298. */
  47299. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  47300. /**
  47301. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47302. * It is mainly used in AR sessions.
  47303. *
  47304. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47305. */
  47306. export class WebXRFeaturesManager implements IDisposable {
  47307. private _xrSessionManager;
  47308. private static readonly _AvailableFeatures;
  47309. private _features;
  47310. /**
  47311. * constructs a new features manages.
  47312. *
  47313. * @param _xrSessionManager an instance of WebXRSessionManager
  47314. */
  47315. constructor(_xrSessionManager: WebXRSessionManager);
  47316. /**
  47317. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47318. * Mainly used internally.
  47319. *
  47320. * @param featureName the name of the feature to register
  47321. * @param constructorFunction the function used to construct the module
  47322. * @param version the (babylon) version of the module
  47323. * @param stable is that a stable version of this module
  47324. */
  47325. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47326. /**
  47327. * Returns a constructor of a specific feature.
  47328. *
  47329. * @param featureName the name of the feature to construct
  47330. * @param version the version of the feature to load
  47331. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47332. * @param options optional options provided to the module.
  47333. * @returns a function that, when called, will return a new instance of this feature
  47334. */
  47335. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  47336. /**
  47337. * Can be used to return the list of features currently registered
  47338. *
  47339. * @returns an Array of available features
  47340. */
  47341. static GetAvailableFeatures(): string[];
  47342. /**
  47343. * Gets the versions available for a specific feature
  47344. * @param featureName the name of the feature
  47345. * @returns an array with the available versions
  47346. */
  47347. static GetAvailableVersions(featureName: string): string[];
  47348. /**
  47349. * Return the latest unstable version of this feature
  47350. * @param featureName the name of the feature to search
  47351. * @returns the version number. if not found will return -1
  47352. */
  47353. static GetLatestVersionOfFeature(featureName: string): number;
  47354. /**
  47355. * Return the latest stable version of this feature
  47356. * @param featureName the name of the feature to search
  47357. * @returns the version number. if not found will return -1
  47358. */
  47359. static GetStableVersionOfFeature(featureName: string): number;
  47360. /**
  47361. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47362. * Can be used during a session to start a feature
  47363. * @param featureName the name of feature to attach
  47364. */
  47365. attachFeature(featureName: string): void;
  47366. /**
  47367. * Can be used inside a session or when the session ends to detach a specific feature
  47368. * @param featureName the name of the feature to detach
  47369. */
  47370. detachFeature(featureName: string): void;
  47371. /**
  47372. * Used to disable an already-enabled feature
  47373. * The feature will be disposed and will be recreated once enabled.
  47374. * @param featureName the feature to disable
  47375. * @returns true if disable was successful
  47376. */
  47377. disableFeature(featureName: string | {
  47378. Name: string;
  47379. }): boolean;
  47380. /**
  47381. * dispose this features manager
  47382. */
  47383. dispose(): void;
  47384. /**
  47385. * 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.
  47386. * 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.
  47387. *
  47388. * @param featureName the name of the feature to load or the class of the feature
  47389. * @param version optional version to load. if not provided the latest version will be enabled
  47390. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47391. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47392. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  47393. * @returns a new constructed feature or throws an error if feature not found.
  47394. */
  47395. enableFeature(featureName: string | {
  47396. Name: string;
  47397. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  47398. /**
  47399. * get the implementation of an enabled feature.
  47400. * @param featureName the name of the feature to load
  47401. * @returns the feature class, if found
  47402. */
  47403. getEnabledFeature(featureName: string): IWebXRFeature;
  47404. /**
  47405. * Get the list of enabled features
  47406. * @returns an array of enabled features
  47407. */
  47408. getEnabledFeatures(): string[];
  47409. /**
  47410. * This function will exten the session creation configuration object with enabled features.
  47411. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  47412. * according to the defined "required" variable, provided during enableFeature call
  47413. * @param xrSessionInit the xr Session init object to extend
  47414. *
  47415. * @returns an extended XRSessionInit object
  47416. */
  47417. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  47418. }
  47419. }
  47420. declare module BABYLON {
  47421. /**
  47422. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47423. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  47424. */
  47425. export class WebXRExperienceHelper implements IDisposable {
  47426. private scene;
  47427. private _nonVRCamera;
  47428. private _originalSceneAutoClear;
  47429. private _supported;
  47430. /**
  47431. * Camera used to render xr content
  47432. */
  47433. camera: WebXRCamera;
  47434. /** A features manager for this xr session */
  47435. featuresManager: WebXRFeaturesManager;
  47436. /**
  47437. * Observers registered here will be triggered after the camera's initial transformation is set
  47438. * This can be used to set a different ground level or an extra rotation.
  47439. *
  47440. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47441. * to the position set after this observable is done executing.
  47442. */
  47443. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47444. /**
  47445. * Fires when the state of the experience helper has changed
  47446. */
  47447. onStateChangedObservable: Observable<WebXRState>;
  47448. /** Session manager used to keep track of xr session */
  47449. sessionManager: WebXRSessionManager;
  47450. /**
  47451. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47452. */
  47453. state: WebXRState;
  47454. /**
  47455. * Creates a WebXRExperienceHelper
  47456. * @param scene The scene the helper should be created in
  47457. */
  47458. private constructor();
  47459. /**
  47460. * Creates the experience helper
  47461. * @param scene the scene to attach the experience helper to
  47462. * @returns a promise for the experience helper
  47463. */
  47464. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47465. /**
  47466. * Disposes of the experience helper
  47467. */
  47468. dispose(): void;
  47469. /**
  47470. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47471. * @param sessionMode options for the XR session
  47472. * @param referenceSpaceType frame of reference of the XR session
  47473. * @param renderTarget the output canvas that will be used to enter XR mode
  47474. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47475. * @returns promise that resolves after xr mode has entered
  47476. */
  47477. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47478. /**
  47479. * Exits XR mode and returns the scene to its original state
  47480. * @returns promise that resolves after xr mode has exited
  47481. */
  47482. exitXRAsync(): Promise<void>;
  47483. private _nonXRToXRCamera;
  47484. private _setState;
  47485. }
  47486. }
  47487. declare module BABYLON {
  47488. /**
  47489. * X-Y values for axes in WebXR
  47490. */
  47491. export interface IWebXRMotionControllerAxesValue {
  47492. /**
  47493. * The value of the x axis
  47494. */
  47495. x: number;
  47496. /**
  47497. * The value of the y-axis
  47498. */
  47499. y: number;
  47500. }
  47501. /**
  47502. * changed / previous values for the values of this component
  47503. */
  47504. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47505. /**
  47506. * current (this frame) value
  47507. */
  47508. current: T;
  47509. /**
  47510. * previous (last change) value
  47511. */
  47512. previous: T;
  47513. }
  47514. /**
  47515. * Represents changes in the component between current frame and last values recorded
  47516. */
  47517. export interface IWebXRMotionControllerComponentChanges {
  47518. /**
  47519. * will be populated with previous and current values if axes changed
  47520. */
  47521. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47522. /**
  47523. * will be populated with previous and current values if pressed changed
  47524. */
  47525. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47526. /**
  47527. * will be populated with previous and current values if touched changed
  47528. */
  47529. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47530. /**
  47531. * will be populated with previous and current values if value changed
  47532. */
  47533. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47534. }
  47535. /**
  47536. * This class represents a single component (for example button or thumbstick) of a motion controller
  47537. */
  47538. export class WebXRControllerComponent implements IDisposable {
  47539. /**
  47540. * the id of this component
  47541. */
  47542. id: string;
  47543. /**
  47544. * the type of the component
  47545. */
  47546. type: MotionControllerComponentType;
  47547. private _buttonIndex;
  47548. private _axesIndices;
  47549. private _axes;
  47550. private _changes;
  47551. private _currentValue;
  47552. private _hasChanges;
  47553. private _pressed;
  47554. private _touched;
  47555. /**
  47556. * button component type
  47557. */
  47558. static BUTTON_TYPE: MotionControllerComponentType;
  47559. /**
  47560. * squeeze component type
  47561. */
  47562. static SQUEEZE_TYPE: MotionControllerComponentType;
  47563. /**
  47564. * Thumbstick component type
  47565. */
  47566. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47567. /**
  47568. * Touchpad component type
  47569. */
  47570. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47571. /**
  47572. * trigger component type
  47573. */
  47574. static TRIGGER_TYPE: MotionControllerComponentType;
  47575. /**
  47576. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47577. * the axes data changes
  47578. */
  47579. onAxisValueChangedObservable: Observable<{
  47580. x: number;
  47581. y: number;
  47582. }>;
  47583. /**
  47584. * Observers registered here will be triggered when the state of a button changes
  47585. * State change is either pressed / touched / value
  47586. */
  47587. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47588. /**
  47589. * Creates a new component for a motion controller.
  47590. * It is created by the motion controller itself
  47591. *
  47592. * @param id the id of this component
  47593. * @param type the type of the component
  47594. * @param _buttonIndex index in the buttons array of the gamepad
  47595. * @param _axesIndices indices of the values in the axes array of the gamepad
  47596. */
  47597. constructor(
  47598. /**
  47599. * the id of this component
  47600. */
  47601. id: string,
  47602. /**
  47603. * the type of the component
  47604. */
  47605. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47606. /**
  47607. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47608. */
  47609. get axes(): IWebXRMotionControllerAxesValue;
  47610. /**
  47611. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47612. */
  47613. get changes(): IWebXRMotionControllerComponentChanges;
  47614. /**
  47615. * Return whether or not the component changed the last frame
  47616. */
  47617. get hasChanges(): boolean;
  47618. /**
  47619. * is the button currently pressed
  47620. */
  47621. get pressed(): boolean;
  47622. /**
  47623. * is the button currently touched
  47624. */
  47625. get touched(): boolean;
  47626. /**
  47627. * Get the current value of this component
  47628. */
  47629. get value(): number;
  47630. /**
  47631. * Dispose this component
  47632. */
  47633. dispose(): void;
  47634. /**
  47635. * Are there axes correlating to this component
  47636. * @return true is axes data is available
  47637. */
  47638. isAxes(): boolean;
  47639. /**
  47640. * Is this component a button (hence - pressable)
  47641. * @returns true if can be pressed
  47642. */
  47643. isButton(): boolean;
  47644. /**
  47645. * update this component using the gamepad object it is in. Called on every frame
  47646. * @param nativeController the native gamepad controller object
  47647. */
  47648. update(nativeController: IMinimalMotionControllerObject): void;
  47649. }
  47650. }
  47651. declare module BABYLON {
  47652. /**
  47653. * Interface used to represent data loading progression
  47654. */
  47655. export interface ISceneLoaderProgressEvent {
  47656. /**
  47657. * Defines if data length to load can be evaluated
  47658. */
  47659. readonly lengthComputable: boolean;
  47660. /**
  47661. * Defines the loaded data length
  47662. */
  47663. readonly loaded: number;
  47664. /**
  47665. * Defines the data length to load
  47666. */
  47667. readonly total: number;
  47668. }
  47669. /**
  47670. * Interface used by SceneLoader plugins to define supported file extensions
  47671. */
  47672. export interface ISceneLoaderPluginExtensions {
  47673. /**
  47674. * Defines the list of supported extensions
  47675. */
  47676. [extension: string]: {
  47677. isBinary: boolean;
  47678. };
  47679. }
  47680. /**
  47681. * Interface used by SceneLoader plugin factory
  47682. */
  47683. export interface ISceneLoaderPluginFactory {
  47684. /**
  47685. * Defines the name of the factory
  47686. */
  47687. name: string;
  47688. /**
  47689. * Function called to create a new plugin
  47690. * @return the new plugin
  47691. */
  47692. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47693. /**
  47694. * The callback that returns true if the data can be directly loaded.
  47695. * @param data string containing the file data
  47696. * @returns if the data can be loaded directly
  47697. */
  47698. canDirectLoad?(data: string): boolean;
  47699. }
  47700. /**
  47701. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47702. */
  47703. export interface ISceneLoaderPluginBase {
  47704. /**
  47705. * The friendly name of this plugin.
  47706. */
  47707. name: string;
  47708. /**
  47709. * The file extensions supported by this plugin.
  47710. */
  47711. extensions: string | ISceneLoaderPluginExtensions;
  47712. /**
  47713. * The callback called when loading from a url.
  47714. * @param scene scene loading this url
  47715. * @param url url to load
  47716. * @param onSuccess callback called when the file successfully loads
  47717. * @param onProgress callback called while file is loading (if the server supports this mode)
  47718. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  47719. * @param onError callback called when the file fails to load
  47720. * @returns a file request object
  47721. */
  47722. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47723. /**
  47724. * The callback called when loading from a file object.
  47725. * @param scene scene loading this file
  47726. * @param file defines the file to load
  47727. * @param onSuccess defines the callback to call when data is loaded
  47728. * @param onProgress defines the callback to call during loading process
  47729. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  47730. * @param onError defines the callback to call when an error occurs
  47731. * @returns a file request object
  47732. */
  47733. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47734. /**
  47735. * The callback that returns true if the data can be directly loaded.
  47736. * @param data string containing the file data
  47737. * @returns if the data can be loaded directly
  47738. */
  47739. canDirectLoad?(data: string): boolean;
  47740. /**
  47741. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  47742. * @param scene scene loading this data
  47743. * @param data string containing the data
  47744. * @returns data to pass to the plugin
  47745. */
  47746. directLoad?(scene: Scene, data: string): any;
  47747. /**
  47748. * The callback that allows custom handling of the root url based on the response url.
  47749. * @param rootUrl the original root url
  47750. * @param responseURL the response url if available
  47751. * @returns the new root url
  47752. */
  47753. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  47754. }
  47755. /**
  47756. * Interface used to define a SceneLoader plugin
  47757. */
  47758. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  47759. /**
  47760. * Import meshes into a scene.
  47761. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47762. * @param scene The scene to import into
  47763. * @param data The data to import
  47764. * @param rootUrl The root url for scene and resources
  47765. * @param meshes The meshes array to import into
  47766. * @param particleSystems The particle systems array to import into
  47767. * @param skeletons The skeletons array to import into
  47768. * @param onError The callback when import fails
  47769. * @returns True if successful or false otherwise
  47770. */
  47771. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  47772. /**
  47773. * Load into a scene.
  47774. * @param scene The scene to load into
  47775. * @param data The data to import
  47776. * @param rootUrl The root url for scene and resources
  47777. * @param onError The callback when import fails
  47778. * @returns True if successful or false otherwise
  47779. */
  47780. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  47781. /**
  47782. * Load into an asset container.
  47783. * @param scene The scene to load into
  47784. * @param data The data to import
  47785. * @param rootUrl The root url for scene and resources
  47786. * @param onError The callback when import fails
  47787. * @returns The loaded asset container
  47788. */
  47789. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  47790. }
  47791. /**
  47792. * Interface used to define an async SceneLoader plugin
  47793. */
  47794. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  47795. /**
  47796. * Import meshes into a scene.
  47797. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47798. * @param scene The scene to import into
  47799. * @param data The data to import
  47800. * @param rootUrl The root url for scene and resources
  47801. * @param onProgress The callback when the load progresses
  47802. * @param fileName Defines the name of the file to load
  47803. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  47804. */
  47805. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  47806. meshes: AbstractMesh[];
  47807. particleSystems: IParticleSystem[];
  47808. skeletons: Skeleton[];
  47809. animationGroups: AnimationGroup[];
  47810. }>;
  47811. /**
  47812. * Load into a scene.
  47813. * @param scene The scene to load into
  47814. * @param data The data to import
  47815. * @param rootUrl The root url for scene and resources
  47816. * @param onProgress The callback when the load progresses
  47817. * @param fileName Defines the name of the file to load
  47818. * @returns Nothing
  47819. */
  47820. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  47821. /**
  47822. * Load into an asset container.
  47823. * @param scene The scene to load into
  47824. * @param data The data to import
  47825. * @param rootUrl The root url for scene and resources
  47826. * @param onProgress The callback when the load progresses
  47827. * @param fileName Defines the name of the file to load
  47828. * @returns The loaded asset container
  47829. */
  47830. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  47831. }
  47832. /**
  47833. * Mode that determines how to handle old animation groups before loading new ones.
  47834. */
  47835. export enum SceneLoaderAnimationGroupLoadingMode {
  47836. /**
  47837. * Reset all old animations to initial state then dispose them.
  47838. */
  47839. Clean = 0,
  47840. /**
  47841. * Stop all old animations.
  47842. */
  47843. Stop = 1,
  47844. /**
  47845. * Restart old animations from first frame.
  47846. */
  47847. Sync = 2,
  47848. /**
  47849. * Old animations remains untouched.
  47850. */
  47851. NoSync = 3
  47852. }
  47853. /**
  47854. * Defines a plugin registered by the SceneLoader
  47855. */
  47856. interface IRegisteredPlugin {
  47857. /**
  47858. * Defines the plugin to use
  47859. */
  47860. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47861. /**
  47862. * Defines if the plugin supports binary data
  47863. */
  47864. isBinary: boolean;
  47865. }
  47866. /**
  47867. * Class used to load scene from various file formats using registered plugins
  47868. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  47869. */
  47870. export class SceneLoader {
  47871. /**
  47872. * No logging while loading
  47873. */
  47874. static readonly NO_LOGGING: number;
  47875. /**
  47876. * Minimal logging while loading
  47877. */
  47878. static readonly MINIMAL_LOGGING: number;
  47879. /**
  47880. * Summary logging while loading
  47881. */
  47882. static readonly SUMMARY_LOGGING: number;
  47883. /**
  47884. * Detailled logging while loading
  47885. */
  47886. static readonly DETAILED_LOGGING: number;
  47887. /**
  47888. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  47889. */
  47890. static get ForceFullSceneLoadingForIncremental(): boolean;
  47891. static set ForceFullSceneLoadingForIncremental(value: boolean);
  47892. /**
  47893. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  47894. */
  47895. static get ShowLoadingScreen(): boolean;
  47896. static set ShowLoadingScreen(value: boolean);
  47897. /**
  47898. * Defines the current logging level (while loading the scene)
  47899. * @ignorenaming
  47900. */
  47901. static get loggingLevel(): number;
  47902. static set loggingLevel(value: number);
  47903. /**
  47904. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47905. */
  47906. static get CleanBoneMatrixWeights(): boolean;
  47907. static set CleanBoneMatrixWeights(value: boolean);
  47908. /**
  47909. * Event raised when a plugin is used to load a scene
  47910. */
  47911. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47912. private static _registeredPlugins;
  47913. private static _showingLoadingScreen;
  47914. /**
  47915. * Gets the default plugin (used to load Babylon files)
  47916. * @returns the .babylon plugin
  47917. */
  47918. static GetDefaultPlugin(): IRegisteredPlugin;
  47919. private static _GetPluginForExtension;
  47920. private static _GetPluginForDirectLoad;
  47921. private static _GetPluginForFilename;
  47922. private static _GetDirectLoad;
  47923. private static _LoadData;
  47924. private static _GetFileInfo;
  47925. /**
  47926. * Gets a plugin that can load the given extension
  47927. * @param extension defines the extension to load
  47928. * @returns a plugin or null if none works
  47929. */
  47930. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47931. /**
  47932. * Gets a boolean indicating that the given extension can be loaded
  47933. * @param extension defines the extension to load
  47934. * @returns true if the extension is supported
  47935. */
  47936. static IsPluginForExtensionAvailable(extension: string): boolean;
  47937. /**
  47938. * Adds a new plugin to the list of registered plugins
  47939. * @param plugin defines the plugin to add
  47940. */
  47941. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  47942. /**
  47943. * Import meshes into a scene
  47944. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47945. * @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)
  47946. * @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)
  47947. * @param scene the instance of BABYLON.Scene to append to
  47948. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  47949. * @param onProgress a callback with a progress event for each file being loaded
  47950. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47951. * @param pluginExtension the extension used to determine the plugin
  47952. * @returns The loaded plugin
  47953. */
  47954. 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>;
  47955. /**
  47956. * Import meshes into a scene
  47957. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47958. * @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)
  47959. * @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)
  47960. * @param scene the instance of BABYLON.Scene to append to
  47961. * @param onProgress a callback with a progress event for each file being loaded
  47962. * @param pluginExtension the extension used to determine the plugin
  47963. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  47964. */
  47965. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  47966. meshes: AbstractMesh[];
  47967. particleSystems: IParticleSystem[];
  47968. skeletons: Skeleton[];
  47969. animationGroups: AnimationGroup[];
  47970. }>;
  47971. /**
  47972. * Load a scene
  47973. * @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)
  47974. * @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)
  47975. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47976. * @param onSuccess a callback with the scene when import succeeds
  47977. * @param onProgress a callback with a progress event for each file being loaded
  47978. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47979. * @param pluginExtension the extension used to determine the plugin
  47980. * @returns The loaded plugin
  47981. */
  47982. 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>;
  47983. /**
  47984. * Load a scene
  47985. * @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)
  47986. * @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)
  47987. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47988. * @param onProgress a callback with a progress event for each file being loaded
  47989. * @param pluginExtension the extension used to determine the plugin
  47990. * @returns The loaded scene
  47991. */
  47992. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47993. /**
  47994. * Append a scene
  47995. * @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)
  47996. * @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)
  47997. * @param scene is the instance of BABYLON.Scene to append to
  47998. * @param onSuccess a callback with the scene when import succeeds
  47999. * @param onProgress a callback with a progress event for each file being loaded
  48000. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48001. * @param pluginExtension the extension used to determine the plugin
  48002. * @returns The loaded plugin
  48003. */
  48004. 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>;
  48005. /**
  48006. * Append a scene
  48007. * @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)
  48008. * @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)
  48009. * @param scene is the instance of BABYLON.Scene to append to
  48010. * @param onProgress a callback with a progress event for each file being loaded
  48011. * @param pluginExtension the extension used to determine the plugin
  48012. * @returns The given scene
  48013. */
  48014. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48015. /**
  48016. * Load a scene into an asset container
  48017. * @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)
  48018. * @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)
  48019. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48020. * @param onSuccess a callback with the scene when import succeeds
  48021. * @param onProgress a callback with a progress event for each file being loaded
  48022. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48023. * @param pluginExtension the extension used to determine the plugin
  48024. * @returns The loaded plugin
  48025. */
  48026. 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>;
  48027. /**
  48028. * Load a scene into an asset container
  48029. * @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)
  48030. * @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)
  48031. * @param scene is the instance of Scene to append to
  48032. * @param onProgress a callback with a progress event for each file being loaded
  48033. * @param pluginExtension the extension used to determine the plugin
  48034. * @returns The loaded asset container
  48035. */
  48036. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  48037. /**
  48038. * Import animations from a file into a scene
  48039. * @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)
  48040. * @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)
  48041. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48042. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48043. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48044. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48045. * @param onSuccess a callback with the scene when import succeeds
  48046. * @param onProgress a callback with a progress event for each file being loaded
  48047. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48048. * @param pluginExtension the extension used to determine the plugin
  48049. */
  48050. 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;
  48051. /**
  48052. * Import animations from a file into a scene
  48053. * @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)
  48054. * @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)
  48055. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48056. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48057. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48058. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48059. * @param onSuccess a callback with the scene when import succeeds
  48060. * @param onProgress a callback with a progress event for each file being loaded
  48061. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48062. * @param pluginExtension the extension used to determine the plugin
  48063. * @returns the updated scene with imported animations
  48064. */
  48065. 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>;
  48066. }
  48067. }
  48068. declare module BABYLON {
  48069. /**
  48070. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48071. */
  48072. export type MotionControllerHandedness = "none" | "left" | "right";
  48073. /**
  48074. * The type of components available in motion controllers.
  48075. * This is not the name of the component.
  48076. */
  48077. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48078. /**
  48079. * The state of a controller component
  48080. */
  48081. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48082. /**
  48083. * The schema of motion controller layout.
  48084. * No object will be initialized using this interface
  48085. * This is used just to define the profile.
  48086. */
  48087. export interface IMotionControllerLayout {
  48088. /**
  48089. * Path to load the assets. Usually relative to the base path
  48090. */
  48091. assetPath: string;
  48092. /**
  48093. * Available components (unsorted)
  48094. */
  48095. components: {
  48096. /**
  48097. * A map of component Ids
  48098. */
  48099. [componentId: string]: {
  48100. /**
  48101. * The type of input the component outputs
  48102. */
  48103. type: MotionControllerComponentType;
  48104. /**
  48105. * The indices of this component in the gamepad object
  48106. */
  48107. gamepadIndices: {
  48108. /**
  48109. * Index of button
  48110. */
  48111. button?: number;
  48112. /**
  48113. * If available, index of x-axis
  48114. */
  48115. xAxis?: number;
  48116. /**
  48117. * If available, index of y-axis
  48118. */
  48119. yAxis?: number;
  48120. };
  48121. /**
  48122. * The mesh's root node name
  48123. */
  48124. rootNodeName: string;
  48125. /**
  48126. * Animation definitions for this model
  48127. */
  48128. visualResponses: {
  48129. [stateKey: string]: {
  48130. /**
  48131. * What property will be animated
  48132. */
  48133. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48134. /**
  48135. * What states influence this visual response
  48136. */
  48137. states: MotionControllerComponentStateType[];
  48138. /**
  48139. * Type of animation - movement or visibility
  48140. */
  48141. valueNodeProperty: "transform" | "visibility";
  48142. /**
  48143. * Base node name to move. Its position will be calculated according to the min and max nodes
  48144. */
  48145. valueNodeName?: string;
  48146. /**
  48147. * Minimum movement node
  48148. */
  48149. minNodeName?: string;
  48150. /**
  48151. * Max movement node
  48152. */
  48153. maxNodeName?: string;
  48154. };
  48155. };
  48156. /**
  48157. * If touch enabled, what is the name of node to display user feedback
  48158. */
  48159. touchPointNodeName?: string;
  48160. };
  48161. };
  48162. /**
  48163. * Is it xr standard mapping or not
  48164. */
  48165. gamepadMapping: "" | "xr-standard";
  48166. /**
  48167. * Base root node of this entire model
  48168. */
  48169. rootNodeName: string;
  48170. /**
  48171. * Defines the main button component id
  48172. */
  48173. selectComponentId: string;
  48174. }
  48175. /**
  48176. * A definition for the layout map in the input profile
  48177. */
  48178. export interface IMotionControllerLayoutMap {
  48179. /**
  48180. * Layouts with handedness type as a key
  48181. */
  48182. [handedness: string]: IMotionControllerLayout;
  48183. }
  48184. /**
  48185. * The XR Input profile schema
  48186. * Profiles can be found here:
  48187. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48188. */
  48189. export interface IMotionControllerProfile {
  48190. /**
  48191. * fallback profiles for this profileId
  48192. */
  48193. fallbackProfileIds: string[];
  48194. /**
  48195. * The layout map, with handedness as key
  48196. */
  48197. layouts: IMotionControllerLayoutMap;
  48198. /**
  48199. * The id of this profile
  48200. * correlates to the profile(s) in the xrInput.profiles array
  48201. */
  48202. profileId: string;
  48203. }
  48204. /**
  48205. * A helper-interface for the 3 meshes needed for controller button animation
  48206. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48207. */
  48208. export interface IMotionControllerButtonMeshMap {
  48209. /**
  48210. * the mesh that defines the pressed value mesh position.
  48211. * This is used to find the max-position of this button
  48212. */
  48213. pressedMesh: AbstractMesh;
  48214. /**
  48215. * the mesh that defines the unpressed value mesh position.
  48216. * This is used to find the min (or initial) position of this button
  48217. */
  48218. unpressedMesh: AbstractMesh;
  48219. /**
  48220. * The mesh that will be changed when value changes
  48221. */
  48222. valueMesh: AbstractMesh;
  48223. }
  48224. /**
  48225. * A helper-interface for the 3 meshes needed for controller axis animation.
  48226. * This will be expanded when touchpad animations are fully supported
  48227. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48228. */
  48229. export interface IMotionControllerMeshMap {
  48230. /**
  48231. * the mesh that defines the maximum value mesh position.
  48232. */
  48233. maxMesh?: AbstractMesh;
  48234. /**
  48235. * the mesh that defines the minimum value mesh position.
  48236. */
  48237. minMesh?: AbstractMesh;
  48238. /**
  48239. * The mesh that will be changed when axis value changes
  48240. */
  48241. valueMesh?: AbstractMesh;
  48242. }
  48243. /**
  48244. * The elements needed for change-detection of the gamepad objects in motion controllers
  48245. */
  48246. export interface IMinimalMotionControllerObject {
  48247. /**
  48248. * Available axes of this controller
  48249. */
  48250. axes: number[];
  48251. /**
  48252. * An array of available buttons
  48253. */
  48254. buttons: Array<{
  48255. /**
  48256. * Value of the button/trigger
  48257. */
  48258. value: number;
  48259. /**
  48260. * If the button/trigger is currently touched
  48261. */
  48262. touched: boolean;
  48263. /**
  48264. * If the button/trigger is currently pressed
  48265. */
  48266. pressed: boolean;
  48267. }>;
  48268. /**
  48269. * EXPERIMENTAL haptic support.
  48270. */
  48271. hapticActuators?: Array<{
  48272. pulse: (value: number, duration: number) => Promise<boolean>;
  48273. }>;
  48274. }
  48275. /**
  48276. * An Abstract Motion controller
  48277. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48278. * Each component has an observable to check for changes in value and state
  48279. */
  48280. export abstract class WebXRAbstractMotionController implements IDisposable {
  48281. protected scene: Scene;
  48282. protected layout: IMotionControllerLayout;
  48283. /**
  48284. * The gamepad object correlating to this controller
  48285. */
  48286. gamepadObject: IMinimalMotionControllerObject;
  48287. /**
  48288. * handedness (left/right/none) of this controller
  48289. */
  48290. handedness: MotionControllerHandedness;
  48291. private _initComponent;
  48292. private _modelReady;
  48293. /**
  48294. * A map of components (WebXRControllerComponent) in this motion controller
  48295. * Components have a ComponentType and can also have both button and axis definitions
  48296. */
  48297. readonly components: {
  48298. [id: string]: WebXRControllerComponent;
  48299. };
  48300. /**
  48301. * Disable the model's animation. Can be set at any time.
  48302. */
  48303. disableAnimation: boolean;
  48304. /**
  48305. * Observers registered here will be triggered when the model of this controller is done loading
  48306. */
  48307. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48308. /**
  48309. * The profile id of this motion controller
  48310. */
  48311. abstract profileId: string;
  48312. /**
  48313. * The root mesh of the model. It is null if the model was not yet initialized
  48314. */
  48315. rootMesh: Nullable<AbstractMesh>;
  48316. /**
  48317. * constructs a new abstract motion controller
  48318. * @param scene the scene to which the model of the controller will be added
  48319. * @param layout The profile layout to load
  48320. * @param gamepadObject The gamepad object correlating to this controller
  48321. * @param handedness handedness (left/right/none) of this controller
  48322. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48323. */
  48324. constructor(scene: Scene, layout: IMotionControllerLayout,
  48325. /**
  48326. * The gamepad object correlating to this controller
  48327. */
  48328. gamepadObject: IMinimalMotionControllerObject,
  48329. /**
  48330. * handedness (left/right/none) of this controller
  48331. */
  48332. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48333. /**
  48334. * Dispose this controller, the model mesh and all its components
  48335. */
  48336. dispose(): void;
  48337. /**
  48338. * Returns all components of specific type
  48339. * @param type the type to search for
  48340. * @return an array of components with this type
  48341. */
  48342. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48343. /**
  48344. * get a component based an its component id as defined in layout.components
  48345. * @param id the id of the component
  48346. * @returns the component correlates to the id or undefined if not found
  48347. */
  48348. getComponent(id: string): WebXRControllerComponent;
  48349. /**
  48350. * Get the list of components available in this motion controller
  48351. * @returns an array of strings correlating to available components
  48352. */
  48353. getComponentIds(): string[];
  48354. /**
  48355. * Get the first component of specific type
  48356. * @param type type of component to find
  48357. * @return a controller component or null if not found
  48358. */
  48359. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48360. /**
  48361. * Get the main (Select) component of this controller as defined in the layout
  48362. * @returns the main component of this controller
  48363. */
  48364. getMainComponent(): WebXRControllerComponent;
  48365. /**
  48366. * Loads the model correlating to this controller
  48367. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48368. * @returns A promise fulfilled with the result of the model loading
  48369. */
  48370. loadModel(): Promise<boolean>;
  48371. /**
  48372. * Update this model using the current XRFrame
  48373. * @param xrFrame the current xr frame to use and update the model
  48374. */
  48375. updateFromXRFrame(xrFrame: XRFrame): void;
  48376. /**
  48377. * Backwards compatibility due to a deeply-integrated typo
  48378. */
  48379. get handness(): XREye;
  48380. /**
  48381. * Pulse (vibrate) this controller
  48382. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48383. * Consecutive calls to this function will cancel the last pulse call
  48384. *
  48385. * @param value the strength of the pulse in 0.0...1.0 range
  48386. * @param duration Duration of the pulse in milliseconds
  48387. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48388. * @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
  48389. */
  48390. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48391. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48392. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48393. /**
  48394. * Moves the axis on the controller mesh based on its current state
  48395. * @param axis the index of the axis
  48396. * @param axisValue the value of the axis which determines the meshes new position
  48397. * @hidden
  48398. */
  48399. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48400. /**
  48401. * Update the model itself with the current frame data
  48402. * @param xrFrame the frame to use for updating the model mesh
  48403. */
  48404. protected updateModel(xrFrame: XRFrame): void;
  48405. /**
  48406. * Get the filename and path for this controller's model
  48407. * @returns a map of filename and path
  48408. */
  48409. protected abstract _getFilenameAndPath(): {
  48410. filename: string;
  48411. path: string;
  48412. };
  48413. /**
  48414. * This function is called before the mesh is loaded. It checks for loading constraints.
  48415. * For example, this function can check if the GLB loader is available
  48416. * If this function returns false, the generic controller will be loaded instead
  48417. * @returns Is the client ready to load the mesh
  48418. */
  48419. protected abstract _getModelLoadingConstraints(): boolean;
  48420. /**
  48421. * This function will be called after the model was successfully loaded and can be used
  48422. * for mesh transformations before it is available for the user
  48423. * @param meshes the loaded meshes
  48424. */
  48425. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48426. /**
  48427. * Set the root mesh for this controller. Important for the WebXR controller class
  48428. * @param meshes the loaded meshes
  48429. */
  48430. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48431. /**
  48432. * A function executed each frame that updates the mesh (if needed)
  48433. * @param xrFrame the current xrFrame
  48434. */
  48435. protected abstract _updateModel(xrFrame: XRFrame): void;
  48436. private _getGenericFilenameAndPath;
  48437. private _getGenericParentMesh;
  48438. }
  48439. }
  48440. declare module BABYLON {
  48441. /**
  48442. * A generic trigger-only motion controller for WebXR
  48443. */
  48444. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48445. /**
  48446. * Static version of the profile id of this controller
  48447. */
  48448. static ProfileId: string;
  48449. profileId: string;
  48450. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48451. protected _getFilenameAndPath(): {
  48452. filename: string;
  48453. path: string;
  48454. };
  48455. protected _getModelLoadingConstraints(): boolean;
  48456. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48457. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48458. protected _updateModel(): void;
  48459. }
  48460. }
  48461. declare module BABYLON {
  48462. /**
  48463. * Class containing static functions to help procedurally build meshes
  48464. */
  48465. export class SphereBuilder {
  48466. /**
  48467. * Creates a sphere mesh
  48468. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48469. * * 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`)
  48470. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48471. * * 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
  48472. * * 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)
  48473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48474. * * 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
  48475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48476. * @param name defines the name of the mesh
  48477. * @param options defines the options used to create the mesh
  48478. * @param scene defines the hosting scene
  48479. * @returns the sphere mesh
  48480. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48481. */
  48482. static CreateSphere(name: string, options: {
  48483. segments?: number;
  48484. diameter?: number;
  48485. diameterX?: number;
  48486. diameterY?: number;
  48487. diameterZ?: number;
  48488. arc?: number;
  48489. slice?: number;
  48490. sideOrientation?: number;
  48491. frontUVs?: Vector4;
  48492. backUVs?: Vector4;
  48493. updatable?: boolean;
  48494. }, scene?: Nullable<Scene>): Mesh;
  48495. }
  48496. }
  48497. declare module BABYLON {
  48498. /**
  48499. * A profiled motion controller has its profile loaded from an online repository.
  48500. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48501. */
  48502. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48503. private _repositoryUrl;
  48504. private _buttonMeshMapping;
  48505. private _touchDots;
  48506. /**
  48507. * The profile ID of this controller. Will be populated when the controller initializes.
  48508. */
  48509. profileId: string;
  48510. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48511. dispose(): void;
  48512. protected _getFilenameAndPath(): {
  48513. filename: string;
  48514. path: string;
  48515. };
  48516. protected _getModelLoadingConstraints(): boolean;
  48517. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48518. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48519. protected _updateModel(_xrFrame: XRFrame): void;
  48520. }
  48521. }
  48522. declare module BABYLON {
  48523. /**
  48524. * A construction function type to create a new controller based on an xrInput object
  48525. */
  48526. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48527. /**
  48528. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48529. *
  48530. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48531. * it should be replaced with auto-loaded controllers.
  48532. *
  48533. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48534. */
  48535. export class WebXRMotionControllerManager {
  48536. private static _AvailableControllers;
  48537. private static _Fallbacks;
  48538. private static _ProfileLoadingPromises;
  48539. private static _ProfilesList;
  48540. /**
  48541. * The base URL of the online controller repository. Can be changed at any time.
  48542. */
  48543. static BaseRepositoryUrl: string;
  48544. /**
  48545. * Which repository gets priority - local or online
  48546. */
  48547. static PrioritizeOnlineRepository: boolean;
  48548. /**
  48549. * Use the online repository, or use only locally-defined controllers
  48550. */
  48551. static UseOnlineRepository: boolean;
  48552. /**
  48553. * Clear the cache used for profile loading and reload when requested again
  48554. */
  48555. static ClearProfilesCache(): void;
  48556. /**
  48557. * Register the default fallbacks.
  48558. * This function is called automatically when this file is imported.
  48559. */
  48560. static DefaultFallbacks(): void;
  48561. /**
  48562. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48563. * @param profileId the profile to which a fallback needs to be found
  48564. * @return an array with corresponding fallback profiles
  48565. */
  48566. static FindFallbackWithProfileId(profileId: string): string[];
  48567. /**
  48568. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48569. * The order of search:
  48570. *
  48571. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48572. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48573. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48574. * 4) return the generic trigger controller if none were found
  48575. *
  48576. * @param xrInput the xrInput to which a new controller is initialized
  48577. * @param scene the scene to which the model will be added
  48578. * @param forceProfile force a certain profile for this controller
  48579. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48580. */
  48581. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48582. /**
  48583. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48584. *
  48585. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48586. *
  48587. * @param type the profile type to register
  48588. * @param constructFunction the function to be called when loading this profile
  48589. */
  48590. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48591. /**
  48592. * Register a fallback to a specific profile.
  48593. * @param profileId the profileId that will receive the fallbacks
  48594. * @param fallbacks A list of fallback profiles
  48595. */
  48596. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48597. /**
  48598. * Will update the list of profiles available in the repository
  48599. * @return a promise that resolves to a map of profiles available online
  48600. */
  48601. static UpdateProfilesList(): Promise<{
  48602. [profile: string]: string;
  48603. }>;
  48604. private static _LoadProfileFromRepository;
  48605. private static _LoadProfilesFromAvailableControllers;
  48606. }
  48607. }
  48608. declare module BABYLON {
  48609. /**
  48610. * Configuration options for the WebXR controller creation
  48611. */
  48612. export interface IWebXRControllerOptions {
  48613. /**
  48614. * Should the controller mesh be animated when a user interacts with it
  48615. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48616. */
  48617. disableMotionControllerAnimation?: boolean;
  48618. /**
  48619. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48620. */
  48621. doNotLoadControllerMesh?: boolean;
  48622. /**
  48623. * Force a specific controller type for this controller.
  48624. * This can be used when creating your own profile or when testing different controllers
  48625. */
  48626. forceControllerProfile?: string;
  48627. /**
  48628. * Defines a rendering group ID for meshes that will be loaded.
  48629. * This is for the default controllers only.
  48630. */
  48631. renderingGroupId?: number;
  48632. }
  48633. /**
  48634. * Represents an XR controller
  48635. */
  48636. export class WebXRInputSource {
  48637. private _scene;
  48638. /** The underlying input source for the controller */
  48639. inputSource: XRInputSource;
  48640. private _options;
  48641. private _tmpVector;
  48642. private _uniqueId;
  48643. private _disposed;
  48644. /**
  48645. * 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
  48646. */
  48647. grip?: AbstractMesh;
  48648. /**
  48649. * If available, this is the gamepad object related to this controller.
  48650. * Using this object it is possible to get click events and trackpad changes of the
  48651. * webxr controller that is currently being used.
  48652. */
  48653. motionController?: WebXRAbstractMotionController;
  48654. /**
  48655. * Event that fires when the controller is removed/disposed.
  48656. * The object provided as event data is this controller, after associated assets were disposed.
  48657. * uniqueId is still available.
  48658. */
  48659. onDisposeObservable: Observable<WebXRInputSource>;
  48660. /**
  48661. * Will be triggered when the mesh associated with the motion controller is done loading.
  48662. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48663. * A shortened version of controller -> motion controller -> on mesh loaded.
  48664. */
  48665. onMeshLoadedObservable: Observable<AbstractMesh>;
  48666. /**
  48667. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48668. */
  48669. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48670. /**
  48671. * Pointer which can be used to select objects or attach a visible laser to
  48672. */
  48673. pointer: AbstractMesh;
  48674. /**
  48675. * Creates the input source object
  48676. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  48677. * @param _scene the scene which the controller should be associated to
  48678. * @param inputSource the underlying input source for the controller
  48679. * @param _options options for this controller creation
  48680. */
  48681. constructor(_scene: Scene,
  48682. /** The underlying input source for the controller */
  48683. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48684. /**
  48685. * Get this controllers unique id
  48686. */
  48687. get uniqueId(): string;
  48688. /**
  48689. * Disposes of the object
  48690. */
  48691. dispose(): void;
  48692. /**
  48693. * Gets a world space ray coming from the pointer or grip
  48694. * @param result the resulting ray
  48695. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48696. */
  48697. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48698. /**
  48699. * Updates the controller pose based on the given XRFrame
  48700. * @param xrFrame xr frame to update the pose with
  48701. * @param referenceSpace reference space to use
  48702. */
  48703. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48704. }
  48705. }
  48706. declare module BABYLON {
  48707. /**
  48708. * The schema for initialization options of the XR Input class
  48709. */
  48710. export interface IWebXRInputOptions {
  48711. /**
  48712. * If set to true no model will be automatically loaded
  48713. */
  48714. doNotLoadControllerMeshes?: boolean;
  48715. /**
  48716. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  48717. * If not found, the xr input profile data will be used.
  48718. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  48719. */
  48720. forceInputProfile?: string;
  48721. /**
  48722. * Do not send a request to the controller repository to load the profile.
  48723. *
  48724. * Instead, use the controllers available in babylon itself.
  48725. */
  48726. disableOnlineControllerRepository?: boolean;
  48727. /**
  48728. * A custom URL for the controllers repository
  48729. */
  48730. customControllersRepositoryURL?: string;
  48731. /**
  48732. * Should the controller model's components not move according to the user input
  48733. */
  48734. disableControllerAnimation?: boolean;
  48735. /**
  48736. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  48737. */
  48738. controllerOptions?: IWebXRControllerOptions;
  48739. }
  48740. /**
  48741. * XR input used to track XR inputs such as controllers/rays
  48742. */
  48743. export class WebXRInput implements IDisposable {
  48744. /**
  48745. * the xr session manager for this session
  48746. */
  48747. xrSessionManager: WebXRSessionManager;
  48748. /**
  48749. * the WebXR camera for this session. Mainly used for teleportation
  48750. */
  48751. xrCamera: WebXRCamera;
  48752. private readonly options;
  48753. /**
  48754. * XR controllers being tracked
  48755. */
  48756. controllers: Array<WebXRInputSource>;
  48757. private _frameObserver;
  48758. private _sessionEndedObserver;
  48759. private _sessionInitObserver;
  48760. /**
  48761. * Event when a controller has been connected/added
  48762. */
  48763. onControllerAddedObservable: Observable<WebXRInputSource>;
  48764. /**
  48765. * Event when a controller has been removed/disconnected
  48766. */
  48767. onControllerRemovedObservable: Observable<WebXRInputSource>;
  48768. /**
  48769. * Initializes the WebXRInput
  48770. * @param xrSessionManager the xr session manager for this session
  48771. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  48772. * @param options = initialization options for this xr input
  48773. */
  48774. constructor(
  48775. /**
  48776. * the xr session manager for this session
  48777. */
  48778. xrSessionManager: WebXRSessionManager,
  48779. /**
  48780. * the WebXR camera for this session. Mainly used for teleportation
  48781. */
  48782. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  48783. private _onInputSourcesChange;
  48784. private _addAndRemoveControllers;
  48785. /**
  48786. * Disposes of the object
  48787. */
  48788. dispose(): void;
  48789. }
  48790. }
  48791. declare module BABYLON {
  48792. /**
  48793. * This is the base class for all WebXR features.
  48794. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  48795. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  48796. */
  48797. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  48798. protected _xrSessionManager: WebXRSessionManager;
  48799. private _attached;
  48800. private _removeOnDetach;
  48801. /**
  48802. * Is this feature disposed?
  48803. */
  48804. isDisposed: boolean;
  48805. /**
  48806. * Should auto-attach be disabled?
  48807. */
  48808. disableAutoAttach: boolean;
  48809. /**
  48810. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  48811. */
  48812. xrNativeFeatureName: string;
  48813. /**
  48814. * Construct a new (abstract) WebXR feature
  48815. * @param _xrSessionManager the xr session manager for this feature
  48816. */
  48817. constructor(_xrSessionManager: WebXRSessionManager);
  48818. /**
  48819. * Is this feature attached
  48820. */
  48821. get attached(): boolean;
  48822. /**
  48823. * attach this feature
  48824. *
  48825. * @param force should attachment be forced (even when already attached)
  48826. * @returns true if successful, false is failed or already attached
  48827. */
  48828. attach(force?: boolean): boolean;
  48829. /**
  48830. * detach this feature.
  48831. *
  48832. * @returns true if successful, false if failed or already detached
  48833. */
  48834. detach(): boolean;
  48835. /**
  48836. * Dispose this feature and all of the resources attached
  48837. */
  48838. dispose(): void;
  48839. /**
  48840. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48841. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48842. *
  48843. * @returns whether or not the feature is compatible in this environment
  48844. */
  48845. isCompatible(): boolean;
  48846. /**
  48847. * This is used to register callbacks that will automatically be removed when detach is called.
  48848. * @param observable the observable to which the observer will be attached
  48849. * @param callback the callback to register
  48850. */
  48851. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  48852. /**
  48853. * Code in this function will be executed on each xrFrame received from the browser.
  48854. * This function will not execute after the feature is detached.
  48855. * @param _xrFrame the current frame
  48856. */
  48857. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  48858. }
  48859. }
  48860. declare module BABYLON {
  48861. /**
  48862. * Renders a layer on top of an existing scene
  48863. */
  48864. export class UtilityLayerRenderer implements IDisposable {
  48865. /** the original scene that will be rendered on top of */
  48866. originalScene: Scene;
  48867. private _pointerCaptures;
  48868. private _lastPointerEvents;
  48869. private static _DefaultUtilityLayer;
  48870. private static _DefaultKeepDepthUtilityLayer;
  48871. private _sharedGizmoLight;
  48872. private _renderCamera;
  48873. /**
  48874. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  48875. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  48876. * @returns the camera that is used when rendering the utility layer
  48877. */
  48878. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  48879. /**
  48880. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  48881. * @param cam the camera that should be used when rendering the utility layer
  48882. */
  48883. setRenderCamera(cam: Nullable<Camera>): void;
  48884. /**
  48885. * @hidden
  48886. * Light which used by gizmos to get light shading
  48887. */
  48888. _getSharedGizmoLight(): HemisphericLight;
  48889. /**
  48890. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  48891. */
  48892. pickUtilitySceneFirst: boolean;
  48893. /**
  48894. * 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)
  48895. */
  48896. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  48897. /**
  48898. * 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)
  48899. */
  48900. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  48901. /**
  48902. * The scene that is rendered on top of the original scene
  48903. */
  48904. utilityLayerScene: Scene;
  48905. /**
  48906. * If the utility layer should automatically be rendered on top of existing scene
  48907. */
  48908. shouldRender: boolean;
  48909. /**
  48910. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  48911. */
  48912. onlyCheckPointerDownEvents: boolean;
  48913. /**
  48914. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  48915. */
  48916. processAllEvents: boolean;
  48917. /**
  48918. * Observable raised when the pointer move from the utility layer scene to the main scene
  48919. */
  48920. onPointerOutObservable: Observable<number>;
  48921. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  48922. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  48923. private _afterRenderObserver;
  48924. private _sceneDisposeObserver;
  48925. private _originalPointerObserver;
  48926. /**
  48927. * Instantiates a UtilityLayerRenderer
  48928. * @param originalScene the original scene that will be rendered on top of
  48929. * @param handleEvents boolean indicating if the utility layer should handle events
  48930. */
  48931. constructor(
  48932. /** the original scene that will be rendered on top of */
  48933. originalScene: Scene, handleEvents?: boolean);
  48934. private _notifyObservers;
  48935. /**
  48936. * Renders the utility layers scene on top of the original scene
  48937. */
  48938. render(): void;
  48939. /**
  48940. * Disposes of the renderer
  48941. */
  48942. dispose(): void;
  48943. private _updateCamera;
  48944. }
  48945. }
  48946. declare module BABYLON {
  48947. /**
  48948. * Options interface for the pointer selection module
  48949. */
  48950. export interface IWebXRControllerPointerSelectionOptions {
  48951. /**
  48952. * if provided, this scene will be used to render meshes.
  48953. */
  48954. customUtilityLayerScene?: Scene;
  48955. /**
  48956. * 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)
  48957. * If not disabled, the last picked point will be used to execute a pointer up event
  48958. * If disabled, pointer up event will be triggered right after the pointer down event.
  48959. * Used in screen and gaze target ray mode only
  48960. */
  48961. disablePointerUpOnTouchOut: boolean;
  48962. /**
  48963. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  48964. */
  48965. forceGazeMode: boolean;
  48966. /**
  48967. * 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
  48968. * to start a new countdown to the pointer down event.
  48969. * Defaults to 1.
  48970. */
  48971. gazeModePointerMovedFactor?: number;
  48972. /**
  48973. * Different button type to use instead of the main component
  48974. */
  48975. overrideButtonId?: string;
  48976. /**
  48977. * use this rendering group id for the meshes (optional)
  48978. */
  48979. renderingGroupId?: number;
  48980. /**
  48981. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  48982. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  48983. * 3000 means 3 seconds between pointing at something and selecting it
  48984. */
  48985. timeToSelect?: number;
  48986. /**
  48987. * Should meshes created here be added to a utility layer or the main scene
  48988. */
  48989. useUtilityLayer?: boolean;
  48990. /**
  48991. * Optional WebXR camera to be used for gaze selection
  48992. */
  48993. gazeCamera?: WebXRCamera;
  48994. /**
  48995. * the xr input to use with this pointer selection
  48996. */
  48997. xrInput: WebXRInput;
  48998. }
  48999. /**
  49000. * A module that will enable pointer selection for motion controllers of XR Input Sources
  49001. */
  49002. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  49003. private readonly _options;
  49004. private static _idCounter;
  49005. private _attachController;
  49006. private _controllers;
  49007. private _scene;
  49008. private _tmpVectorForPickCompare;
  49009. /**
  49010. * The module's name
  49011. */
  49012. static readonly Name: string;
  49013. /**
  49014. * The (Babylon) version of this module.
  49015. * This is an integer representing the implementation version.
  49016. * This number does not correspond to the WebXR specs version
  49017. */
  49018. static readonly Version: number;
  49019. /**
  49020. * Disable lighting on the laser pointer (so it will always be visible)
  49021. */
  49022. disablePointerLighting: boolean;
  49023. /**
  49024. * Disable lighting on the selection mesh (so it will always be visible)
  49025. */
  49026. disableSelectionMeshLighting: boolean;
  49027. /**
  49028. * Should the laser pointer be displayed
  49029. */
  49030. displayLaserPointer: boolean;
  49031. /**
  49032. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  49033. */
  49034. displaySelectionMesh: boolean;
  49035. /**
  49036. * This color will be set to the laser pointer when selection is triggered
  49037. */
  49038. laserPointerPickedColor: Color3;
  49039. /**
  49040. * Default color of the laser pointer
  49041. */
  49042. laserPointerDefaultColor: Color3;
  49043. /**
  49044. * default color of the selection ring
  49045. */
  49046. selectionMeshDefaultColor: Color3;
  49047. /**
  49048. * This color will be applied to the selection ring when selection is triggered
  49049. */
  49050. selectionMeshPickedColor: Color3;
  49051. /**
  49052. * Optional filter to be used for ray selection. This predicate shares behavior with
  49053. * scene.pointerMovePredicate which takes priority if it is also assigned.
  49054. */
  49055. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49056. /**
  49057. * constructs a new background remover module
  49058. * @param _xrSessionManager the session manager for this module
  49059. * @param _options read-only options to be used in this module
  49060. */
  49061. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49062. /**
  49063. * attach this feature
  49064. * Will usually be called by the features manager
  49065. *
  49066. * @returns true if successful.
  49067. */
  49068. attach(): boolean;
  49069. /**
  49070. * detach this feature.
  49071. * Will usually be called by the features manager
  49072. *
  49073. * @returns true if successful.
  49074. */
  49075. detach(): boolean;
  49076. /**
  49077. * Will get the mesh under a specific pointer.
  49078. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49079. * @param controllerId the controllerId to check
  49080. * @returns The mesh under pointer or null if no mesh is under the pointer
  49081. */
  49082. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49083. /**
  49084. * Get the xr controller that correlates to the pointer id in the pointer event
  49085. *
  49086. * @param id the pointer id to search for
  49087. * @returns the controller that correlates to this id or null if not found
  49088. */
  49089. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49090. protected _onXRFrame(_xrFrame: XRFrame): void;
  49091. private _attachGazeMode;
  49092. private _attachScreenRayMode;
  49093. private _attachTrackedPointerRayMode;
  49094. private _convertNormalToDirectionOfRay;
  49095. private _detachController;
  49096. private _generateNewMeshPair;
  49097. private _pickingMoved;
  49098. private _updatePointerDistance;
  49099. /** @hidden */
  49100. get lasterPointerDefaultColor(): Color3;
  49101. }
  49102. }
  49103. declare module BABYLON {
  49104. /**
  49105. * Button which can be used to enter a different mode of XR
  49106. */
  49107. export class WebXREnterExitUIButton {
  49108. /** button element */
  49109. element: HTMLElement;
  49110. /** XR initialization options for the button */
  49111. sessionMode: XRSessionMode;
  49112. /** Reference space type */
  49113. referenceSpaceType: XRReferenceSpaceType;
  49114. /**
  49115. * Creates a WebXREnterExitUIButton
  49116. * @param element button element
  49117. * @param sessionMode XR initialization session mode
  49118. * @param referenceSpaceType the type of reference space to be used
  49119. */
  49120. constructor(
  49121. /** button element */
  49122. element: HTMLElement,
  49123. /** XR initialization options for the button */
  49124. sessionMode: XRSessionMode,
  49125. /** Reference space type */
  49126. referenceSpaceType: XRReferenceSpaceType);
  49127. /**
  49128. * Extendable function which can be used to update the button's visuals when the state changes
  49129. * @param activeButton the current active button in the UI
  49130. */
  49131. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49132. }
  49133. /**
  49134. * Options to create the webXR UI
  49135. */
  49136. export class WebXREnterExitUIOptions {
  49137. /**
  49138. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49139. */
  49140. customButtons?: Array<WebXREnterExitUIButton>;
  49141. /**
  49142. * A reference space type to use when creating the default button.
  49143. * Default is local-floor
  49144. */
  49145. referenceSpaceType?: XRReferenceSpaceType;
  49146. /**
  49147. * Context to enter xr with
  49148. */
  49149. renderTarget?: Nullable<WebXRRenderTarget>;
  49150. /**
  49151. * A session mode to use when creating the default button.
  49152. * Default is immersive-vr
  49153. */
  49154. sessionMode?: XRSessionMode;
  49155. /**
  49156. * A list of optional features to init the session with
  49157. */
  49158. optionalFeatures?: string[];
  49159. /**
  49160. * A list of optional features to init the session with
  49161. */
  49162. requiredFeatures?: string[];
  49163. }
  49164. /**
  49165. * UI to allow the user to enter/exit XR mode
  49166. */
  49167. export class WebXREnterExitUI implements IDisposable {
  49168. private scene;
  49169. /** version of the options passed to this UI */
  49170. options: WebXREnterExitUIOptions;
  49171. private _activeButton;
  49172. private _buttons;
  49173. /**
  49174. * The HTML Div Element to which buttons are added.
  49175. */
  49176. readonly overlay: HTMLDivElement;
  49177. /**
  49178. * Fired every time the active button is changed.
  49179. *
  49180. * When xr is entered via a button that launches xr that button will be the callback parameter
  49181. *
  49182. * When exiting xr the callback parameter will be null)
  49183. */
  49184. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49185. /**
  49186. *
  49187. * @param scene babylon scene object to use
  49188. * @param options (read-only) version of the options passed to this UI
  49189. */
  49190. private constructor();
  49191. /**
  49192. * Creates UI to allow the user to enter/exit XR mode
  49193. * @param scene the scene to add the ui to
  49194. * @param helper the xr experience helper to enter/exit xr with
  49195. * @param options options to configure the UI
  49196. * @returns the created ui
  49197. */
  49198. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49199. /**
  49200. * Disposes of the XR UI component
  49201. */
  49202. dispose(): void;
  49203. private _updateButtons;
  49204. }
  49205. }
  49206. declare module BABYLON {
  49207. /**
  49208. * Class containing static functions to help procedurally build meshes
  49209. */
  49210. export class LinesBuilder {
  49211. /**
  49212. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49213. * * 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
  49214. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49215. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49216. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49217. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49218. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49219. * * 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
  49220. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49222. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49223. * @param name defines the name of the new line system
  49224. * @param options defines the options used to create the line system
  49225. * @param scene defines the hosting scene
  49226. * @returns a new line system mesh
  49227. */
  49228. static CreateLineSystem(name: string, options: {
  49229. lines: Vector3[][];
  49230. updatable?: boolean;
  49231. instance?: Nullable<LinesMesh>;
  49232. colors?: Nullable<Color4[][]>;
  49233. useVertexAlpha?: boolean;
  49234. }, scene: Nullable<Scene>): LinesMesh;
  49235. /**
  49236. * Creates a line mesh
  49237. * 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
  49238. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49239. * * The parameter `points` is an array successive Vector3
  49240. * * 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
  49241. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49242. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49243. * * When updating an instance, remember that only point positions can change, not the number of points
  49244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49245. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49246. * @param name defines the name of the new line system
  49247. * @param options defines the options used to create the line system
  49248. * @param scene defines the hosting scene
  49249. * @returns a new line mesh
  49250. */
  49251. static CreateLines(name: string, options: {
  49252. points: Vector3[];
  49253. updatable?: boolean;
  49254. instance?: Nullable<LinesMesh>;
  49255. colors?: Color4[];
  49256. useVertexAlpha?: boolean;
  49257. }, scene?: Nullable<Scene>): LinesMesh;
  49258. /**
  49259. * Creates a dashed line mesh
  49260. * * 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
  49261. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49262. * * The parameter `points` is an array successive Vector3
  49263. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49264. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49265. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49266. * * 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
  49267. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49268. * * When updating an instance, remember that only point positions can change, not the number of points
  49269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49270. * @param name defines the name of the mesh
  49271. * @param options defines the options used to create the mesh
  49272. * @param scene defines the hosting scene
  49273. * @returns the dashed line mesh
  49274. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49275. */
  49276. static CreateDashedLines(name: string, options: {
  49277. points: Vector3[];
  49278. dashSize?: number;
  49279. gapSize?: number;
  49280. dashNb?: number;
  49281. updatable?: boolean;
  49282. instance?: LinesMesh;
  49283. useVertexAlpha?: boolean;
  49284. }, scene?: Nullable<Scene>): LinesMesh;
  49285. }
  49286. }
  49287. declare module BABYLON {
  49288. /**
  49289. * Construction options for a timer
  49290. */
  49291. export interface ITimerOptions<T> {
  49292. /**
  49293. * Time-to-end
  49294. */
  49295. timeout: number;
  49296. /**
  49297. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  49298. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  49299. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  49300. */
  49301. contextObservable: Observable<T>;
  49302. /**
  49303. * Optional parameters when adding an observer to the observable
  49304. */
  49305. observableParameters?: {
  49306. mask?: number;
  49307. insertFirst?: boolean;
  49308. scope?: any;
  49309. };
  49310. /**
  49311. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  49312. */
  49313. breakCondition?: (data?: ITimerData<T>) => boolean;
  49314. /**
  49315. * Will be triggered when the time condition has met
  49316. */
  49317. onEnded?: (data: ITimerData<any>) => void;
  49318. /**
  49319. * Will be triggered when the break condition has met (prematurely ended)
  49320. */
  49321. onAborted?: (data: ITimerData<any>) => void;
  49322. /**
  49323. * Optional function to execute on each tick (or count)
  49324. */
  49325. onTick?: (data: ITimerData<any>) => void;
  49326. }
  49327. /**
  49328. * An interface defining the data sent by the timer
  49329. */
  49330. export interface ITimerData<T> {
  49331. /**
  49332. * When did it start
  49333. */
  49334. startTime: number;
  49335. /**
  49336. * Time now
  49337. */
  49338. currentTime: number;
  49339. /**
  49340. * Time passed since started
  49341. */
  49342. deltaTime: number;
  49343. /**
  49344. * How much is completed, in [0.0...1.0].
  49345. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  49346. */
  49347. completeRate: number;
  49348. /**
  49349. * What the registered observable sent in the last count
  49350. */
  49351. payload: T;
  49352. }
  49353. /**
  49354. * The current state of the timer
  49355. */
  49356. export enum TimerState {
  49357. /**
  49358. * Timer initialized, not yet started
  49359. */
  49360. INIT = 0,
  49361. /**
  49362. * Timer started and counting
  49363. */
  49364. STARTED = 1,
  49365. /**
  49366. * Timer ended (whether aborted or time reached)
  49367. */
  49368. ENDED = 2
  49369. }
  49370. /**
  49371. * A simple version of the timer. Will take options and start the timer immediately after calling it
  49372. *
  49373. * @param options options with which to initialize this timer
  49374. */
  49375. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  49376. /**
  49377. * An advanced implementation of a timer class
  49378. */
  49379. export class AdvancedTimer<T = any> implements IDisposable {
  49380. /**
  49381. * Will notify each time the timer calculates the remaining time
  49382. */
  49383. onEachCountObservable: Observable<ITimerData<T>>;
  49384. /**
  49385. * Will trigger when the timer was aborted due to the break condition
  49386. */
  49387. onTimerAbortedObservable: Observable<ITimerData<T>>;
  49388. /**
  49389. * Will trigger when the timer ended successfully
  49390. */
  49391. onTimerEndedObservable: Observable<ITimerData<T>>;
  49392. /**
  49393. * Will trigger when the timer state has changed
  49394. */
  49395. onStateChangedObservable: Observable<TimerState>;
  49396. private _observer;
  49397. private _contextObservable;
  49398. private _observableParameters;
  49399. private _startTime;
  49400. private _timer;
  49401. private _state;
  49402. private _breakCondition;
  49403. private _timeToEnd;
  49404. private _breakOnNextTick;
  49405. /**
  49406. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  49407. * @param options construction options for this advanced timer
  49408. */
  49409. constructor(options: ITimerOptions<T>);
  49410. /**
  49411. * set a breaking condition for this timer. Default is to never break during count
  49412. * @param predicate the new break condition. Returns true to break, false otherwise
  49413. */
  49414. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  49415. /**
  49416. * Reset ALL associated observables in this advanced timer
  49417. */
  49418. clearObservables(): void;
  49419. /**
  49420. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  49421. *
  49422. * @param timeToEnd how much time to measure until timer ended
  49423. */
  49424. start(timeToEnd?: number): void;
  49425. /**
  49426. * Will force a stop on the next tick.
  49427. */
  49428. stop(): void;
  49429. /**
  49430. * Dispose this timer, clearing all resources
  49431. */
  49432. dispose(): void;
  49433. private _setState;
  49434. private _tick;
  49435. private _stop;
  49436. }
  49437. }
  49438. declare module BABYLON {
  49439. /**
  49440. * The options container for the teleportation module
  49441. */
  49442. export interface IWebXRTeleportationOptions {
  49443. /**
  49444. * if provided, this scene will be used to render meshes.
  49445. */
  49446. customUtilityLayerScene?: Scene;
  49447. /**
  49448. * Values to configure the default target mesh
  49449. */
  49450. defaultTargetMeshOptions?: {
  49451. /**
  49452. * Fill color of the teleportation area
  49453. */
  49454. teleportationFillColor?: string;
  49455. /**
  49456. * Border color for the teleportation area
  49457. */
  49458. teleportationBorderColor?: string;
  49459. /**
  49460. * Disable the mesh's animation sequence
  49461. */
  49462. disableAnimation?: boolean;
  49463. /**
  49464. * Disable lighting on the material or the ring and arrow
  49465. */
  49466. disableLighting?: boolean;
  49467. /**
  49468. * Override the default material of the torus and arrow
  49469. */
  49470. torusArrowMaterial?: Material;
  49471. };
  49472. /**
  49473. * A list of meshes to use as floor meshes.
  49474. * Meshes can be added and removed after initializing the feature using the
  49475. * addFloorMesh and removeFloorMesh functions
  49476. * If empty, rotation will still work
  49477. */
  49478. floorMeshes?: AbstractMesh[];
  49479. /**
  49480. * use this rendering group id for the meshes (optional)
  49481. */
  49482. renderingGroupId?: number;
  49483. /**
  49484. * Should teleportation move only to snap points
  49485. */
  49486. snapPointsOnly?: boolean;
  49487. /**
  49488. * An array of points to which the teleportation will snap to.
  49489. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49490. */
  49491. snapPositions?: Vector3[];
  49492. /**
  49493. * How close should the teleportation ray be in order to snap to position.
  49494. * Default to 0.8 units (meters)
  49495. */
  49496. snapToPositionRadius?: number;
  49497. /**
  49498. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49499. * If you want to support rotation, make sure your mesh has a direction indicator.
  49500. *
  49501. * When left untouched, the default mesh will be initialized.
  49502. */
  49503. teleportationTargetMesh?: AbstractMesh;
  49504. /**
  49505. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49506. */
  49507. timeToTeleport?: number;
  49508. /**
  49509. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49510. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49511. */
  49512. useMainComponentOnly?: boolean;
  49513. /**
  49514. * Should meshes created here be added to a utility layer or the main scene
  49515. */
  49516. useUtilityLayer?: boolean;
  49517. /**
  49518. * Babylon XR Input class for controller
  49519. */
  49520. xrInput: WebXRInput;
  49521. /**
  49522. * Meshes that the teleportation ray cannot go through
  49523. */
  49524. pickBlockerMeshes?: AbstractMesh[];
  49525. }
  49526. /**
  49527. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49528. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49529. * the input of the attached controllers.
  49530. */
  49531. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49532. private _options;
  49533. private _controllers;
  49534. private _currentTeleportationControllerId;
  49535. private _floorMeshes;
  49536. private _quadraticBezierCurve;
  49537. private _selectionFeature;
  49538. private _snapToPositions;
  49539. private _snappedToPoint;
  49540. private _teleportationRingMaterial?;
  49541. private _tmpRay;
  49542. private _tmpVector;
  49543. private _tmpQuaternion;
  49544. /**
  49545. * The module's name
  49546. */
  49547. static readonly Name: string;
  49548. /**
  49549. * The (Babylon) version of this module.
  49550. * This is an integer representing the implementation version.
  49551. * This number does not correspond to the webxr specs version
  49552. */
  49553. static readonly Version: number;
  49554. /**
  49555. * Is movement backwards enabled
  49556. */
  49557. backwardsMovementEnabled: boolean;
  49558. /**
  49559. * Distance to travel when moving backwards
  49560. */
  49561. backwardsTeleportationDistance: number;
  49562. /**
  49563. * The distance from the user to the inspection point in the direction of the controller
  49564. * A higher number will allow the user to move further
  49565. * defaults to 5 (meters, in xr units)
  49566. */
  49567. parabolicCheckRadius: number;
  49568. /**
  49569. * Should the module support parabolic ray on top of direct ray
  49570. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49571. * Very helpful when moving between floors / different heights
  49572. */
  49573. parabolicRayEnabled: boolean;
  49574. /**
  49575. * How much rotation should be applied when rotating right and left
  49576. */
  49577. rotationAngle: number;
  49578. /**
  49579. * Is rotation enabled when moving forward?
  49580. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49581. */
  49582. rotationEnabled: boolean;
  49583. /**
  49584. * constructs a new anchor system
  49585. * @param _xrSessionManager an instance of WebXRSessionManager
  49586. * @param _options configuration object for this feature
  49587. */
  49588. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49589. /**
  49590. * Get the snapPointsOnly flag
  49591. */
  49592. get snapPointsOnly(): boolean;
  49593. /**
  49594. * Sets the snapPointsOnly flag
  49595. * @param snapToPoints should teleportation be exclusively to snap points
  49596. */
  49597. set snapPointsOnly(snapToPoints: boolean);
  49598. /**
  49599. * Add a new mesh to the floor meshes array
  49600. * @param mesh the mesh to use as floor mesh
  49601. */
  49602. addFloorMesh(mesh: AbstractMesh): void;
  49603. /**
  49604. * Add a new snap-to point to fix teleportation to this position
  49605. * @param newSnapPoint The new Snap-To point
  49606. */
  49607. addSnapPoint(newSnapPoint: Vector3): void;
  49608. attach(): boolean;
  49609. detach(): boolean;
  49610. dispose(): void;
  49611. /**
  49612. * Remove a mesh from the floor meshes array
  49613. * @param mesh the mesh to remove
  49614. */
  49615. removeFloorMesh(mesh: AbstractMesh): void;
  49616. /**
  49617. * Remove a mesh from the floor meshes array using its name
  49618. * @param name the mesh name to remove
  49619. */
  49620. removeFloorMeshByName(name: string): void;
  49621. /**
  49622. * 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
  49623. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49624. * @returns was the point found and removed or not
  49625. */
  49626. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49627. /**
  49628. * This function sets a selection feature that will be disabled when
  49629. * the forward ray is shown and will be reattached when hidden.
  49630. * This is used to remove the selection rays when moving.
  49631. * @param selectionFeature the feature to disable when forward movement is enabled
  49632. */
  49633. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  49634. protected _onXRFrame(_xrFrame: XRFrame): void;
  49635. private _attachController;
  49636. private _createDefaultTargetMesh;
  49637. private _detachController;
  49638. private _findClosestSnapPointWithRadius;
  49639. private _setTargetMeshPosition;
  49640. private _setTargetMeshVisibility;
  49641. private _showParabolicPath;
  49642. private _teleportForward;
  49643. }
  49644. }
  49645. declare module BABYLON {
  49646. /**
  49647. * Options for the default xr helper
  49648. */
  49649. export class WebXRDefaultExperienceOptions {
  49650. /**
  49651. * Enable or disable default UI to enter XR
  49652. */
  49653. disableDefaultUI?: boolean;
  49654. /**
  49655. * Should teleportation not initialize. defaults to false.
  49656. */
  49657. disableTeleportation?: boolean;
  49658. /**
  49659. * Floor meshes that will be used for teleport
  49660. */
  49661. floorMeshes?: Array<AbstractMesh>;
  49662. /**
  49663. * If set to true, the first frame will not be used to reset position
  49664. * The first frame is mainly used when copying transformation from the old camera
  49665. * Mainly used in AR
  49666. */
  49667. ignoreNativeCameraTransformation?: boolean;
  49668. /**
  49669. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49670. */
  49671. inputOptions?: IWebXRInputOptions;
  49672. /**
  49673. * optional configuration for the output canvas
  49674. */
  49675. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49676. /**
  49677. * optional UI options. This can be used among other to change session mode and reference space type
  49678. */
  49679. uiOptions?: WebXREnterExitUIOptions;
  49680. /**
  49681. * When loading teleportation and pointer select, use stable versions instead of latest.
  49682. */
  49683. useStablePlugins?: boolean;
  49684. /**
  49685. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49686. */
  49687. renderingGroupId?: number;
  49688. /**
  49689. * A list of optional features to init the session with
  49690. * If set to true, all features we support will be added
  49691. */
  49692. optionalFeatures?: boolean | string[];
  49693. }
  49694. /**
  49695. * Default experience which provides a similar setup to the previous webVRExperience
  49696. */
  49697. export class WebXRDefaultExperience {
  49698. /**
  49699. * Base experience
  49700. */
  49701. baseExperience: WebXRExperienceHelper;
  49702. /**
  49703. * Enables ui for entering/exiting xr
  49704. */
  49705. enterExitUI: WebXREnterExitUI;
  49706. /**
  49707. * Input experience extension
  49708. */
  49709. input: WebXRInput;
  49710. /**
  49711. * Enables laser pointer and selection
  49712. */
  49713. pointerSelection: WebXRControllerPointerSelection;
  49714. /**
  49715. * Default target xr should render to
  49716. */
  49717. renderTarget: WebXRRenderTarget;
  49718. /**
  49719. * Enables teleportation
  49720. */
  49721. teleportation: WebXRMotionControllerTeleportation;
  49722. private constructor();
  49723. /**
  49724. * Creates the default xr experience
  49725. * @param scene scene
  49726. * @param options options for basic configuration
  49727. * @returns resulting WebXRDefaultExperience
  49728. */
  49729. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49730. /**
  49731. * DIsposes of the experience helper
  49732. */
  49733. dispose(): void;
  49734. }
  49735. }
  49736. declare module BABYLON {
  49737. /**
  49738. * Options to modify the vr teleportation behavior.
  49739. */
  49740. export interface VRTeleportationOptions {
  49741. /**
  49742. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49743. */
  49744. floorMeshName?: string;
  49745. /**
  49746. * A list of meshes to be used as the teleportation floor. (default: empty)
  49747. */
  49748. floorMeshes?: Mesh[];
  49749. /**
  49750. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49751. */
  49752. teleportationMode?: number;
  49753. /**
  49754. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49755. */
  49756. teleportationTime?: number;
  49757. /**
  49758. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49759. */
  49760. teleportationSpeed?: number;
  49761. /**
  49762. * The easing function used in the animation or null for Linear. (default CircleEase)
  49763. */
  49764. easingFunction?: EasingFunction;
  49765. }
  49766. /**
  49767. * Options to modify the vr experience helper's behavior.
  49768. */
  49769. export interface VRExperienceHelperOptions extends WebVROptions {
  49770. /**
  49771. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49772. */
  49773. createDeviceOrientationCamera?: boolean;
  49774. /**
  49775. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49776. */
  49777. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49778. /**
  49779. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49780. */
  49781. laserToggle?: boolean;
  49782. /**
  49783. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49784. */
  49785. floorMeshes?: Mesh[];
  49786. /**
  49787. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49788. */
  49789. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49790. /**
  49791. * Defines if WebXR should be used instead of WebVR (if available)
  49792. */
  49793. useXR?: boolean;
  49794. }
  49795. /**
  49796. * Event containing information after VR has been entered
  49797. */
  49798. export class OnAfterEnteringVRObservableEvent {
  49799. /**
  49800. * If entering vr was successful
  49801. */
  49802. success: boolean;
  49803. }
  49804. /**
  49805. * Helps to quickly add VR support to an existing scene.
  49806. * See https://doc.babylonjs.com/how_to/webvr_helper
  49807. */
  49808. export class VRExperienceHelper {
  49809. /** Options to modify the vr experience helper's behavior. */
  49810. webVROptions: VRExperienceHelperOptions;
  49811. private _scene;
  49812. private _position;
  49813. private _btnVR;
  49814. private _btnVRDisplayed;
  49815. private _webVRsupported;
  49816. private _webVRready;
  49817. private _webVRrequesting;
  49818. private _webVRpresenting;
  49819. private _hasEnteredVR;
  49820. private _fullscreenVRpresenting;
  49821. private _inputElement;
  49822. private _webVRCamera;
  49823. private _vrDeviceOrientationCamera;
  49824. private _deviceOrientationCamera;
  49825. private _existingCamera;
  49826. private _onKeyDown;
  49827. private _onVrDisplayPresentChange;
  49828. private _onVRDisplayChanged;
  49829. private _onVRRequestPresentStart;
  49830. private _onVRRequestPresentComplete;
  49831. /**
  49832. * 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)
  49833. */
  49834. enableGazeEvenWhenNoPointerLock: boolean;
  49835. /**
  49836. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  49837. */
  49838. exitVROnDoubleTap: boolean;
  49839. /**
  49840. * Observable raised right before entering VR.
  49841. */
  49842. onEnteringVRObservable: Observable<VRExperienceHelper>;
  49843. /**
  49844. * Observable raised when entering VR has completed.
  49845. */
  49846. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  49847. /**
  49848. * Observable raised when exiting VR.
  49849. */
  49850. onExitingVRObservable: Observable<VRExperienceHelper>;
  49851. /**
  49852. * Observable raised when controller mesh is loaded.
  49853. */
  49854. onControllerMeshLoadedObservable: Observable<WebVRController>;
  49855. /** Return this.onEnteringVRObservable
  49856. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  49857. */
  49858. get onEnteringVR(): Observable<VRExperienceHelper>;
  49859. /** Return this.onExitingVRObservable
  49860. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  49861. */
  49862. get onExitingVR(): Observable<VRExperienceHelper>;
  49863. /** Return this.onControllerMeshLoadedObservable
  49864. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  49865. */
  49866. get onControllerMeshLoaded(): Observable<WebVRController>;
  49867. private _rayLength;
  49868. private _useCustomVRButton;
  49869. private _teleportationRequested;
  49870. private _teleportActive;
  49871. private _floorMeshName;
  49872. private _floorMeshesCollection;
  49873. private _teleportationMode;
  49874. private _teleportationTime;
  49875. private _teleportationSpeed;
  49876. private _teleportationEasing;
  49877. private _rotationAllowed;
  49878. private _teleportBackwardsVector;
  49879. private _teleportationTarget;
  49880. private _isDefaultTeleportationTarget;
  49881. private _postProcessMove;
  49882. private _teleportationFillColor;
  49883. private _teleportationBorderColor;
  49884. private _rotationAngle;
  49885. private _haloCenter;
  49886. private _cameraGazer;
  49887. private _padSensibilityUp;
  49888. private _padSensibilityDown;
  49889. private _leftController;
  49890. private _rightController;
  49891. private _gazeColor;
  49892. private _laserColor;
  49893. private _pickedLaserColor;
  49894. private _pickedGazeColor;
  49895. /**
  49896. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  49897. */
  49898. onNewMeshSelected: Observable<AbstractMesh>;
  49899. /**
  49900. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  49901. * This observable will provide the mesh and the controller used to select the mesh
  49902. */
  49903. onMeshSelectedWithController: Observable<{
  49904. mesh: AbstractMesh;
  49905. controller: WebVRController;
  49906. }>;
  49907. /**
  49908. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  49909. */
  49910. onNewMeshPicked: Observable<PickingInfo>;
  49911. private _circleEase;
  49912. /**
  49913. * Observable raised before camera teleportation
  49914. */
  49915. onBeforeCameraTeleport: Observable<Vector3>;
  49916. /**
  49917. * Observable raised after camera teleportation
  49918. */
  49919. onAfterCameraTeleport: Observable<Vector3>;
  49920. /**
  49921. * Observable raised when current selected mesh gets unselected
  49922. */
  49923. onSelectedMeshUnselected: Observable<AbstractMesh>;
  49924. private _raySelectionPredicate;
  49925. /**
  49926. * To be optionaly changed by user to define custom ray selection
  49927. */
  49928. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49929. /**
  49930. * To be optionaly changed by user to define custom selection logic (after ray selection)
  49931. */
  49932. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49933. /**
  49934. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  49935. */
  49936. teleportationEnabled: boolean;
  49937. private _defaultHeight;
  49938. private _teleportationInitialized;
  49939. private _interactionsEnabled;
  49940. private _interactionsRequested;
  49941. private _displayGaze;
  49942. private _displayLaserPointer;
  49943. /**
  49944. * The mesh used to display where the user is going to teleport.
  49945. */
  49946. get teleportationTarget(): Mesh;
  49947. /**
  49948. * Sets the mesh to be used to display where the user is going to teleport.
  49949. */
  49950. set teleportationTarget(value: Mesh);
  49951. /**
  49952. * 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
  49953. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  49954. * See https://doc.babylonjs.com/resources/baking_transformations
  49955. */
  49956. get gazeTrackerMesh(): Mesh;
  49957. set gazeTrackerMesh(value: Mesh);
  49958. /**
  49959. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  49960. */
  49961. updateGazeTrackerScale: boolean;
  49962. /**
  49963. * If the gaze trackers color should be updated when selecting meshes
  49964. */
  49965. updateGazeTrackerColor: boolean;
  49966. /**
  49967. * If the controller laser color should be updated when selecting meshes
  49968. */
  49969. updateControllerLaserColor: boolean;
  49970. /**
  49971. * The gaze tracking mesh corresponding to the left controller
  49972. */
  49973. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  49974. /**
  49975. * The gaze tracking mesh corresponding to the right controller
  49976. */
  49977. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  49978. /**
  49979. * If the ray of the gaze should be displayed.
  49980. */
  49981. get displayGaze(): boolean;
  49982. /**
  49983. * Sets if the ray of the gaze should be displayed.
  49984. */
  49985. set displayGaze(value: boolean);
  49986. /**
  49987. * If the ray of the LaserPointer should be displayed.
  49988. */
  49989. get displayLaserPointer(): boolean;
  49990. /**
  49991. * Sets if the ray of the LaserPointer should be displayed.
  49992. */
  49993. set displayLaserPointer(value: boolean);
  49994. /**
  49995. * The deviceOrientationCamera used as the camera when not in VR.
  49996. */
  49997. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  49998. /**
  49999. * Based on the current WebVR support, returns the current VR camera used.
  50000. */
  50001. get currentVRCamera(): Nullable<Camera>;
  50002. /**
  50003. * The webVRCamera which is used when in VR.
  50004. */
  50005. get webVRCamera(): WebVRFreeCamera;
  50006. /**
  50007. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  50008. */
  50009. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  50010. /**
  50011. * The html button that is used to trigger entering into VR.
  50012. */
  50013. get vrButton(): Nullable<HTMLButtonElement>;
  50014. private get _teleportationRequestInitiated();
  50015. /**
  50016. * Defines whether or not Pointer lock should be requested when switching to
  50017. * full screen.
  50018. */
  50019. requestPointerLockOnFullScreen: boolean;
  50020. /**
  50021. * If asking to force XR, this will be populated with the default xr experience
  50022. */
  50023. xr: WebXRDefaultExperience;
  50024. /**
  50025. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  50026. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  50027. */
  50028. xrTestDone: boolean;
  50029. /**
  50030. * Instantiates a VRExperienceHelper.
  50031. * Helps to quickly add VR support to an existing scene.
  50032. * @param scene The scene the VRExperienceHelper belongs to.
  50033. * @param webVROptions Options to modify the vr experience helper's behavior.
  50034. */
  50035. constructor(scene: Scene,
  50036. /** Options to modify the vr experience helper's behavior. */
  50037. webVROptions?: VRExperienceHelperOptions);
  50038. private completeVRInit;
  50039. private _onDefaultMeshLoaded;
  50040. private _onResize;
  50041. private _onFullscreenChange;
  50042. /**
  50043. * Gets a value indicating if we are currently in VR mode.
  50044. */
  50045. get isInVRMode(): boolean;
  50046. private onVrDisplayPresentChange;
  50047. private onVRDisplayChanged;
  50048. private moveButtonToBottomRight;
  50049. private displayVRButton;
  50050. private updateButtonVisibility;
  50051. private _cachedAngularSensibility;
  50052. /**
  50053. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  50054. * Otherwise, will use the fullscreen API.
  50055. */
  50056. enterVR(): void;
  50057. /**
  50058. * Attempt to exit VR, or fullscreen.
  50059. */
  50060. exitVR(): void;
  50061. /**
  50062. * The position of the vr experience helper.
  50063. */
  50064. get position(): Vector3;
  50065. /**
  50066. * Sets the position of the vr experience helper.
  50067. */
  50068. set position(value: Vector3);
  50069. /**
  50070. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  50071. */
  50072. enableInteractions(): void;
  50073. private get _noControllerIsActive();
  50074. private beforeRender;
  50075. private _isTeleportationFloor;
  50076. /**
  50077. * Adds a floor mesh to be used for teleportation.
  50078. * @param floorMesh the mesh to be used for teleportation.
  50079. */
  50080. addFloorMesh(floorMesh: Mesh): void;
  50081. /**
  50082. * Removes a floor mesh from being used for teleportation.
  50083. * @param floorMesh the mesh to be removed.
  50084. */
  50085. removeFloorMesh(floorMesh: Mesh): void;
  50086. /**
  50087. * Enables interactions and teleportation using the VR controllers and gaze.
  50088. * @param vrTeleportationOptions options to modify teleportation behavior.
  50089. */
  50090. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  50091. private _onNewGamepadConnected;
  50092. private _tryEnableInteractionOnController;
  50093. private _onNewGamepadDisconnected;
  50094. private _enableInteractionOnController;
  50095. private _checkTeleportWithRay;
  50096. private _checkRotate;
  50097. private _checkTeleportBackwards;
  50098. private _enableTeleportationOnController;
  50099. private _createTeleportationCircles;
  50100. private _displayTeleportationTarget;
  50101. private _hideTeleportationTarget;
  50102. private _rotateCamera;
  50103. private _moveTeleportationSelectorTo;
  50104. private _workingVector;
  50105. private _workingQuaternion;
  50106. private _workingMatrix;
  50107. /**
  50108. * Time Constant Teleportation Mode
  50109. */
  50110. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  50111. /**
  50112. * Speed Constant Teleportation Mode
  50113. */
  50114. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  50115. /**
  50116. * Teleports the users feet to the desired location
  50117. * @param location The location where the user's feet should be placed
  50118. */
  50119. teleportCamera(location: Vector3): void;
  50120. private _convertNormalToDirectionOfRay;
  50121. private _castRayAndSelectObject;
  50122. private _notifySelectedMeshUnselected;
  50123. /**
  50124. * Permanently set new colors for the laser pointer
  50125. * @param color the new laser color
  50126. * @param pickedColor the new laser color when picked mesh detected
  50127. */
  50128. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50129. /**
  50130. * Set lighting enabled / disabled on the laser pointer of both controllers
  50131. * @param enabled should the lighting be enabled on the laser pointer
  50132. */
  50133. setLaserLightingState(enabled?: boolean): void;
  50134. /**
  50135. * Permanently set new colors for the gaze pointer
  50136. * @param color the new gaze color
  50137. * @param pickedColor the new gaze color when picked mesh detected
  50138. */
  50139. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50140. /**
  50141. * Sets the color of the laser ray from the vr controllers.
  50142. * @param color new color for the ray.
  50143. */
  50144. changeLaserColor(color: Color3): void;
  50145. /**
  50146. * Sets the color of the ray from the vr headsets gaze.
  50147. * @param color new color for the ray.
  50148. */
  50149. changeGazeColor(color: Color3): void;
  50150. /**
  50151. * Exits VR and disposes of the vr experience helper
  50152. */
  50153. dispose(): void;
  50154. /**
  50155. * Gets the name of the VRExperienceHelper class
  50156. * @returns "VRExperienceHelper"
  50157. */
  50158. getClassName(): string;
  50159. }
  50160. }
  50161. declare module BABYLON {
  50162. /**
  50163. * Contains an array of blocks representing the octree
  50164. */
  50165. export interface IOctreeContainer<T> {
  50166. /**
  50167. * Blocks within the octree
  50168. */
  50169. blocks: Array<OctreeBlock<T>>;
  50170. }
  50171. /**
  50172. * Class used to store a cell in an octree
  50173. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50174. */
  50175. export class OctreeBlock<T> {
  50176. /**
  50177. * Gets the content of the current block
  50178. */
  50179. entries: T[];
  50180. /**
  50181. * Gets the list of block children
  50182. */
  50183. blocks: Array<OctreeBlock<T>>;
  50184. private _depth;
  50185. private _maxDepth;
  50186. private _capacity;
  50187. private _minPoint;
  50188. private _maxPoint;
  50189. private _boundingVectors;
  50190. private _creationFunc;
  50191. /**
  50192. * Creates a new block
  50193. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  50194. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  50195. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50196. * @param depth defines the current depth of this block in the octree
  50197. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  50198. * @param creationFunc defines a callback to call when an element is added to the block
  50199. */
  50200. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  50201. /**
  50202. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50203. */
  50204. get capacity(): number;
  50205. /**
  50206. * Gets the minimum vector (in world space) of the block's bounding box
  50207. */
  50208. get minPoint(): Vector3;
  50209. /**
  50210. * Gets the maximum vector (in world space) of the block's bounding box
  50211. */
  50212. get maxPoint(): Vector3;
  50213. /**
  50214. * Add a new element to this block
  50215. * @param entry defines the element to add
  50216. */
  50217. addEntry(entry: T): void;
  50218. /**
  50219. * Remove an element from this block
  50220. * @param entry defines the element to remove
  50221. */
  50222. removeEntry(entry: T): void;
  50223. /**
  50224. * Add an array of elements to this block
  50225. * @param entries defines the array of elements to add
  50226. */
  50227. addEntries(entries: T[]): void;
  50228. /**
  50229. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50230. * @param frustumPlanes defines the frustum planes to test
  50231. * @param selection defines the array to store current content if selection is positive
  50232. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50233. */
  50234. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50235. /**
  50236. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50237. * @param sphereCenter defines the bounding sphere center
  50238. * @param sphereRadius defines the bounding sphere radius
  50239. * @param selection defines the array to store current content if selection is positive
  50240. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50241. */
  50242. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50243. /**
  50244. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50245. * @param ray defines the ray to test with
  50246. * @param selection defines the array to store current content if selection is positive
  50247. */
  50248. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50249. /**
  50250. * Subdivide the content into child blocks (this block will then be empty)
  50251. */
  50252. createInnerBlocks(): void;
  50253. /**
  50254. * @hidden
  50255. */
  50256. 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;
  50257. }
  50258. }
  50259. declare module BABYLON {
  50260. /**
  50261. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50262. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50263. */
  50264. export class Octree<T> {
  50265. /** 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.) */
  50266. maxDepth: number;
  50267. /**
  50268. * Blocks within the octree containing objects
  50269. */
  50270. blocks: Array<OctreeBlock<T>>;
  50271. /**
  50272. * Content stored in the octree
  50273. */
  50274. dynamicContent: T[];
  50275. private _maxBlockCapacity;
  50276. private _selectionContent;
  50277. private _creationFunc;
  50278. /**
  50279. * Creates a octree
  50280. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50281. * @param creationFunc function to be used to instatiate the octree
  50282. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50283. * @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.)
  50284. */
  50285. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50286. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  50287. maxDepth?: number);
  50288. /**
  50289. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50290. * @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);
  50291. * @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);
  50292. * @param entries meshes to be added to the octree blocks
  50293. */
  50294. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50295. /**
  50296. * Adds a mesh to the octree
  50297. * @param entry Mesh to add to the octree
  50298. */
  50299. addMesh(entry: T): void;
  50300. /**
  50301. * Remove an element from the octree
  50302. * @param entry defines the element to remove
  50303. */
  50304. removeMesh(entry: T): void;
  50305. /**
  50306. * Selects an array of meshes within the frustum
  50307. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  50308. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  50309. * @returns array of meshes within the frustum
  50310. */
  50311. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  50312. /**
  50313. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  50314. * @param sphereCenter defines the bounding sphere center
  50315. * @param sphereRadius defines the bounding sphere radius
  50316. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50317. * @returns an array of objects that intersect the sphere
  50318. */
  50319. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  50320. /**
  50321. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  50322. * @param ray defines the ray to test with
  50323. * @returns array of intersected objects
  50324. */
  50325. intersectsRay(ray: Ray): SmartArray<T>;
  50326. /**
  50327. * Adds a mesh into the octree block if it intersects the block
  50328. */
  50329. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  50330. /**
  50331. * Adds a submesh into the octree block if it intersects the block
  50332. */
  50333. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  50334. }
  50335. }
  50336. declare module BABYLON {
  50337. interface Scene {
  50338. /**
  50339. * @hidden
  50340. * Backing Filed
  50341. */
  50342. _selectionOctree: Octree<AbstractMesh>;
  50343. /**
  50344. * Gets the octree used to boost mesh selection (picking)
  50345. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50346. */
  50347. selectionOctree: Octree<AbstractMesh>;
  50348. /**
  50349. * Creates or updates the octree used to boost selection (picking)
  50350. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50351. * @param maxCapacity defines the maximum capacity per leaf
  50352. * @param maxDepth defines the maximum depth of the octree
  50353. * @returns an octree of AbstractMesh
  50354. */
  50355. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  50356. }
  50357. interface AbstractMesh {
  50358. /**
  50359. * @hidden
  50360. * Backing Field
  50361. */
  50362. _submeshesOctree: Octree<SubMesh>;
  50363. /**
  50364. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  50365. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  50366. * @param maxCapacity defines the maximum size of each block (64 by default)
  50367. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  50368. * @returns the new octree
  50369. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  50370. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50371. */
  50372. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50373. }
  50374. /**
  50375. * Defines the octree scene component responsible to manage any octrees
  50376. * in a given scene.
  50377. */
  50378. export class OctreeSceneComponent {
  50379. /**
  50380. * The component name help to identify the component in the list of scene components.
  50381. */
  50382. readonly name: string;
  50383. /**
  50384. * The scene the component belongs to.
  50385. */
  50386. scene: Scene;
  50387. /**
  50388. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50389. */
  50390. readonly checksIsEnabled: boolean;
  50391. /**
  50392. * Creates a new instance of the component for the given scene
  50393. * @param scene Defines the scene to register the component in
  50394. */
  50395. constructor(scene: Scene);
  50396. /**
  50397. * Registers the component in a given scene
  50398. */
  50399. register(): void;
  50400. /**
  50401. * Return the list of active meshes
  50402. * @returns the list of active meshes
  50403. */
  50404. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50405. /**
  50406. * Return the list of active sub meshes
  50407. * @param mesh The mesh to get the candidates sub meshes from
  50408. * @returns the list of active sub meshes
  50409. */
  50410. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50411. private _tempRay;
  50412. /**
  50413. * Return the list of sub meshes intersecting with a given local ray
  50414. * @param mesh defines the mesh to find the submesh for
  50415. * @param localRay defines the ray in local space
  50416. * @returns the list of intersecting sub meshes
  50417. */
  50418. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50419. /**
  50420. * Return the list of sub meshes colliding with a collider
  50421. * @param mesh defines the mesh to find the submesh for
  50422. * @param collider defines the collider to evaluate the collision against
  50423. * @returns the list of colliding sub meshes
  50424. */
  50425. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50426. /**
  50427. * Rebuilds the elements related to this component in case of
  50428. * context lost for instance.
  50429. */
  50430. rebuild(): void;
  50431. /**
  50432. * Disposes the component and the associated ressources.
  50433. */
  50434. dispose(): void;
  50435. }
  50436. }
  50437. declare module BABYLON {
  50438. /**
  50439. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50440. */
  50441. export class Gizmo implements IDisposable {
  50442. /** The utility layer the gizmo will be added to */
  50443. gizmoLayer: UtilityLayerRenderer;
  50444. /**
  50445. * The root mesh of the gizmo
  50446. */
  50447. _rootMesh: Mesh;
  50448. private _attachedMesh;
  50449. private _attachedNode;
  50450. /**
  50451. * Ratio for the scale of the gizmo (Default: 1)
  50452. */
  50453. protected _scaleRatio: number;
  50454. /**
  50455. * boolean updated by pointermove when a gizmo mesh is hovered
  50456. */
  50457. protected _isHovered: boolean;
  50458. /**
  50459. * Ratio for the scale of the gizmo (Default: 1)
  50460. */
  50461. set scaleRatio(value: number);
  50462. get scaleRatio(): number;
  50463. /**
  50464. * True when the mouse pointer is hovered a gizmo mesh
  50465. */
  50466. get isHovered(): boolean;
  50467. /**
  50468. * If a custom mesh has been set (Default: false)
  50469. */
  50470. protected _customMeshSet: boolean;
  50471. /**
  50472. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50473. * * When set, interactions will be enabled
  50474. */
  50475. get attachedMesh(): Nullable<AbstractMesh>;
  50476. set attachedMesh(value: Nullable<AbstractMesh>);
  50477. /**
  50478. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  50479. * * When set, interactions will be enabled
  50480. */
  50481. get attachedNode(): Nullable<Node>;
  50482. set attachedNode(value: Nullable<Node>);
  50483. /**
  50484. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50485. * @param mesh The mesh to replace the default mesh of the gizmo
  50486. */
  50487. setCustomMesh(mesh: Mesh): void;
  50488. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  50489. /**
  50490. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50491. */
  50492. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50493. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50494. /**
  50495. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50496. */
  50497. updateGizmoPositionToMatchAttachedMesh: boolean;
  50498. /**
  50499. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50500. */
  50501. updateScale: boolean;
  50502. protected _interactionsEnabled: boolean;
  50503. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50504. private _beforeRenderObserver;
  50505. private _tempQuaternion;
  50506. private _tempVector;
  50507. private _tempVector2;
  50508. private _tempMatrix1;
  50509. private _tempMatrix2;
  50510. private _rightHandtoLeftHandMatrix;
  50511. /**
  50512. * Creates a gizmo
  50513. * @param gizmoLayer The utility layer the gizmo will be added to
  50514. */
  50515. constructor(
  50516. /** The utility layer the gizmo will be added to */
  50517. gizmoLayer?: UtilityLayerRenderer);
  50518. /**
  50519. * Updates the gizmo to match the attached mesh's position/rotation
  50520. */
  50521. protected _update(): void;
  50522. /**
  50523. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  50524. * @param value Node, TransformNode or mesh
  50525. */
  50526. protected _matrixChanged(): void;
  50527. /**
  50528. * Disposes of the gizmo
  50529. */
  50530. dispose(): void;
  50531. }
  50532. }
  50533. declare module BABYLON {
  50534. /**
  50535. * Single plane drag gizmo
  50536. */
  50537. export class PlaneDragGizmo extends Gizmo {
  50538. /**
  50539. * Drag behavior responsible for the gizmos dragging interactions
  50540. */
  50541. dragBehavior: PointerDragBehavior;
  50542. private _pointerObserver;
  50543. /**
  50544. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50545. */
  50546. snapDistance: number;
  50547. /**
  50548. * Event that fires each time the gizmo snaps to a new location.
  50549. * * snapDistance is the the change in distance
  50550. */
  50551. onSnapObservable: Observable<{
  50552. snapDistance: number;
  50553. }>;
  50554. private _plane;
  50555. private _coloredMaterial;
  50556. private _hoverMaterial;
  50557. private _isEnabled;
  50558. private _parent;
  50559. /** @hidden */
  50560. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50561. /** @hidden */
  50562. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50563. /**
  50564. * Creates a PlaneDragGizmo
  50565. * @param gizmoLayer The utility layer the gizmo will be added to
  50566. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50567. * @param color The color of the gizmo
  50568. */
  50569. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50570. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50571. /**
  50572. * If the gizmo is enabled
  50573. */
  50574. set isEnabled(value: boolean);
  50575. get isEnabled(): boolean;
  50576. /**
  50577. * Disposes of the gizmo
  50578. */
  50579. dispose(): void;
  50580. }
  50581. }
  50582. declare module BABYLON {
  50583. /**
  50584. * Gizmo that enables dragging a mesh along 3 axis
  50585. */
  50586. export class PositionGizmo extends Gizmo {
  50587. /**
  50588. * Internal gizmo used for interactions on the x axis
  50589. */
  50590. xGizmo: AxisDragGizmo;
  50591. /**
  50592. * Internal gizmo used for interactions on the y axis
  50593. */
  50594. yGizmo: AxisDragGizmo;
  50595. /**
  50596. * Internal gizmo used for interactions on the z axis
  50597. */
  50598. zGizmo: AxisDragGizmo;
  50599. /**
  50600. * Internal gizmo used for interactions on the yz plane
  50601. */
  50602. xPlaneGizmo: PlaneDragGizmo;
  50603. /**
  50604. * Internal gizmo used for interactions on the xz plane
  50605. */
  50606. yPlaneGizmo: PlaneDragGizmo;
  50607. /**
  50608. * Internal gizmo used for interactions on the xy plane
  50609. */
  50610. zPlaneGizmo: PlaneDragGizmo;
  50611. /**
  50612. * private variables
  50613. */
  50614. private _meshAttached;
  50615. private _nodeAttached;
  50616. private _snapDistance;
  50617. /** Fires an event when any of it's sub gizmos are dragged */
  50618. onDragStartObservable: Observable<unknown>;
  50619. /** Fires an event when any of it's sub gizmos are released from dragging */
  50620. onDragEndObservable: Observable<unknown>;
  50621. /**
  50622. * If set to true, planar drag is enabled
  50623. */
  50624. private _planarGizmoEnabled;
  50625. get attachedMesh(): Nullable<AbstractMesh>;
  50626. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50627. get attachedNode(): Nullable<Node>;
  50628. set attachedNode(node: Nullable<Node>);
  50629. /**
  50630. * True when the mouse pointer is hovering a gizmo mesh
  50631. */
  50632. get isHovered(): boolean;
  50633. /**
  50634. * Creates a PositionGizmo
  50635. * @param gizmoLayer The utility layer the gizmo will be added to
  50636. @param thickness display gizmo axis thickness
  50637. */
  50638. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  50639. /**
  50640. * If the planar drag gizmo is enabled
  50641. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50642. */
  50643. set planarGizmoEnabled(value: boolean);
  50644. get planarGizmoEnabled(): boolean;
  50645. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50646. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50647. /**
  50648. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50649. */
  50650. set snapDistance(value: number);
  50651. get snapDistance(): number;
  50652. /**
  50653. * Ratio for the scale of the gizmo (Default: 1)
  50654. */
  50655. set scaleRatio(value: number);
  50656. get scaleRatio(): number;
  50657. /**
  50658. * Disposes of the gizmo
  50659. */
  50660. dispose(): void;
  50661. /**
  50662. * CustomMeshes are not supported by this gizmo
  50663. * @param mesh The mesh to replace the default mesh of the gizmo
  50664. */
  50665. setCustomMesh(mesh: Mesh): void;
  50666. }
  50667. }
  50668. declare module BABYLON {
  50669. /**
  50670. * Single axis drag gizmo
  50671. */
  50672. export class AxisDragGizmo extends Gizmo {
  50673. /**
  50674. * Drag behavior responsible for the gizmos dragging interactions
  50675. */
  50676. dragBehavior: PointerDragBehavior;
  50677. private _pointerObserver;
  50678. /**
  50679. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50680. */
  50681. snapDistance: number;
  50682. /**
  50683. * Event that fires each time the gizmo snaps to a new location.
  50684. * * snapDistance is the the change in distance
  50685. */
  50686. onSnapObservable: Observable<{
  50687. snapDistance: number;
  50688. }>;
  50689. private _isEnabled;
  50690. private _parent;
  50691. private _arrow;
  50692. private _coloredMaterial;
  50693. private _hoverMaterial;
  50694. /** @hidden */
  50695. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  50696. /** @hidden */
  50697. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50698. /**
  50699. * Creates an AxisDragGizmo
  50700. * @param gizmoLayer The utility layer the gizmo will be added to
  50701. * @param dragAxis The axis which the gizmo will be able to drag on
  50702. * @param color The color of the gizmo
  50703. * @param thickness display gizmo axis thickness
  50704. */
  50705. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  50706. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50707. /**
  50708. * If the gizmo is enabled
  50709. */
  50710. set isEnabled(value: boolean);
  50711. get isEnabled(): boolean;
  50712. /**
  50713. * Disposes of the gizmo
  50714. */
  50715. dispose(): void;
  50716. }
  50717. }
  50718. declare module BABYLON.Debug {
  50719. /**
  50720. * The Axes viewer will show 3 axes in a specific point in space
  50721. */
  50722. export class AxesViewer {
  50723. private _xAxis;
  50724. private _yAxis;
  50725. private _zAxis;
  50726. private _scaleLinesFactor;
  50727. private _instanced;
  50728. /**
  50729. * Gets the hosting scene
  50730. */
  50731. scene: Nullable<Scene>;
  50732. /**
  50733. * Gets or sets a number used to scale line length
  50734. */
  50735. scaleLines: number;
  50736. /** Gets the node hierarchy used to render x-axis */
  50737. get xAxis(): TransformNode;
  50738. /** Gets the node hierarchy used to render y-axis */
  50739. get yAxis(): TransformNode;
  50740. /** Gets the node hierarchy used to render z-axis */
  50741. get zAxis(): TransformNode;
  50742. /**
  50743. * Creates a new AxesViewer
  50744. * @param scene defines the hosting scene
  50745. * @param scaleLines defines a number used to scale line length (1 by default)
  50746. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50747. * @param xAxis defines the node hierarchy used to render the x-axis
  50748. * @param yAxis defines the node hierarchy used to render the y-axis
  50749. * @param zAxis defines the node hierarchy used to render the z-axis
  50750. */
  50751. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  50752. /**
  50753. * Force the viewer to update
  50754. * @param position defines the position of the viewer
  50755. * @param xaxis defines the x axis of the viewer
  50756. * @param yaxis defines the y axis of the viewer
  50757. * @param zaxis defines the z axis of the viewer
  50758. */
  50759. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  50760. /**
  50761. * Creates an instance of this axes viewer.
  50762. * @returns a new axes viewer with instanced meshes
  50763. */
  50764. createInstance(): AxesViewer;
  50765. /** Releases resources */
  50766. dispose(): void;
  50767. private static _SetRenderingGroupId;
  50768. }
  50769. }
  50770. declare module BABYLON.Debug {
  50771. /**
  50772. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  50773. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  50774. */
  50775. export class BoneAxesViewer extends AxesViewer {
  50776. /**
  50777. * Gets or sets the target mesh where to display the axes viewer
  50778. */
  50779. mesh: Nullable<Mesh>;
  50780. /**
  50781. * Gets or sets the target bone where to display the axes viewer
  50782. */
  50783. bone: Nullable<Bone>;
  50784. /** Gets current position */
  50785. pos: Vector3;
  50786. /** Gets direction of X axis */
  50787. xaxis: Vector3;
  50788. /** Gets direction of Y axis */
  50789. yaxis: Vector3;
  50790. /** Gets direction of Z axis */
  50791. zaxis: Vector3;
  50792. /**
  50793. * Creates a new BoneAxesViewer
  50794. * @param scene defines the hosting scene
  50795. * @param bone defines the target bone
  50796. * @param mesh defines the target mesh
  50797. * @param scaleLines defines a scaling factor for line length (1 by default)
  50798. */
  50799. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  50800. /**
  50801. * Force the viewer to update
  50802. */
  50803. update(): void;
  50804. /** Releases resources */
  50805. dispose(): void;
  50806. }
  50807. }
  50808. declare module BABYLON {
  50809. /**
  50810. * Interface used to define scene explorer extensibility option
  50811. */
  50812. export interface IExplorerExtensibilityOption {
  50813. /**
  50814. * Define the option label
  50815. */
  50816. label: string;
  50817. /**
  50818. * Defines the action to execute on click
  50819. */
  50820. action: (entity: any) => void;
  50821. }
  50822. /**
  50823. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  50824. */
  50825. export interface IExplorerExtensibilityGroup {
  50826. /**
  50827. * Defines a predicate to test if a given type mut be extended
  50828. */
  50829. predicate: (entity: any) => boolean;
  50830. /**
  50831. * Gets the list of options added to a type
  50832. */
  50833. entries: IExplorerExtensibilityOption[];
  50834. }
  50835. /**
  50836. * Interface used to define the options to use to create the Inspector
  50837. */
  50838. export interface IInspectorOptions {
  50839. /**
  50840. * Display in overlay mode (default: false)
  50841. */
  50842. overlay?: boolean;
  50843. /**
  50844. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  50845. */
  50846. globalRoot?: HTMLElement;
  50847. /**
  50848. * Display the Scene explorer
  50849. */
  50850. showExplorer?: boolean;
  50851. /**
  50852. * Display the property inspector
  50853. */
  50854. showInspector?: boolean;
  50855. /**
  50856. * Display in embed mode (both panes on the right)
  50857. */
  50858. embedMode?: boolean;
  50859. /**
  50860. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  50861. */
  50862. handleResize?: boolean;
  50863. /**
  50864. * Allow the panes to popup (default: true)
  50865. */
  50866. enablePopup?: boolean;
  50867. /**
  50868. * Allow the panes to be closed by users (default: true)
  50869. */
  50870. enableClose?: boolean;
  50871. /**
  50872. * Optional list of extensibility entries
  50873. */
  50874. explorerExtensibility?: IExplorerExtensibilityGroup[];
  50875. /**
  50876. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  50877. */
  50878. inspectorURL?: string;
  50879. /**
  50880. * Optional initial tab (default to DebugLayerTab.Properties)
  50881. */
  50882. initialTab?: DebugLayerTab;
  50883. }
  50884. interface Scene {
  50885. /**
  50886. * @hidden
  50887. * Backing field
  50888. */
  50889. _debugLayer: DebugLayer;
  50890. /**
  50891. * Gets the debug layer (aka Inspector) associated with the scene
  50892. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50893. */
  50894. debugLayer: DebugLayer;
  50895. }
  50896. /**
  50897. * Enum of inspector action tab
  50898. */
  50899. export enum DebugLayerTab {
  50900. /**
  50901. * Properties tag (default)
  50902. */
  50903. Properties = 0,
  50904. /**
  50905. * Debug tab
  50906. */
  50907. Debug = 1,
  50908. /**
  50909. * Statistics tab
  50910. */
  50911. Statistics = 2,
  50912. /**
  50913. * Tools tab
  50914. */
  50915. Tools = 3,
  50916. /**
  50917. * Settings tab
  50918. */
  50919. Settings = 4
  50920. }
  50921. /**
  50922. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50923. * what is happening in your scene
  50924. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50925. */
  50926. export class DebugLayer {
  50927. /**
  50928. * Define the url to get the inspector script from.
  50929. * By default it uses the babylonjs CDN.
  50930. * @ignoreNaming
  50931. */
  50932. static InspectorURL: string;
  50933. private _scene;
  50934. private BJSINSPECTOR;
  50935. private _onPropertyChangedObservable?;
  50936. /**
  50937. * Observable triggered when a property is changed through the inspector.
  50938. */
  50939. get onPropertyChangedObservable(): any;
  50940. /**
  50941. * Instantiates a new debug layer.
  50942. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50943. * what is happening in your scene
  50944. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50945. * @param scene Defines the scene to inspect
  50946. */
  50947. constructor(scene: Scene);
  50948. /** Creates the inspector window. */
  50949. private _createInspector;
  50950. /**
  50951. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  50952. * @param entity defines the entity to select
  50953. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  50954. */
  50955. select(entity: any, lineContainerTitles?: string | string[]): void;
  50956. /** Get the inspector from bundle or global */
  50957. private _getGlobalInspector;
  50958. /**
  50959. * Get if the inspector is visible or not.
  50960. * @returns true if visible otherwise, false
  50961. */
  50962. isVisible(): boolean;
  50963. /**
  50964. * Hide the inspector and close its window.
  50965. */
  50966. hide(): void;
  50967. /**
  50968. * Update the scene in the inspector
  50969. */
  50970. setAsActiveScene(): void;
  50971. /**
  50972. * Launch the debugLayer.
  50973. * @param config Define the configuration of the inspector
  50974. * @return a promise fulfilled when the debug layer is visible
  50975. */
  50976. show(config?: IInspectorOptions): Promise<DebugLayer>;
  50977. }
  50978. }
  50979. declare module BABYLON {
  50980. /**
  50981. * Class containing static functions to help procedurally build meshes
  50982. */
  50983. export class BoxBuilder {
  50984. /**
  50985. * Creates a box mesh
  50986. * * The parameter `size` sets the size (float) of each box side (default 1)
  50987. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50988. * * 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)
  50989. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50990. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50991. * * 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
  50992. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50993. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50994. * @param name defines the name of the mesh
  50995. * @param options defines the options used to create the mesh
  50996. * @param scene defines the hosting scene
  50997. * @returns the box mesh
  50998. */
  50999. static CreateBox(name: string, options: {
  51000. size?: number;
  51001. width?: number;
  51002. height?: number;
  51003. depth?: number;
  51004. faceUV?: Vector4[];
  51005. faceColors?: Color4[];
  51006. sideOrientation?: number;
  51007. frontUVs?: Vector4;
  51008. backUVs?: Vector4;
  51009. wrap?: boolean;
  51010. topBaseAt?: number;
  51011. bottomBaseAt?: number;
  51012. updatable?: boolean;
  51013. }, scene?: Nullable<Scene>): Mesh;
  51014. }
  51015. }
  51016. declare module BABYLON.Debug {
  51017. /**
  51018. * Used to show the physics impostor around the specific mesh
  51019. */
  51020. export class PhysicsViewer {
  51021. /** @hidden */
  51022. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  51023. /** @hidden */
  51024. protected _meshes: Array<Nullable<AbstractMesh>>;
  51025. /** @hidden */
  51026. protected _scene: Nullable<Scene>;
  51027. /** @hidden */
  51028. protected _numMeshes: number;
  51029. /** @hidden */
  51030. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  51031. private _renderFunction;
  51032. private _utilityLayer;
  51033. private _debugBoxMesh;
  51034. private _debugSphereMesh;
  51035. private _debugCylinderMesh;
  51036. private _debugMaterial;
  51037. private _debugMeshMeshes;
  51038. /**
  51039. * Creates a new PhysicsViewer
  51040. * @param scene defines the hosting scene
  51041. */
  51042. constructor(scene: Scene);
  51043. /** @hidden */
  51044. protected _updateDebugMeshes(): void;
  51045. /**
  51046. * Renders a specified physic impostor
  51047. * @param impostor defines the impostor to render
  51048. * @param targetMesh defines the mesh represented by the impostor
  51049. * @returns the new debug mesh used to render the impostor
  51050. */
  51051. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  51052. /**
  51053. * Hides a specified physic impostor
  51054. * @param impostor defines the impostor to hide
  51055. */
  51056. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  51057. private _getDebugMaterial;
  51058. private _getDebugBoxMesh;
  51059. private _getDebugSphereMesh;
  51060. private _getDebugCylinderMesh;
  51061. private _getDebugMeshMesh;
  51062. private _getDebugMesh;
  51063. /** Releases all resources */
  51064. dispose(): void;
  51065. }
  51066. }
  51067. declare module BABYLON {
  51068. /**
  51069. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51070. * in order to better appreciate the issue one might have.
  51071. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  51072. */
  51073. export class RayHelper {
  51074. /**
  51075. * Defines the ray we are currently tryin to visualize.
  51076. */
  51077. ray: Nullable<Ray>;
  51078. private _renderPoints;
  51079. private _renderLine;
  51080. private _renderFunction;
  51081. private _scene;
  51082. private _onAfterRenderObserver;
  51083. private _onAfterStepObserver;
  51084. private _attachedToMesh;
  51085. private _meshSpaceDirection;
  51086. private _meshSpaceOrigin;
  51087. /**
  51088. * Helper function to create a colored helper in a scene in one line.
  51089. * @param ray Defines the ray we are currently tryin to visualize
  51090. * @param scene Defines the scene the ray is used in
  51091. * @param color Defines the color we want to see the ray in
  51092. * @returns The newly created ray helper.
  51093. */
  51094. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  51095. /**
  51096. * Instantiate a new ray helper.
  51097. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51098. * in order to better appreciate the issue one might have.
  51099. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  51100. * @param ray Defines the ray we are currently tryin to visualize
  51101. */
  51102. constructor(ray: Ray);
  51103. /**
  51104. * Shows the ray we are willing to debug.
  51105. * @param scene Defines the scene the ray needs to be rendered in
  51106. * @param color Defines the color the ray needs to be rendered in
  51107. */
  51108. show(scene: Scene, color?: Color3): void;
  51109. /**
  51110. * Hides the ray we are debugging.
  51111. */
  51112. hide(): void;
  51113. private _render;
  51114. /**
  51115. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  51116. * @param mesh Defines the mesh we want the helper attached to
  51117. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  51118. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  51119. * @param length Defines the length of the ray
  51120. */
  51121. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  51122. /**
  51123. * Detach the ray helper from the mesh it has previously been attached to.
  51124. */
  51125. detachFromMesh(): void;
  51126. private _updateToMesh;
  51127. /**
  51128. * Dispose the helper and release its associated resources.
  51129. */
  51130. dispose(): void;
  51131. }
  51132. }
  51133. declare module BABYLON {
  51134. /**
  51135. * Defines the options associated with the creation of a SkeletonViewer.
  51136. */
  51137. export interface ISkeletonViewerOptions {
  51138. /** Should the system pause animations before building the Viewer? */
  51139. pauseAnimations: boolean;
  51140. /** Should the system return the skeleton to rest before building? */
  51141. returnToRest: boolean;
  51142. /** public Display Mode of the Viewer */
  51143. displayMode: number;
  51144. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  51145. displayOptions: ISkeletonViewerDisplayOptions;
  51146. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  51147. computeBonesUsingShaders: boolean;
  51148. /** Flag ignore non weighted bones */
  51149. useAllBones: boolean;
  51150. }
  51151. /**
  51152. * Defines how to display the various bone meshes for the viewer.
  51153. */
  51154. export interface ISkeletonViewerDisplayOptions {
  51155. /** How far down to start tapering the bone spurs */
  51156. midStep?: number;
  51157. /** How big is the midStep? */
  51158. midStepFactor?: number;
  51159. /** Base for the Sphere Size */
  51160. sphereBaseSize?: number;
  51161. /** The ratio of the sphere to the longest bone in units */
  51162. sphereScaleUnit?: number;
  51163. /** Ratio for the Sphere Size */
  51164. sphereFactor?: number;
  51165. /** Whether to show local axes or not */
  51166. showLocalAxes?: boolean;
  51167. /** Length of each local axis */
  51168. localAxesSize?: number;
  51169. }
  51170. /**
  51171. * Defines the constructor options for the BoneWeight Shader.
  51172. */
  51173. export interface IBoneWeightShaderOptions {
  51174. /** Skeleton to Map */
  51175. skeleton: Skeleton;
  51176. /** Colors for Uninfluenced bones */
  51177. colorBase?: Color3;
  51178. /** Colors for 0.0-0.25 Weight bones */
  51179. colorZero?: Color3;
  51180. /** Color for 0.25-0.5 Weight Influence */
  51181. colorQuarter?: Color3;
  51182. /** Color for 0.5-0.75 Weight Influence */
  51183. colorHalf?: Color3;
  51184. /** Color for 0.75-1 Weight Influence */
  51185. colorFull?: Color3;
  51186. /** Color for Zero Weight Influence */
  51187. targetBoneIndex?: number;
  51188. }
  51189. /**
  51190. * Simple structure of the gradient steps for the Color Map.
  51191. */
  51192. export interface ISkeletonMapShaderColorMapKnot {
  51193. /** Color of the Knot */
  51194. color: Color3;
  51195. /** Location of the Knot */
  51196. location: number;
  51197. }
  51198. /**
  51199. * Defines the constructor options for the SkeletonMap Shader.
  51200. */
  51201. export interface ISkeletonMapShaderOptions {
  51202. /** Skeleton to Map */
  51203. skeleton: Skeleton;
  51204. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  51205. colorMap?: ISkeletonMapShaderColorMapKnot[];
  51206. }
  51207. }
  51208. declare module BABYLON {
  51209. /**
  51210. * Class containing static functions to help procedurally build meshes
  51211. */
  51212. export class RibbonBuilder {
  51213. /**
  51214. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51215. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51216. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51217. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51218. * * 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
  51219. * * 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
  51220. * * 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
  51221. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51222. * * 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
  51223. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51224. * * 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
  51225. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51226. * * 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
  51227. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51229. * @param name defines the name of the mesh
  51230. * @param options defines the options used to create the mesh
  51231. * @param scene defines the hosting scene
  51232. * @returns the ribbon mesh
  51233. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51234. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51235. */
  51236. static CreateRibbon(name: string, options: {
  51237. pathArray: Vector3[][];
  51238. closeArray?: boolean;
  51239. closePath?: boolean;
  51240. offset?: number;
  51241. updatable?: boolean;
  51242. sideOrientation?: number;
  51243. frontUVs?: Vector4;
  51244. backUVs?: Vector4;
  51245. instance?: Mesh;
  51246. invertUV?: boolean;
  51247. uvs?: Vector2[];
  51248. colors?: Color4[];
  51249. }, scene?: Nullable<Scene>): Mesh;
  51250. }
  51251. }
  51252. declare module BABYLON {
  51253. /**
  51254. * Class containing static functions to help procedurally build meshes
  51255. */
  51256. export class ShapeBuilder {
  51257. /**
  51258. * 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.
  51259. * * 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.
  51260. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51261. * * 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.
  51262. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51263. * * 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
  51264. * * 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
  51265. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51267. * * 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
  51268. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51270. * @param name defines the name of the mesh
  51271. * @param options defines the options used to create the mesh
  51272. * @param scene defines the hosting scene
  51273. * @returns the extruded shape mesh
  51274. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51275. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51276. */
  51277. static ExtrudeShape(name: string, options: {
  51278. shape: Vector3[];
  51279. path: Vector3[];
  51280. scale?: number;
  51281. rotation?: number;
  51282. cap?: number;
  51283. updatable?: boolean;
  51284. sideOrientation?: number;
  51285. frontUVs?: Vector4;
  51286. backUVs?: Vector4;
  51287. instance?: Mesh;
  51288. invertUV?: boolean;
  51289. }, scene?: Nullable<Scene>): Mesh;
  51290. /**
  51291. * Creates an custom extruded shape mesh.
  51292. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51293. * * 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.
  51294. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51295. * * 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
  51296. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51297. * * 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
  51298. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51299. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51300. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51301. * * 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
  51302. * * 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
  51303. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51304. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51305. * * 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
  51306. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51308. * @param name defines the name of the mesh
  51309. * @param options defines the options used to create the mesh
  51310. * @param scene defines the hosting scene
  51311. * @returns the custom extruded shape mesh
  51312. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51313. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51314. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51315. */
  51316. static ExtrudeShapeCustom(name: string, options: {
  51317. shape: Vector3[];
  51318. path: Vector3[];
  51319. scaleFunction?: any;
  51320. rotationFunction?: any;
  51321. ribbonCloseArray?: boolean;
  51322. ribbonClosePath?: boolean;
  51323. cap?: number;
  51324. updatable?: boolean;
  51325. sideOrientation?: number;
  51326. frontUVs?: Vector4;
  51327. backUVs?: Vector4;
  51328. instance?: Mesh;
  51329. invertUV?: boolean;
  51330. }, scene?: Nullable<Scene>): Mesh;
  51331. private static _ExtrudeShapeGeneric;
  51332. }
  51333. }
  51334. declare module BABYLON.Debug {
  51335. /**
  51336. * Class used to render a debug view of a given skeleton
  51337. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51338. */
  51339. export class SkeletonViewer {
  51340. /** defines the skeleton to render */
  51341. skeleton: Skeleton;
  51342. /** defines the mesh attached to the skeleton */
  51343. mesh: AbstractMesh;
  51344. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51345. autoUpdateBonesMatrices: boolean;
  51346. /** defines the rendering group id to use with the viewer */
  51347. renderingGroupId: number;
  51348. /** is the options for the viewer */
  51349. options: Partial<ISkeletonViewerOptions>;
  51350. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  51351. static readonly DISPLAY_LINES: number;
  51352. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  51353. static readonly DISPLAY_SPHERES: number;
  51354. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  51355. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  51356. /** public static method to create a BoneWeight Shader
  51357. * @param options The constructor options
  51358. * @param scene The scene that the shader is scoped to
  51359. * @returns The created ShaderMaterial
  51360. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  51361. */
  51362. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  51363. /** public static method to create a BoneWeight Shader
  51364. * @param options The constructor options
  51365. * @param scene The scene that the shader is scoped to
  51366. * @returns The created ShaderMaterial
  51367. */
  51368. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  51369. /** private static method to create a BoneWeight Shader
  51370. * @param size The size of the buffer to create (usually the bone count)
  51371. * @param colorMap The gradient data to generate
  51372. * @param scene The scene that the shader is scoped to
  51373. * @returns an Array of floats from the color gradient values
  51374. */
  51375. private static _CreateBoneMapColorBuffer;
  51376. /** If SkeletonViewer scene scope. */
  51377. private _scene;
  51378. /** Gets or sets the color used to render the skeleton */
  51379. color: Color3;
  51380. /** Array of the points of the skeleton fo the line view. */
  51381. private _debugLines;
  51382. /** The SkeletonViewers Mesh. */
  51383. private _debugMesh;
  51384. /** The local axes Meshes. */
  51385. private _localAxes;
  51386. /** If SkeletonViewer is enabled. */
  51387. private _isEnabled;
  51388. /** If SkeletonViewer is ready. */
  51389. private _ready;
  51390. /** SkeletonViewer render observable. */
  51391. private _obs;
  51392. /** The Utility Layer to render the gizmos in. */
  51393. private _utilityLayer;
  51394. private _boneIndices;
  51395. /** Gets the Scene. */
  51396. get scene(): Scene;
  51397. /** Gets the utilityLayer. */
  51398. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  51399. /** Checks Ready Status. */
  51400. get isReady(): Boolean;
  51401. /** Sets Ready Status. */
  51402. set ready(value: boolean);
  51403. /** Gets the debugMesh */
  51404. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  51405. /** Sets the debugMesh */
  51406. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  51407. /** Gets the displayMode */
  51408. get displayMode(): number;
  51409. /** Sets the displayMode */
  51410. set displayMode(value: number);
  51411. /**
  51412. * Creates a new SkeletonViewer
  51413. * @param skeleton defines the skeleton to render
  51414. * @param mesh defines the mesh attached to the skeleton
  51415. * @param scene defines the hosting scene
  51416. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51417. * @param renderingGroupId defines the rendering group id to use with the viewer
  51418. * @param options All of the extra constructor options for the SkeletonViewer
  51419. */
  51420. constructor(
  51421. /** defines the skeleton to render */
  51422. skeleton: Skeleton,
  51423. /** defines the mesh attached to the skeleton */
  51424. mesh: AbstractMesh,
  51425. /** The Scene scope*/
  51426. scene: Scene,
  51427. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51428. autoUpdateBonesMatrices?: boolean,
  51429. /** defines the rendering group id to use with the viewer */
  51430. renderingGroupId?: number,
  51431. /** is the options for the viewer */
  51432. options?: Partial<ISkeletonViewerOptions>);
  51433. /** The Dynamic bindings for the update functions */
  51434. private _bindObs;
  51435. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  51436. update(): void;
  51437. /** Gets or sets a boolean indicating if the viewer is enabled */
  51438. set isEnabled(value: boolean);
  51439. get isEnabled(): boolean;
  51440. private _getBonePosition;
  51441. private _getLinesForBonesWithLength;
  51442. private _getLinesForBonesNoLength;
  51443. /** function to revert the mesh and scene back to the initial state. */
  51444. private _revert;
  51445. private getAbsoluteRestPose;
  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. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  51460. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  51461. *
  51462. * @param option String of the option name
  51463. * @param value The numerical option value
  51464. */
  51465. changeDisplayOptions(option: string, value: number): void;
  51466. /** Release associated resources */
  51467. dispose(): void;
  51468. }
  51469. }
  51470. declare module BABYLON {
  51471. /**
  51472. * Enum for Device Types
  51473. */
  51474. export enum DeviceType {
  51475. /** Generic */
  51476. Generic = 0,
  51477. /** Keyboard */
  51478. Keyboard = 1,
  51479. /** Mouse */
  51480. Mouse = 2,
  51481. /** Touch Pointers */
  51482. Touch = 3,
  51483. /** PS4 Dual Shock */
  51484. DualShock = 4,
  51485. /** Xbox */
  51486. Xbox = 5,
  51487. /** Switch Controller */
  51488. Switch = 6
  51489. }
  51490. /**
  51491. * Enum for All Pointers (Touch/Mouse)
  51492. */
  51493. export enum PointerInput {
  51494. /** Horizontal Axis */
  51495. Horizontal = 0,
  51496. /** Vertical Axis */
  51497. Vertical = 1,
  51498. /** Left Click or Touch */
  51499. LeftClick = 2,
  51500. /** Middle Click */
  51501. MiddleClick = 3,
  51502. /** Right Click */
  51503. RightClick = 4,
  51504. /** Browser Back */
  51505. BrowserBack = 5,
  51506. /** Browser Forward */
  51507. BrowserForward = 6
  51508. }
  51509. /**
  51510. * Enum for Dual Shock Gamepad
  51511. */
  51512. export enum DualShockInput {
  51513. /** Cross */
  51514. Cross = 0,
  51515. /** Circle */
  51516. Circle = 1,
  51517. /** Square */
  51518. Square = 2,
  51519. /** Triangle */
  51520. Triangle = 3,
  51521. /** L1 */
  51522. L1 = 4,
  51523. /** R1 */
  51524. R1 = 5,
  51525. /** L2 */
  51526. L2 = 6,
  51527. /** R2 */
  51528. R2 = 7,
  51529. /** Share */
  51530. Share = 8,
  51531. /** Options */
  51532. Options = 9,
  51533. /** L3 */
  51534. L3 = 10,
  51535. /** R3 */
  51536. R3 = 11,
  51537. /** DPadUp */
  51538. DPadUp = 12,
  51539. /** DPadDown */
  51540. DPadDown = 13,
  51541. /** DPadLeft */
  51542. DPadLeft = 14,
  51543. /** DRight */
  51544. DPadRight = 15,
  51545. /** Home */
  51546. Home = 16,
  51547. /** TouchPad */
  51548. TouchPad = 17,
  51549. /** LStickXAxis */
  51550. LStickXAxis = 18,
  51551. /** LStickYAxis */
  51552. LStickYAxis = 19,
  51553. /** RStickXAxis */
  51554. RStickXAxis = 20,
  51555. /** RStickYAxis */
  51556. RStickYAxis = 21
  51557. }
  51558. /**
  51559. * Enum for Xbox Gamepad
  51560. */
  51561. export enum XboxInput {
  51562. /** A */
  51563. A = 0,
  51564. /** B */
  51565. B = 1,
  51566. /** X */
  51567. X = 2,
  51568. /** Y */
  51569. Y = 3,
  51570. /** LB */
  51571. LB = 4,
  51572. /** RB */
  51573. RB = 5,
  51574. /** LT */
  51575. LT = 6,
  51576. /** RT */
  51577. RT = 7,
  51578. /** Back */
  51579. Back = 8,
  51580. /** Start */
  51581. Start = 9,
  51582. /** LS */
  51583. LS = 10,
  51584. /** RS */
  51585. RS = 11,
  51586. /** DPadUp */
  51587. DPadUp = 12,
  51588. /** DPadDown */
  51589. DPadDown = 13,
  51590. /** DPadLeft */
  51591. DPadLeft = 14,
  51592. /** DRight */
  51593. DPadRight = 15,
  51594. /** Home */
  51595. Home = 16,
  51596. /** LStickXAxis */
  51597. LStickXAxis = 17,
  51598. /** LStickYAxis */
  51599. LStickYAxis = 18,
  51600. /** RStickXAxis */
  51601. RStickXAxis = 19,
  51602. /** RStickYAxis */
  51603. RStickYAxis = 20
  51604. }
  51605. /**
  51606. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  51607. */
  51608. export enum SwitchInput {
  51609. /** B */
  51610. B = 0,
  51611. /** A */
  51612. A = 1,
  51613. /** Y */
  51614. Y = 2,
  51615. /** X */
  51616. X = 3,
  51617. /** L */
  51618. L = 4,
  51619. /** R */
  51620. R = 5,
  51621. /** ZL */
  51622. ZL = 6,
  51623. /** ZR */
  51624. ZR = 7,
  51625. /** Minus */
  51626. Minus = 8,
  51627. /** Plus */
  51628. Plus = 9,
  51629. /** LS */
  51630. LS = 10,
  51631. /** RS */
  51632. RS = 11,
  51633. /** DPadUp */
  51634. DPadUp = 12,
  51635. /** DPadDown */
  51636. DPadDown = 13,
  51637. /** DPadLeft */
  51638. DPadLeft = 14,
  51639. /** DRight */
  51640. DPadRight = 15,
  51641. /** Home */
  51642. Home = 16,
  51643. /** Capture */
  51644. Capture = 17,
  51645. /** LStickXAxis */
  51646. LStickXAxis = 18,
  51647. /** LStickYAxis */
  51648. LStickYAxis = 19,
  51649. /** RStickXAxis */
  51650. RStickXAxis = 20,
  51651. /** RStickYAxis */
  51652. RStickYAxis = 21
  51653. }
  51654. }
  51655. declare module BABYLON {
  51656. /**
  51657. * This class will take all inputs from Keyboard, Pointer, and
  51658. * any Gamepads and provide a polling system that all devices
  51659. * will use. This class assumes that there will only be one
  51660. * pointer device and one keyboard.
  51661. */
  51662. export class DeviceInputSystem implements IDisposable {
  51663. /**
  51664. * Callback to be triggered when a device is connected
  51665. */
  51666. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51667. /**
  51668. * Callback to be triggered when a device is disconnected
  51669. */
  51670. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51671. /**
  51672. * Callback to be triggered when event driven input is updated
  51673. */
  51674. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  51675. private _inputs;
  51676. private _gamepads;
  51677. private _keyboardActive;
  51678. private _pointerActive;
  51679. private _elementToAttachTo;
  51680. private _keyboardDownEvent;
  51681. private _keyboardUpEvent;
  51682. private _pointerMoveEvent;
  51683. private _pointerDownEvent;
  51684. private _pointerUpEvent;
  51685. private _gamepadConnectedEvent;
  51686. private _gamepadDisconnectedEvent;
  51687. private static _MAX_KEYCODES;
  51688. private static _MAX_POINTER_INPUTS;
  51689. private constructor();
  51690. /**
  51691. * Creates a new DeviceInputSystem instance
  51692. * @param engine Engine to pull input element from
  51693. * @returns The new instance
  51694. */
  51695. static Create(engine: Engine): DeviceInputSystem;
  51696. /**
  51697. * Checks for current device input value, given an id and input index
  51698. * @param deviceName Id of connected device
  51699. * @param inputIndex Index of device input
  51700. * @returns Current value of input
  51701. */
  51702. /**
  51703. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  51704. * @param deviceType Enum specifiying device type
  51705. * @param deviceSlot "Slot" or index that device is referenced in
  51706. * @param inputIndex Id of input to be checked
  51707. * @returns Current value of input
  51708. */
  51709. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  51710. /**
  51711. * Dispose of all the eventlisteners
  51712. */
  51713. dispose(): void;
  51714. /**
  51715. * Add device and inputs to device array
  51716. * @param deviceType Enum specifiying device type
  51717. * @param deviceSlot "Slot" or index that device is referenced in
  51718. * @param numberOfInputs Number of input entries to create for given device
  51719. */
  51720. private _registerDevice;
  51721. /**
  51722. * Given a specific device name, remove that device from the device map
  51723. * @param deviceType Enum specifiying device type
  51724. * @param deviceSlot "Slot" or index that device is referenced in
  51725. */
  51726. private _unregisterDevice;
  51727. /**
  51728. * Handle all actions that come from keyboard interaction
  51729. */
  51730. private _handleKeyActions;
  51731. /**
  51732. * Handle all actions that come from pointer interaction
  51733. */
  51734. private _handlePointerActions;
  51735. /**
  51736. * Handle all actions that come from gamepad interaction
  51737. */
  51738. private _handleGamepadActions;
  51739. /**
  51740. * Update all non-event based devices with each frame
  51741. * @param deviceType Enum specifiying device type
  51742. * @param deviceSlot "Slot" or index that device is referenced in
  51743. * @param inputIndex Id of input to be checked
  51744. */
  51745. private _updateDevice;
  51746. /**
  51747. * Gets DeviceType from the device name
  51748. * @param deviceName Name of Device from DeviceInputSystem
  51749. * @returns DeviceType enum value
  51750. */
  51751. private _getGamepadDeviceType;
  51752. }
  51753. }
  51754. declare module BABYLON {
  51755. /**
  51756. * Type to handle enforcement of inputs
  51757. */
  51758. 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;
  51759. }
  51760. declare module BABYLON {
  51761. /**
  51762. * Class that handles all input for a specific device
  51763. */
  51764. export class DeviceSource<T extends DeviceType> {
  51765. /** Type of device */
  51766. readonly deviceType: DeviceType;
  51767. /** "Slot" or index that device is referenced in */
  51768. readonly deviceSlot: number;
  51769. /**
  51770. * Observable to handle device input changes per device
  51771. */
  51772. readonly onInputChangedObservable: Observable<{
  51773. inputIndex: DeviceInput<T>;
  51774. previousState: Nullable<number>;
  51775. currentState: Nullable<number>;
  51776. }>;
  51777. private readonly _deviceInputSystem;
  51778. /**
  51779. * Default Constructor
  51780. * @param deviceInputSystem Reference to DeviceInputSystem
  51781. * @param deviceType Type of device
  51782. * @param deviceSlot "Slot" or index that device is referenced in
  51783. */
  51784. constructor(deviceInputSystem: DeviceInputSystem,
  51785. /** Type of device */
  51786. deviceType: DeviceType,
  51787. /** "Slot" or index that device is referenced in */
  51788. deviceSlot?: number);
  51789. /**
  51790. * Get input for specific input
  51791. * @param inputIndex index of specific input on device
  51792. * @returns Input value from DeviceInputSystem
  51793. */
  51794. getInput(inputIndex: DeviceInput<T>): number;
  51795. }
  51796. /**
  51797. * Class to keep track of devices
  51798. */
  51799. export class DeviceSourceManager implements IDisposable {
  51800. /**
  51801. * Observable to be triggered when before a device is connected
  51802. */
  51803. readonly onBeforeDeviceConnectedObservable: Observable<{
  51804. deviceType: DeviceType;
  51805. deviceSlot: number;
  51806. }>;
  51807. /**
  51808. * Observable to be triggered when before a device is disconnected
  51809. */
  51810. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51811. deviceType: DeviceType;
  51812. deviceSlot: number;
  51813. }>;
  51814. /**
  51815. * Observable to be triggered when after a device is connected
  51816. */
  51817. readonly onAfterDeviceConnectedObservable: Observable<{
  51818. deviceType: DeviceType;
  51819. deviceSlot: number;
  51820. }>;
  51821. /**
  51822. * Observable to be triggered when after a device is disconnected
  51823. */
  51824. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51825. deviceType: DeviceType;
  51826. deviceSlot: number;
  51827. }>;
  51828. private readonly _devices;
  51829. private readonly _firstDevice;
  51830. private readonly _deviceInputSystem;
  51831. /**
  51832. * Default Constructor
  51833. * @param engine engine to pull input element from
  51834. */
  51835. constructor(engine: Engine);
  51836. /**
  51837. * Gets a DeviceSource, given a type and slot
  51838. * @param deviceType Enum specifying device type
  51839. * @param deviceSlot "Slot" or index that device is referenced in
  51840. * @returns DeviceSource object
  51841. */
  51842. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51843. /**
  51844. * Gets an array of DeviceSource objects for a given device type
  51845. * @param deviceType Enum specifying device type
  51846. * @returns Array of DeviceSource objects
  51847. */
  51848. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51849. /**
  51850. * Dispose of DeviceInputSystem and other parts
  51851. */
  51852. dispose(): void;
  51853. /**
  51854. * Function to add device name to device list
  51855. * @param deviceType Enum specifying device type
  51856. * @param deviceSlot "Slot" or index that device is referenced in
  51857. */
  51858. private _addDevice;
  51859. /**
  51860. * Function to remove device name to device list
  51861. * @param deviceType Enum specifying device type
  51862. * @param deviceSlot "Slot" or index that device is referenced in
  51863. */
  51864. private _removeDevice;
  51865. /**
  51866. * Updates array storing first connected device of each type
  51867. * @param type Type of Device
  51868. */
  51869. private _updateFirstDevices;
  51870. }
  51871. }
  51872. declare module BABYLON {
  51873. /**
  51874. * Options to create the null engine
  51875. */
  51876. export class NullEngineOptions {
  51877. /**
  51878. * Render width (Default: 512)
  51879. */
  51880. renderWidth: number;
  51881. /**
  51882. * Render height (Default: 256)
  51883. */
  51884. renderHeight: number;
  51885. /**
  51886. * Texture size (Default: 512)
  51887. */
  51888. textureSize: number;
  51889. /**
  51890. * If delta time between frames should be constant
  51891. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51892. */
  51893. deterministicLockstep: boolean;
  51894. /**
  51895. * Maximum about of steps between frames (Default: 4)
  51896. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51897. */
  51898. lockstepMaxSteps: number;
  51899. /**
  51900. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  51901. */
  51902. useHighPrecisionMatrix?: boolean;
  51903. }
  51904. /**
  51905. * The null engine class provides support for headless version of babylon.js.
  51906. * This can be used in server side scenario or for testing purposes
  51907. */
  51908. export class NullEngine extends Engine {
  51909. private _options;
  51910. /**
  51911. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  51912. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51913. * @returns true if engine is in deterministic lock step mode
  51914. */
  51915. isDeterministicLockStep(): boolean;
  51916. /**
  51917. * Gets the max steps when engine is running in deterministic lock step
  51918. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51919. * @returns the max steps
  51920. */
  51921. getLockstepMaxSteps(): number;
  51922. /**
  51923. * Gets the current hardware scaling level.
  51924. * By default the hardware scaling level is computed from the window device ratio.
  51925. * 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.
  51926. * @returns a number indicating the current hardware scaling level
  51927. */
  51928. getHardwareScalingLevel(): number;
  51929. constructor(options?: NullEngineOptions);
  51930. /**
  51931. * Creates a vertex buffer
  51932. * @param vertices the data for the vertex buffer
  51933. * @returns the new WebGL static buffer
  51934. */
  51935. createVertexBuffer(vertices: FloatArray): DataBuffer;
  51936. /**
  51937. * Creates a new index buffer
  51938. * @param indices defines the content of the index buffer
  51939. * @param updatable defines if the index buffer must be updatable
  51940. * @returns a new webGL buffer
  51941. */
  51942. createIndexBuffer(indices: IndicesArray): DataBuffer;
  51943. /**
  51944. * Clear the current render buffer or the current render target (if any is set up)
  51945. * @param color defines the color to use
  51946. * @param backBuffer defines if the back buffer must be cleared
  51947. * @param depth defines if the depth buffer must be cleared
  51948. * @param stencil defines if the stencil buffer must be cleared
  51949. */
  51950. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51951. /**
  51952. * Gets the current render width
  51953. * @param useScreen defines if screen size must be used (or the current render target if any)
  51954. * @returns a number defining the current render width
  51955. */
  51956. getRenderWidth(useScreen?: boolean): number;
  51957. /**
  51958. * Gets the current render height
  51959. * @param useScreen defines if screen size must be used (or the current render target if any)
  51960. * @returns a number defining the current render height
  51961. */
  51962. getRenderHeight(useScreen?: boolean): number;
  51963. /**
  51964. * Set the WebGL's viewport
  51965. * @param viewport defines the viewport element to be used
  51966. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  51967. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  51968. */
  51969. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  51970. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  51971. /**
  51972. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  51973. * @param pipelineContext defines the pipeline context to use
  51974. * @param uniformsNames defines the list of uniform names
  51975. * @returns an array of webGL uniform locations
  51976. */
  51977. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  51978. /**
  51979. * Gets the lsit of active attributes for a given webGL program
  51980. * @param pipelineContext defines the pipeline context to use
  51981. * @param attributesNames defines the list of attribute names to get
  51982. * @returns an array of indices indicating the offset of each attribute
  51983. */
  51984. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51985. /**
  51986. * Binds an effect to the webGL context
  51987. * @param effect defines the effect to bind
  51988. */
  51989. bindSamplers(effect: Effect): void;
  51990. /**
  51991. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  51992. * @param effect defines the effect to activate
  51993. */
  51994. enableEffect(effect: Effect): void;
  51995. /**
  51996. * Set various states to the webGL context
  51997. * @param culling defines backface culling state
  51998. * @param zOffset defines the value to apply to zOffset (0 by default)
  51999. * @param force defines if states must be applied even if cache is up to date
  52000. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  52001. */
  52002. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52003. /**
  52004. * Set the value of an uniform to an array of int32
  52005. * @param uniform defines the webGL uniform location where to store the value
  52006. * @param array defines the array of int32 to store
  52007. * @returns true if value was set
  52008. */
  52009. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  52010. /**
  52011. * Set the value of an uniform to an array of int32 (stored as vec2)
  52012. * @param uniform defines the webGL uniform location where to store the value
  52013. * @param array defines the array of int32 to store
  52014. * @returns true if value was set
  52015. */
  52016. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  52017. /**
  52018. * Set the value of an uniform to an array of int32 (stored as vec3)
  52019. * @param uniform defines the webGL uniform location where to store the value
  52020. * @param array defines the array of int32 to store
  52021. * @returns true if value was set
  52022. */
  52023. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  52024. /**
  52025. * Set the value of an uniform to an array of int32 (stored as vec4)
  52026. * @param uniform defines the webGL uniform location where to store the value
  52027. * @param array defines the array of int32 to store
  52028. * @returns true if value was set
  52029. */
  52030. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  52031. /**
  52032. * Set the value of an uniform to an array of float32
  52033. * @param uniform defines the webGL uniform location where to store the value
  52034. * @param array defines the array of float32 to store
  52035. * @returns true if value was set
  52036. */
  52037. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  52038. /**
  52039. * Set the value of an uniform to an array of float32 (stored as vec2)
  52040. * @param uniform defines the webGL uniform location where to store the value
  52041. * @param array defines the array of float32 to store
  52042. * @returns true if value was set
  52043. */
  52044. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  52045. /**
  52046. * Set the value of an uniform to an array of float32 (stored as vec3)
  52047. * @param uniform defines the webGL uniform location where to store the value
  52048. * @param array defines the array of float32 to store
  52049. * @returns true if value was set
  52050. */
  52051. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  52052. /**
  52053. * Set the value of an uniform to an array of float32 (stored as vec4)
  52054. * @param uniform defines the webGL uniform location where to store the value
  52055. * @param array defines the array of float32 to store
  52056. * @returns true if value was set
  52057. */
  52058. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  52059. /**
  52060. * Set the value of an uniform to an array of number
  52061. * @param uniform defines the webGL uniform location where to store the value
  52062. * @param array defines the array of number to store
  52063. * @returns true if value was set
  52064. */
  52065. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  52066. /**
  52067. * Set the value of an uniform to an array of number (stored as vec2)
  52068. * @param uniform defines the webGL uniform location where to store the value
  52069. * @param array defines the array of number to store
  52070. * @returns true if value was set
  52071. */
  52072. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  52073. /**
  52074. * Set the value of an uniform to an array of number (stored as vec3)
  52075. * @param uniform defines the webGL uniform location where to store the value
  52076. * @param array defines the array of number to store
  52077. * @returns true if value was set
  52078. */
  52079. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  52080. /**
  52081. * Set the value of an uniform to an array of number (stored as vec4)
  52082. * @param uniform defines the webGL uniform location where to store the value
  52083. * @param array defines the array of number to store
  52084. * @returns true if value was set
  52085. */
  52086. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  52087. /**
  52088. * Set the value of an uniform to an array of float32 (stored as matrices)
  52089. * @param uniform defines the webGL uniform location where to store the value
  52090. * @param matrices defines the array of float32 to store
  52091. * @returns true if value was set
  52092. */
  52093. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  52094. /**
  52095. * Set the value of an uniform to a matrix (3x3)
  52096. * @param uniform defines the webGL uniform location where to store the value
  52097. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52098. * @returns true if value was set
  52099. */
  52100. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  52101. /**
  52102. * Set the value of an uniform to a matrix (2x2)
  52103. * @param uniform defines the webGL uniform location where to store the value
  52104. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52105. * @returns true if value was set
  52106. */
  52107. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  52108. /**
  52109. * Set the value of an uniform to a number (float)
  52110. * @param uniform defines the webGL uniform location where to store the value
  52111. * @param value defines the float number to store
  52112. * @returns true if value was set
  52113. */
  52114. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  52115. /**
  52116. * Set the value of an uniform to a vec2
  52117. * @param uniform defines the webGL uniform location where to store the value
  52118. * @param x defines the 1st component of the value
  52119. * @param y defines the 2nd component of the value
  52120. * @returns true if value was set
  52121. */
  52122. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  52123. /**
  52124. * Set the value of an uniform to a vec3
  52125. * @param uniform defines the webGL uniform location where to store the value
  52126. * @param x defines the 1st component of the value
  52127. * @param y defines the 2nd component of the value
  52128. * @param z defines the 3rd component of the value
  52129. * @returns true if value was set
  52130. */
  52131. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  52132. /**
  52133. * Set the value of an uniform to a boolean
  52134. * @param uniform defines the webGL uniform location where to store the value
  52135. * @param bool defines the boolean to store
  52136. * @returns true if value was set
  52137. */
  52138. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  52139. /**
  52140. * Set the value of an uniform to a vec4
  52141. * @param uniform defines the webGL uniform location where to store the value
  52142. * @param x defines the 1st component of the value
  52143. * @param y defines the 2nd component of the value
  52144. * @param z defines the 3rd component of the value
  52145. * @param w defines the 4th component of the value
  52146. * @returns true if value was set
  52147. */
  52148. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  52149. /**
  52150. * Sets the current alpha mode
  52151. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52152. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52153. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52154. */
  52155. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52156. /**
  52157. * Bind webGl buffers directly to the webGL context
  52158. * @param vertexBuffers defines the vertex buffer to bind
  52159. * @param indexBuffer defines the index buffer to bind
  52160. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52161. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52162. * @param effect defines the effect associated with the vertex buffer
  52163. */
  52164. bindBuffers(vertexBuffers: {
  52165. [key: string]: VertexBuffer;
  52166. }, indexBuffer: DataBuffer, effect: Effect): void;
  52167. /**
  52168. * Force the entire cache to be cleared
  52169. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52170. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52171. */
  52172. wipeCaches(bruteForce?: boolean): void;
  52173. /**
  52174. * Send a draw order
  52175. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52176. * @param indexStart defines the starting index
  52177. * @param indexCount defines the number of index to draw
  52178. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52179. */
  52180. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52181. /**
  52182. * Draw a list of indexed primitives
  52183. * @param fillMode defines the primitive to use
  52184. * @param indexStart defines the starting index
  52185. * @param indexCount defines the number of index to draw
  52186. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52187. */
  52188. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52189. /**
  52190. * Draw a list of unindexed primitives
  52191. * @param fillMode defines the primitive to use
  52192. * @param verticesStart defines the index of first vertex to draw
  52193. * @param verticesCount defines the count of vertices to draw
  52194. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52195. */
  52196. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52197. /** @hidden */
  52198. _createTexture(): WebGLTexture;
  52199. /** @hidden */
  52200. _releaseTexture(texture: InternalTexture): void;
  52201. /**
  52202. * Usually called from Texture.ts.
  52203. * Passed information to create a WebGLTexture
  52204. * @param urlArg defines a value which contains one of the following:
  52205. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52206. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52207. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52208. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52209. * @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)
  52210. * @param scene needed for loading to the correct scene
  52211. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52212. * @param onLoad optional callback to be called upon successful completion
  52213. * @param onError optional callback to be called upon failure
  52214. * @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
  52215. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52216. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52217. * @param forcedExtension defines the extension to use to pick the right loader
  52218. * @param mimeType defines an optional mime type
  52219. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52220. */
  52221. 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;
  52222. /**
  52223. * Creates a new render target texture
  52224. * @param size defines the size of the texture
  52225. * @param options defines the options used to create the texture
  52226. * @returns a new render target texture stored in an InternalTexture
  52227. */
  52228. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52229. /**
  52230. * Update the sampling mode of a given texture
  52231. * @param samplingMode defines the required sampling mode
  52232. * @param texture defines the texture to update
  52233. */
  52234. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52235. /**
  52236. * Binds the frame buffer to the specified texture.
  52237. * @param texture The texture to render to or null for the default canvas
  52238. * @param faceIndex The face of the texture to render to in case of cube texture
  52239. * @param requiredWidth The width of the target to render to
  52240. * @param requiredHeight The height of the target to render to
  52241. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52242. * @param lodLevel defines le lod level to bind to the frame buffer
  52243. */
  52244. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52245. /**
  52246. * Unbind the current render target texture from the webGL context
  52247. * @param texture defines the render target texture to unbind
  52248. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52249. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52250. */
  52251. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52252. /**
  52253. * Creates a dynamic vertex buffer
  52254. * @param vertices the data for the dynamic vertex buffer
  52255. * @returns the new WebGL dynamic buffer
  52256. */
  52257. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52258. /**
  52259. * Update the content of a dynamic texture
  52260. * @param texture defines the texture to update
  52261. * @param canvas defines the canvas containing the source
  52262. * @param invertY defines if data must be stored with Y axis inverted
  52263. * @param premulAlpha defines if alpha is stored as premultiplied
  52264. * @param format defines the format of the data
  52265. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52266. */
  52267. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52268. /**
  52269. * Gets a boolean indicating if all created effects are ready
  52270. * @returns true if all effects are ready
  52271. */
  52272. areAllEffectsReady(): boolean;
  52273. /**
  52274. * @hidden
  52275. * Get the current error code of the webGL context
  52276. * @returns the error code
  52277. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52278. */
  52279. getError(): number;
  52280. /** @hidden */
  52281. _getUnpackAlignement(): number;
  52282. /** @hidden */
  52283. _unpackFlipY(value: boolean): void;
  52284. /**
  52285. * Update a dynamic index buffer
  52286. * @param indexBuffer defines the target index buffer
  52287. * @param indices defines the data to update
  52288. * @param offset defines the offset in the target index buffer where update should start
  52289. */
  52290. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52291. /**
  52292. * Updates a dynamic vertex buffer.
  52293. * @param vertexBuffer the vertex buffer to update
  52294. * @param vertices the data used to update the vertex buffer
  52295. * @param byteOffset the byte offset of the data (optional)
  52296. * @param byteLength the byte length of the data (optional)
  52297. */
  52298. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52299. /** @hidden */
  52300. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52301. /** @hidden */
  52302. _bindTexture(channel: number, texture: InternalTexture): void;
  52303. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52304. /**
  52305. * 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
  52306. */
  52307. releaseEffects(): void;
  52308. displayLoadingUI(): void;
  52309. hideLoadingUI(): void;
  52310. /** @hidden */
  52311. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52312. /** @hidden */
  52313. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52314. /** @hidden */
  52315. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52316. /** @hidden */
  52317. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52318. }
  52319. }
  52320. declare module BABYLON {
  52321. /**
  52322. * @hidden
  52323. **/
  52324. export class _TimeToken {
  52325. _startTimeQuery: Nullable<WebGLQuery>;
  52326. _endTimeQuery: Nullable<WebGLQuery>;
  52327. _timeElapsedQuery: Nullable<WebGLQuery>;
  52328. _timeElapsedQueryEnded: boolean;
  52329. }
  52330. }
  52331. declare module BABYLON {
  52332. /** @hidden */
  52333. export class _OcclusionDataStorage {
  52334. /** @hidden */
  52335. occlusionInternalRetryCounter: number;
  52336. /** @hidden */
  52337. isOcclusionQueryInProgress: boolean;
  52338. /** @hidden */
  52339. isOccluded: boolean;
  52340. /** @hidden */
  52341. occlusionRetryCount: number;
  52342. /** @hidden */
  52343. occlusionType: number;
  52344. /** @hidden */
  52345. occlusionQueryAlgorithmType: number;
  52346. }
  52347. interface Engine {
  52348. /**
  52349. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52350. * @return the new query
  52351. */
  52352. createQuery(): WebGLQuery;
  52353. /**
  52354. * Delete and release a webGL query
  52355. * @param query defines the query to delete
  52356. * @return the current engine
  52357. */
  52358. deleteQuery(query: WebGLQuery): Engine;
  52359. /**
  52360. * Check if a given query has resolved and got its value
  52361. * @param query defines the query to check
  52362. * @returns true if the query got its value
  52363. */
  52364. isQueryResultAvailable(query: WebGLQuery): boolean;
  52365. /**
  52366. * Gets the value of a given query
  52367. * @param query defines the query to check
  52368. * @returns the value of the query
  52369. */
  52370. getQueryResult(query: WebGLQuery): number;
  52371. /**
  52372. * Initiates an occlusion query
  52373. * @param algorithmType defines the algorithm to use
  52374. * @param query defines the query to use
  52375. * @returns the current engine
  52376. * @see https://doc.babylonjs.com/features/occlusionquery
  52377. */
  52378. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52379. /**
  52380. * Ends an occlusion query
  52381. * @see https://doc.babylonjs.com/features/occlusionquery
  52382. * @param algorithmType defines the algorithm to use
  52383. * @returns the current engine
  52384. */
  52385. endOcclusionQuery(algorithmType: number): Engine;
  52386. /**
  52387. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52388. * Please note that only one query can be issued at a time
  52389. * @returns a time token used to track the time span
  52390. */
  52391. startTimeQuery(): Nullable<_TimeToken>;
  52392. /**
  52393. * Ends a time query
  52394. * @param token defines the token used to measure the time span
  52395. * @returns the time spent (in ns)
  52396. */
  52397. endTimeQuery(token: _TimeToken): int;
  52398. /** @hidden */
  52399. _currentNonTimestampToken: Nullable<_TimeToken>;
  52400. /** @hidden */
  52401. _createTimeQuery(): WebGLQuery;
  52402. /** @hidden */
  52403. _deleteTimeQuery(query: WebGLQuery): void;
  52404. /** @hidden */
  52405. _getGlAlgorithmType(algorithmType: number): number;
  52406. /** @hidden */
  52407. _getTimeQueryResult(query: WebGLQuery): any;
  52408. /** @hidden */
  52409. _getTimeQueryAvailability(query: WebGLQuery): any;
  52410. }
  52411. interface AbstractMesh {
  52412. /**
  52413. * Backing filed
  52414. * @hidden
  52415. */
  52416. __occlusionDataStorage: _OcclusionDataStorage;
  52417. /**
  52418. * Access property
  52419. * @hidden
  52420. */
  52421. _occlusionDataStorage: _OcclusionDataStorage;
  52422. /**
  52423. * 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.
  52424. * The default value is -1 which means don't break the query and wait till the result
  52425. * @see https://doc.babylonjs.com/features/occlusionquery
  52426. */
  52427. occlusionRetryCount: number;
  52428. /**
  52429. * 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:
  52430. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52431. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52432. * * 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.
  52433. * @see https://doc.babylonjs.com/features/occlusionquery
  52434. */
  52435. occlusionType: number;
  52436. /**
  52437. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52438. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52439. * * 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.
  52440. * @see https://doc.babylonjs.com/features/occlusionquery
  52441. */
  52442. occlusionQueryAlgorithmType: number;
  52443. /**
  52444. * 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
  52445. * @see https://doc.babylonjs.com/features/occlusionquery
  52446. */
  52447. isOccluded: boolean;
  52448. /**
  52449. * Flag to check the progress status of the query
  52450. * @see https://doc.babylonjs.com/features/occlusionquery
  52451. */
  52452. isOcclusionQueryInProgress: boolean;
  52453. }
  52454. }
  52455. declare module BABYLON {
  52456. /** @hidden */
  52457. export var _forceTransformFeedbackToBundle: boolean;
  52458. interface Engine {
  52459. /**
  52460. * Creates a webGL transform feedback object
  52461. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52462. * @returns the webGL transform feedback object
  52463. */
  52464. createTransformFeedback(): WebGLTransformFeedback;
  52465. /**
  52466. * Delete a webGL transform feedback object
  52467. * @param value defines the webGL transform feedback object to delete
  52468. */
  52469. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52470. /**
  52471. * Bind a webGL transform feedback object to the webgl context
  52472. * @param value defines the webGL transform feedback object to bind
  52473. */
  52474. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52475. /**
  52476. * Begins a transform feedback operation
  52477. * @param usePoints defines if points or triangles must be used
  52478. */
  52479. beginTransformFeedback(usePoints: boolean): void;
  52480. /**
  52481. * Ends a transform feedback operation
  52482. */
  52483. endTransformFeedback(): void;
  52484. /**
  52485. * Specify the varyings to use with transform feedback
  52486. * @param program defines the associated webGL program
  52487. * @param value defines the list of strings representing the varying names
  52488. */
  52489. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52490. /**
  52491. * Bind a webGL buffer for a transform feedback operation
  52492. * @param value defines the webGL buffer to bind
  52493. */
  52494. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52495. }
  52496. }
  52497. declare module BABYLON {
  52498. /**
  52499. * Class used to define an additional view for the engine
  52500. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52501. */
  52502. export class EngineView {
  52503. /** Defines the canvas where to render the view */
  52504. target: HTMLCanvasElement;
  52505. /** Defines an optional camera used to render the view (will use active camera else) */
  52506. camera?: Camera;
  52507. }
  52508. interface Engine {
  52509. /**
  52510. * Gets or sets the HTML element to use for attaching events
  52511. */
  52512. inputElement: Nullable<HTMLElement>;
  52513. /**
  52514. * Gets the current engine view
  52515. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52516. */
  52517. activeView: Nullable<EngineView>;
  52518. /** Gets or sets the list of views */
  52519. views: EngineView[];
  52520. /**
  52521. * Register a new child canvas
  52522. * @param canvas defines the canvas to register
  52523. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  52524. * @returns the associated view
  52525. */
  52526. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  52527. /**
  52528. * Remove a registered child canvas
  52529. * @param canvas defines the canvas to remove
  52530. * @returns the current engine
  52531. */
  52532. unRegisterView(canvas: HTMLCanvasElement): Engine;
  52533. }
  52534. }
  52535. declare module BABYLON {
  52536. interface Engine {
  52537. /** @hidden */
  52538. _excludedCompressedTextures: string[];
  52539. /** @hidden */
  52540. _textureFormatInUse: string;
  52541. /**
  52542. * Gets the list of texture formats supported
  52543. */
  52544. readonly texturesSupported: Array<string>;
  52545. /**
  52546. * Gets the texture format in use
  52547. */
  52548. readonly textureFormatInUse: Nullable<string>;
  52549. /**
  52550. * Set the compressed texture extensions or file names to skip.
  52551. *
  52552. * @param skippedFiles defines the list of those texture files you want to skip
  52553. * Example: [".dds", ".env", "myfile.png"]
  52554. */
  52555. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  52556. /**
  52557. * Set the compressed texture format to use, based on the formats you have, and the formats
  52558. * supported by the hardware / browser.
  52559. *
  52560. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  52561. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  52562. * to API arguments needed to compressed textures. This puts the burden on the container
  52563. * generator to house the arcane code for determining these for current & future formats.
  52564. *
  52565. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52566. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52567. *
  52568. * Note: The result of this call is not taken into account when a texture is base64.
  52569. *
  52570. * @param formatsAvailable defines the list of those format families you have created
  52571. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  52572. *
  52573. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  52574. * @returns The extension selected.
  52575. */
  52576. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  52577. }
  52578. }
  52579. declare module BABYLON {
  52580. /**
  52581. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  52582. */
  52583. export interface CubeMapInfo {
  52584. /**
  52585. * The pixel array for the front face.
  52586. * This is stored in format, left to right, up to down format.
  52587. */
  52588. front: Nullable<ArrayBufferView>;
  52589. /**
  52590. * The pixel array for the back face.
  52591. * This is stored in format, left to right, up to down format.
  52592. */
  52593. back: Nullable<ArrayBufferView>;
  52594. /**
  52595. * The pixel array for the left face.
  52596. * This is stored in format, left to right, up to down format.
  52597. */
  52598. left: Nullable<ArrayBufferView>;
  52599. /**
  52600. * The pixel array for the right face.
  52601. * This is stored in format, left to right, up to down format.
  52602. */
  52603. right: Nullable<ArrayBufferView>;
  52604. /**
  52605. * The pixel array for the up face.
  52606. * This is stored in format, left to right, up to down format.
  52607. */
  52608. up: Nullable<ArrayBufferView>;
  52609. /**
  52610. * The pixel array for the down face.
  52611. * This is stored in format, left to right, up to down format.
  52612. */
  52613. down: Nullable<ArrayBufferView>;
  52614. /**
  52615. * The size of the cubemap stored.
  52616. *
  52617. * Each faces will be size * size pixels.
  52618. */
  52619. size: number;
  52620. /**
  52621. * The format of the texture.
  52622. *
  52623. * RGBA, RGB.
  52624. */
  52625. format: number;
  52626. /**
  52627. * The type of the texture data.
  52628. *
  52629. * UNSIGNED_INT, FLOAT.
  52630. */
  52631. type: number;
  52632. /**
  52633. * Specifies whether the texture is in gamma space.
  52634. */
  52635. gammaSpace: boolean;
  52636. }
  52637. /**
  52638. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  52639. */
  52640. export class PanoramaToCubeMapTools {
  52641. private static FACE_LEFT;
  52642. private static FACE_RIGHT;
  52643. private static FACE_FRONT;
  52644. private static FACE_BACK;
  52645. private static FACE_DOWN;
  52646. private static FACE_UP;
  52647. /**
  52648. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  52649. *
  52650. * @param float32Array The source data.
  52651. * @param inputWidth The width of the input panorama.
  52652. * @param inputHeight The height of the input panorama.
  52653. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  52654. * @return The cubemap data
  52655. */
  52656. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  52657. private static CreateCubemapTexture;
  52658. private static CalcProjectionSpherical;
  52659. }
  52660. }
  52661. declare module BABYLON {
  52662. /**
  52663. * Helper class dealing with the extraction of spherical polynomial dataArray
  52664. * from a cube map.
  52665. */
  52666. export class CubeMapToSphericalPolynomialTools {
  52667. private static FileFaces;
  52668. /**
  52669. * Converts a texture to the according Spherical Polynomial data.
  52670. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52671. *
  52672. * @param texture The texture to extract the information from.
  52673. * @return The Spherical Polynomial data.
  52674. */
  52675. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  52676. /**
  52677. * Converts a cubemap to the according Spherical Polynomial data.
  52678. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52679. *
  52680. * @param cubeInfo The Cube map to extract the information from.
  52681. * @return The Spherical Polynomial data.
  52682. */
  52683. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  52684. }
  52685. }
  52686. declare module BABYLON {
  52687. interface BaseTexture {
  52688. /**
  52689. * Get the polynomial representation of the texture data.
  52690. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  52691. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  52692. */
  52693. sphericalPolynomial: Nullable<SphericalPolynomial>;
  52694. }
  52695. }
  52696. declare module BABYLON {
  52697. /** @hidden */
  52698. export var rgbdEncodePixelShader: {
  52699. name: string;
  52700. shader: string;
  52701. };
  52702. }
  52703. declare module BABYLON {
  52704. /** @hidden */
  52705. export var rgbdDecodePixelShader: {
  52706. name: string;
  52707. shader: string;
  52708. };
  52709. }
  52710. declare module BABYLON {
  52711. /**
  52712. * Raw texture data and descriptor sufficient for WebGL texture upload
  52713. */
  52714. export interface EnvironmentTextureInfo {
  52715. /**
  52716. * Version of the environment map
  52717. */
  52718. version: number;
  52719. /**
  52720. * Width of image
  52721. */
  52722. width: number;
  52723. /**
  52724. * Irradiance information stored in the file.
  52725. */
  52726. irradiance: any;
  52727. /**
  52728. * Specular information stored in the file.
  52729. */
  52730. specular: any;
  52731. }
  52732. /**
  52733. * Defines One Image in the file. It requires only the position in the file
  52734. * as well as the length.
  52735. */
  52736. interface BufferImageData {
  52737. /**
  52738. * Length of the image data.
  52739. */
  52740. length: number;
  52741. /**
  52742. * Position of the data from the null terminator delimiting the end of the JSON.
  52743. */
  52744. position: number;
  52745. }
  52746. /**
  52747. * Defines the specular data enclosed in the file.
  52748. * This corresponds to the version 1 of the data.
  52749. */
  52750. export interface EnvironmentTextureSpecularInfoV1 {
  52751. /**
  52752. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  52753. */
  52754. specularDataPosition?: number;
  52755. /**
  52756. * This contains all the images data needed to reconstruct the cubemap.
  52757. */
  52758. mipmaps: Array<BufferImageData>;
  52759. /**
  52760. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  52761. */
  52762. lodGenerationScale: number;
  52763. }
  52764. /**
  52765. * Sets of helpers addressing the serialization and deserialization of environment texture
  52766. * stored in a BabylonJS env file.
  52767. * Those files are usually stored as .env files.
  52768. */
  52769. export class EnvironmentTextureTools {
  52770. /**
  52771. * Magic number identifying the env file.
  52772. */
  52773. private static _MagicBytes;
  52774. /**
  52775. * Gets the environment info from an env file.
  52776. * @param data The array buffer containing the .env bytes.
  52777. * @returns the environment file info (the json header) if successfully parsed.
  52778. */
  52779. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  52780. /**
  52781. * Creates an environment texture from a loaded cube texture.
  52782. * @param texture defines the cube texture to convert in env file
  52783. * @return a promise containing the environment data if succesfull.
  52784. */
  52785. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  52786. /**
  52787. * Creates a JSON representation of the spherical data.
  52788. * @param texture defines the texture containing the polynomials
  52789. * @return the JSON representation of the spherical info
  52790. */
  52791. private static _CreateEnvTextureIrradiance;
  52792. /**
  52793. * Creates the ArrayBufferViews used for initializing environment texture image data.
  52794. * @param data the image data
  52795. * @param info parameters that determine what views will be created for accessing the underlying buffer
  52796. * @return the views described by info providing access to the underlying buffer
  52797. */
  52798. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  52799. /**
  52800. * Uploads the texture info contained in the env file to the GPU.
  52801. * @param texture defines the internal texture to upload to
  52802. * @param data defines the data to load
  52803. * @param info defines the texture info retrieved through the GetEnvInfo method
  52804. * @returns a promise
  52805. */
  52806. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  52807. private static _OnImageReadyAsync;
  52808. /**
  52809. * Uploads the levels of image data to the GPU.
  52810. * @param texture defines the internal texture to upload to
  52811. * @param imageData defines the array buffer views of image data [mipmap][face]
  52812. * @returns a promise
  52813. */
  52814. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  52815. /**
  52816. * Uploads spherical polynomials information to the texture.
  52817. * @param texture defines the texture we are trying to upload the information to
  52818. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  52819. */
  52820. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  52821. /** @hidden */
  52822. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52823. }
  52824. }
  52825. declare module BABYLON {
  52826. /**
  52827. * Class used to inline functions in shader code
  52828. */
  52829. export class ShaderCodeInliner {
  52830. private static readonly _RegexpFindFunctionNameAndType;
  52831. private _sourceCode;
  52832. private _functionDescr;
  52833. private _numMaxIterations;
  52834. /** Gets or sets the token used to mark the functions to inline */
  52835. inlineToken: string;
  52836. /** Gets or sets the debug mode */
  52837. debug: boolean;
  52838. /** Gets the code after the inlining process */
  52839. get code(): string;
  52840. /**
  52841. * Initializes the inliner
  52842. * @param sourceCode shader code source to inline
  52843. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  52844. */
  52845. constructor(sourceCode: string, numMaxIterations?: number);
  52846. /**
  52847. * Start the processing of the shader code
  52848. */
  52849. processCode(): void;
  52850. private _collectFunctions;
  52851. private _processInlining;
  52852. private _extractBetweenMarkers;
  52853. private _skipWhitespaces;
  52854. private _removeComments;
  52855. private _replaceFunctionCallsByCode;
  52856. private _findBackward;
  52857. private _escapeRegExp;
  52858. private _replaceNames;
  52859. }
  52860. }
  52861. declare module BABYLON {
  52862. /**
  52863. * Container for accessors for natively-stored mesh data buffers.
  52864. */
  52865. class NativeDataBuffer extends DataBuffer {
  52866. /**
  52867. * Accessor value used to identify/retrieve a natively-stored index buffer.
  52868. */
  52869. nativeIndexBuffer?: any;
  52870. /**
  52871. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  52872. */
  52873. nativeVertexBuffer?: any;
  52874. }
  52875. /** @hidden */
  52876. class NativeTexture extends InternalTexture {
  52877. getInternalTexture(): InternalTexture;
  52878. getViewCount(): number;
  52879. }
  52880. /** @hidden */
  52881. export class NativeEngine extends Engine {
  52882. private readonly _native;
  52883. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  52884. private readonly INVALID_HANDLE;
  52885. private _boundBuffersVertexArray;
  52886. getHardwareScalingLevel(): number;
  52887. constructor();
  52888. dispose(): void;
  52889. /**
  52890. * Can be used to override the current requestAnimationFrame requester.
  52891. * @hidden
  52892. */
  52893. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  52894. /**
  52895. * Override default engine behavior.
  52896. * @param color
  52897. * @param backBuffer
  52898. * @param depth
  52899. * @param stencil
  52900. */
  52901. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  52902. /**
  52903. * Gets host document
  52904. * @returns the host document object
  52905. */
  52906. getHostDocument(): Nullable<Document>;
  52907. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52908. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  52909. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  52910. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  52911. [key: string]: VertexBuffer;
  52912. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52913. bindBuffers(vertexBuffers: {
  52914. [key: string]: VertexBuffer;
  52915. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52916. recordVertexArrayObject(vertexBuffers: {
  52917. [key: string]: VertexBuffer;
  52918. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  52919. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52920. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52921. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52922. /**
  52923. * Draw a list of indexed primitives
  52924. * @param fillMode defines the primitive to use
  52925. * @param indexStart defines the starting index
  52926. * @param indexCount defines the number of index to draw
  52927. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52928. */
  52929. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52930. /**
  52931. * Draw a list of unindexed primitives
  52932. * @param fillMode defines the primitive to use
  52933. * @param verticesStart defines the index of first vertex to draw
  52934. * @param verticesCount defines the count of vertices to draw
  52935. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52936. */
  52937. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52938. createPipelineContext(): IPipelineContext;
  52939. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  52940. /** @hidden */
  52941. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  52942. /** @hidden */
  52943. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  52944. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52945. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52946. protected _setProgram(program: WebGLProgram): void;
  52947. _releaseEffect(effect: Effect): void;
  52948. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  52949. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  52950. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  52951. bindSamplers(effect: Effect): void;
  52952. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  52953. getRenderWidth(useScreen?: boolean): number;
  52954. getRenderHeight(useScreen?: boolean): number;
  52955. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  52956. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52957. /**
  52958. * Set the z offset to apply to current rendering
  52959. * @param value defines the offset to apply
  52960. */
  52961. setZOffset(value: number): void;
  52962. /**
  52963. * Gets the current value of the zOffset
  52964. * @returns the current zOffset state
  52965. */
  52966. getZOffset(): number;
  52967. /**
  52968. * Enable or disable depth buffering
  52969. * @param enable defines the state to set
  52970. */
  52971. setDepthBuffer(enable: boolean): void;
  52972. /**
  52973. * Gets a boolean indicating if depth writing is enabled
  52974. * @returns the current depth writing state
  52975. */
  52976. getDepthWrite(): boolean;
  52977. /**
  52978. * Enable or disable depth writing
  52979. * @param enable defines the state to set
  52980. */
  52981. setDepthWrite(enable: boolean): void;
  52982. /**
  52983. * Enable or disable color writing
  52984. * @param enable defines the state to set
  52985. */
  52986. setColorWrite(enable: boolean): void;
  52987. /**
  52988. * Gets a boolean indicating if color writing is enabled
  52989. * @returns the current color writing state
  52990. */
  52991. getColorWrite(): boolean;
  52992. /**
  52993. * Sets alpha constants used by some alpha blending modes
  52994. * @param r defines the red component
  52995. * @param g defines the green component
  52996. * @param b defines the blue component
  52997. * @param a defines the alpha component
  52998. */
  52999. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  53000. /**
  53001. * Sets the current alpha mode
  53002. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  53003. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53004. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53005. */
  53006. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53007. /**
  53008. * Gets the current alpha mode
  53009. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53010. * @returns the current alpha mode
  53011. */
  53012. getAlphaMode(): number;
  53013. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  53014. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  53015. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  53016. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  53017. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  53018. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  53019. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  53020. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  53021. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  53022. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  53023. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  53024. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  53025. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  53026. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  53027. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  53028. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  53029. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  53030. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  53031. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  53032. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  53033. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  53034. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  53035. wipeCaches(bruteForce?: boolean): void;
  53036. _createTexture(): WebGLTexture;
  53037. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  53038. /**
  53039. * Usually called from Texture.ts.
  53040. * Passed information to create a WebGLTexture
  53041. * @param url defines a value which contains one of the following:
  53042. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53043. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53044. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53045. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53046. * @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)
  53047. * @param scene needed for loading to the correct scene
  53048. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53049. * @param onLoad optional callback to be called upon successful completion
  53050. * @param onError optional callback to be called upon failure
  53051. * @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
  53052. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53053. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53054. * @param forcedExtension defines the extension to use to pick the right loader
  53055. * @param mimeType defines an optional mime type
  53056. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53057. */
  53058. 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;
  53059. /**
  53060. * Creates a cube texture
  53061. * @param rootUrl defines the url where the files to load is located
  53062. * @param scene defines the current scene
  53063. * @param files defines the list of files to load (1 per face)
  53064. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  53065. * @param onLoad defines an optional callback raised when the texture is loaded
  53066. * @param onError defines an optional callback raised if there is an issue to load the texture
  53067. * @param format defines the format of the data
  53068. * @param forcedExtension defines the extension to use to pick the right loader
  53069. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  53070. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53071. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53072. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  53073. * @returns the cube texture as an InternalTexture
  53074. */
  53075. 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;
  53076. private _getSamplingFilter;
  53077. private static _GetNativeTextureFormat;
  53078. createRenderTargetTexture(size: number | {
  53079. width: number;
  53080. height: number;
  53081. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  53082. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53083. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53084. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53085. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  53086. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  53087. /**
  53088. * Updates a dynamic vertex buffer.
  53089. * @param vertexBuffer the vertex buffer to update
  53090. * @param data the data used to update the vertex buffer
  53091. * @param byteOffset the byte offset of the data (optional)
  53092. * @param byteLength the byte length of the data (optional)
  53093. */
  53094. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  53095. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  53096. private _updateAnisotropicLevel;
  53097. private _getAddressMode;
  53098. /** @hidden */
  53099. _bindTexture(channel: number, texture: InternalTexture): void;
  53100. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  53101. releaseEffects(): void;
  53102. /** @hidden */
  53103. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53104. /** @hidden */
  53105. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53106. /** @hidden */
  53107. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53108. /** @hidden */
  53109. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53110. }
  53111. }
  53112. declare module BABYLON {
  53113. /**
  53114. * Gather the list of clipboard event types as constants.
  53115. */
  53116. export class ClipboardEventTypes {
  53117. /**
  53118. * The clipboard event is fired when a copy command is active (pressed).
  53119. */
  53120. static readonly COPY: number;
  53121. /**
  53122. * The clipboard event is fired when a cut command is active (pressed).
  53123. */
  53124. static readonly CUT: number;
  53125. /**
  53126. * The clipboard event is fired when a paste command is active (pressed).
  53127. */
  53128. static readonly PASTE: number;
  53129. }
  53130. /**
  53131. * This class is used to store clipboard related info for the onClipboardObservable event.
  53132. */
  53133. export class ClipboardInfo {
  53134. /**
  53135. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53136. */
  53137. type: number;
  53138. /**
  53139. * Defines the related dom event
  53140. */
  53141. event: ClipboardEvent;
  53142. /**
  53143. *Creates an instance of ClipboardInfo.
  53144. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  53145. * @param event Defines the related dom event
  53146. */
  53147. constructor(
  53148. /**
  53149. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53150. */
  53151. type: number,
  53152. /**
  53153. * Defines the related dom event
  53154. */
  53155. event: ClipboardEvent);
  53156. /**
  53157. * Get the clipboard event's type from the keycode.
  53158. * @param keyCode Defines the keyCode for the current keyboard event.
  53159. * @return {number}
  53160. */
  53161. static GetTypeFromCharacter(keyCode: number): number;
  53162. }
  53163. }
  53164. declare module BABYLON {
  53165. /**
  53166. * Google Daydream controller
  53167. */
  53168. export class DaydreamController extends WebVRController {
  53169. /**
  53170. * Base Url for the controller model.
  53171. */
  53172. static MODEL_BASE_URL: string;
  53173. /**
  53174. * File name for the controller model.
  53175. */
  53176. static MODEL_FILENAME: string;
  53177. /**
  53178. * Gamepad Id prefix used to identify Daydream Controller.
  53179. */
  53180. static readonly GAMEPAD_ID_PREFIX: string;
  53181. /**
  53182. * Creates a new DaydreamController from a gamepad
  53183. * @param vrGamepad the gamepad that the controller should be created from
  53184. */
  53185. constructor(vrGamepad: any);
  53186. /**
  53187. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53188. * @param scene scene in which to add meshes
  53189. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53190. */
  53191. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53192. /**
  53193. * Called once for each button that changed state since the last frame
  53194. * @param buttonIdx Which button index changed
  53195. * @param state New state of the button
  53196. * @param changes Which properties on the state changed since last frame
  53197. */
  53198. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53199. }
  53200. }
  53201. declare module BABYLON {
  53202. /**
  53203. * Gear VR Controller
  53204. */
  53205. export class GearVRController extends WebVRController {
  53206. /**
  53207. * Base Url for the controller model.
  53208. */
  53209. static MODEL_BASE_URL: string;
  53210. /**
  53211. * File name for the controller model.
  53212. */
  53213. static MODEL_FILENAME: string;
  53214. /**
  53215. * Gamepad Id prefix used to identify this controller.
  53216. */
  53217. static readonly GAMEPAD_ID_PREFIX: string;
  53218. private readonly _buttonIndexToObservableNameMap;
  53219. /**
  53220. * Creates a new GearVRController from a gamepad
  53221. * @param vrGamepad the gamepad that the controller should be created from
  53222. */
  53223. constructor(vrGamepad: any);
  53224. /**
  53225. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53226. * @param scene scene in which to add meshes
  53227. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53228. */
  53229. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53230. /**
  53231. * Called once for each button that changed state since the last frame
  53232. * @param buttonIdx Which button index changed
  53233. * @param state New state of the button
  53234. * @param changes Which properties on the state changed since last frame
  53235. */
  53236. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53237. }
  53238. }
  53239. declare module BABYLON {
  53240. /**
  53241. * Generic Controller
  53242. */
  53243. export class GenericController extends WebVRController {
  53244. /**
  53245. * Base Url for the controller model.
  53246. */
  53247. static readonly MODEL_BASE_URL: string;
  53248. /**
  53249. * File name for the controller model.
  53250. */
  53251. static readonly MODEL_FILENAME: string;
  53252. /**
  53253. * Creates a new GenericController from a gamepad
  53254. * @param vrGamepad the gamepad that the controller should be created from
  53255. */
  53256. constructor(vrGamepad: any);
  53257. /**
  53258. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53259. * @param scene scene in which to add meshes
  53260. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53261. */
  53262. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53263. /**
  53264. * Called once for each button that changed state since the last frame
  53265. * @param buttonIdx Which button index changed
  53266. * @param state New state of the button
  53267. * @param changes Which properties on the state changed since last frame
  53268. */
  53269. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53270. }
  53271. }
  53272. declare module BABYLON {
  53273. /**
  53274. * Oculus Touch Controller
  53275. */
  53276. export class OculusTouchController extends WebVRController {
  53277. /**
  53278. * Base Url for the controller model.
  53279. */
  53280. static MODEL_BASE_URL: string;
  53281. /**
  53282. * File name for the left controller model.
  53283. */
  53284. static MODEL_LEFT_FILENAME: string;
  53285. /**
  53286. * File name for the right controller model.
  53287. */
  53288. static MODEL_RIGHT_FILENAME: string;
  53289. /**
  53290. * Base Url for the Quest controller model.
  53291. */
  53292. static QUEST_MODEL_BASE_URL: string;
  53293. /**
  53294. * @hidden
  53295. * If the controllers are running on a device that needs the updated Quest controller models
  53296. */
  53297. static _IsQuest: boolean;
  53298. /**
  53299. * Fired when the secondary trigger on this controller is modified
  53300. */
  53301. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  53302. /**
  53303. * Fired when the thumb rest on this controller is modified
  53304. */
  53305. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  53306. /**
  53307. * Creates a new OculusTouchController from a gamepad
  53308. * @param vrGamepad the gamepad that the controller should be created from
  53309. */
  53310. constructor(vrGamepad: any);
  53311. /**
  53312. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53313. * @param scene scene in which to add meshes
  53314. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53315. */
  53316. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53317. /**
  53318. * Fired when the A button on this controller is modified
  53319. */
  53320. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53321. /**
  53322. * Fired when the B button on this controller is modified
  53323. */
  53324. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53325. /**
  53326. * Fired when the X button on this controller is modified
  53327. */
  53328. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53329. /**
  53330. * Fired when the Y button on this controller is modified
  53331. */
  53332. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53333. /**
  53334. * Called once for each button that changed state since the last frame
  53335. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  53336. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  53337. * 2) secondary trigger (same)
  53338. * 3) A (right) X (left), touch, pressed = value
  53339. * 4) B / Y
  53340. * 5) thumb rest
  53341. * @param buttonIdx Which button index changed
  53342. * @param state New state of the button
  53343. * @param changes Which properties on the state changed since last frame
  53344. */
  53345. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53346. }
  53347. }
  53348. declare module BABYLON {
  53349. /**
  53350. * Vive Controller
  53351. */
  53352. export class ViveController extends WebVRController {
  53353. /**
  53354. * Base Url for the controller model.
  53355. */
  53356. static MODEL_BASE_URL: string;
  53357. /**
  53358. * File name for the controller model.
  53359. */
  53360. static MODEL_FILENAME: string;
  53361. /**
  53362. * Creates a new ViveController from a gamepad
  53363. * @param vrGamepad the gamepad that the controller should be created from
  53364. */
  53365. constructor(vrGamepad: any);
  53366. /**
  53367. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53368. * @param scene scene in which to add meshes
  53369. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53370. */
  53371. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53372. /**
  53373. * Fired when the left button on this controller is modified
  53374. */
  53375. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53376. /**
  53377. * Fired when the right button on this controller is modified
  53378. */
  53379. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53380. /**
  53381. * Fired when the menu button on this controller is modified
  53382. */
  53383. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53384. /**
  53385. * Called once for each button that changed state since the last frame
  53386. * Vive mapping:
  53387. * 0: touchpad
  53388. * 1: trigger
  53389. * 2: left AND right buttons
  53390. * 3: menu button
  53391. * @param buttonIdx Which button index changed
  53392. * @param state New state of the button
  53393. * @param changes Which properties on the state changed since last frame
  53394. */
  53395. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53396. }
  53397. }
  53398. declare module BABYLON {
  53399. /**
  53400. * Defines the WindowsMotionController object that the state of the windows motion controller
  53401. */
  53402. export class WindowsMotionController extends WebVRController {
  53403. /**
  53404. * The base url used to load the left and right controller models
  53405. */
  53406. static MODEL_BASE_URL: string;
  53407. /**
  53408. * The name of the left controller model file
  53409. */
  53410. static MODEL_LEFT_FILENAME: string;
  53411. /**
  53412. * The name of the right controller model file
  53413. */
  53414. static MODEL_RIGHT_FILENAME: string;
  53415. /**
  53416. * The controller name prefix for this controller type
  53417. */
  53418. static readonly GAMEPAD_ID_PREFIX: string;
  53419. /**
  53420. * The controller id pattern for this controller type
  53421. */
  53422. private static readonly GAMEPAD_ID_PATTERN;
  53423. private _loadedMeshInfo;
  53424. protected readonly _mapping: {
  53425. buttons: string[];
  53426. buttonMeshNames: {
  53427. trigger: string;
  53428. menu: string;
  53429. grip: string;
  53430. thumbstick: string;
  53431. trackpad: string;
  53432. };
  53433. buttonObservableNames: {
  53434. trigger: string;
  53435. menu: string;
  53436. grip: string;
  53437. thumbstick: string;
  53438. trackpad: string;
  53439. };
  53440. axisMeshNames: string[];
  53441. pointingPoseMeshName: string;
  53442. };
  53443. /**
  53444. * Fired when the trackpad on this controller is clicked
  53445. */
  53446. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53447. /**
  53448. * Fired when the trackpad on this controller is modified
  53449. */
  53450. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53451. /**
  53452. * The current x and y values of this controller's trackpad
  53453. */
  53454. trackpad: StickValues;
  53455. /**
  53456. * Creates a new WindowsMotionController from a gamepad
  53457. * @param vrGamepad the gamepad that the controller should be created from
  53458. */
  53459. constructor(vrGamepad: any);
  53460. /**
  53461. * Fired when the trigger on this controller is modified
  53462. */
  53463. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53464. /**
  53465. * Fired when the menu button on this controller is modified
  53466. */
  53467. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53468. /**
  53469. * Fired when the grip button on this controller is modified
  53470. */
  53471. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53472. /**
  53473. * Fired when the thumbstick button on this controller is modified
  53474. */
  53475. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53476. /**
  53477. * Fired when the touchpad button on this controller is modified
  53478. */
  53479. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53480. /**
  53481. * Fired when the touchpad values on this controller are modified
  53482. */
  53483. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  53484. protected _updateTrackpad(): void;
  53485. /**
  53486. * Called once per frame by the engine.
  53487. */
  53488. update(): void;
  53489. /**
  53490. * Called once for each button that changed state since the last frame
  53491. * @param buttonIdx Which button index changed
  53492. * @param state New state of the button
  53493. * @param changes Which properties on the state changed since last frame
  53494. */
  53495. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53496. /**
  53497. * Moves the buttons on the controller mesh based on their current state
  53498. * @param buttonName the name of the button to move
  53499. * @param buttonValue the value of the button which determines the buttons new position
  53500. */
  53501. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  53502. /**
  53503. * Moves the axis on the controller mesh based on its current state
  53504. * @param axis the index of the axis
  53505. * @param axisValue the value of the axis which determines the meshes new position
  53506. * @hidden
  53507. */
  53508. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  53509. /**
  53510. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53511. * @param scene scene in which to add meshes
  53512. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53513. */
  53514. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  53515. /**
  53516. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  53517. * can be transformed by button presses and axes values, based on this._mapping.
  53518. *
  53519. * @param scene scene in which the meshes exist
  53520. * @param meshes list of meshes that make up the controller model to process
  53521. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  53522. */
  53523. private processModel;
  53524. private createMeshInfo;
  53525. /**
  53526. * Gets the ray of the controller in the direction the controller is pointing
  53527. * @param length the length the resulting ray should be
  53528. * @returns a ray in the direction the controller is pointing
  53529. */
  53530. getForwardRay(length?: number): Ray;
  53531. /**
  53532. * Disposes of the controller
  53533. */
  53534. dispose(): void;
  53535. }
  53536. /**
  53537. * This class represents a new windows motion controller in XR.
  53538. */
  53539. export class XRWindowsMotionController extends WindowsMotionController {
  53540. /**
  53541. * Changing the original WIndowsMotionController mapping to fir the new mapping
  53542. */
  53543. protected readonly _mapping: {
  53544. buttons: string[];
  53545. buttonMeshNames: {
  53546. trigger: string;
  53547. menu: string;
  53548. grip: string;
  53549. thumbstick: string;
  53550. trackpad: string;
  53551. };
  53552. buttonObservableNames: {
  53553. trigger: string;
  53554. menu: string;
  53555. grip: string;
  53556. thumbstick: string;
  53557. trackpad: string;
  53558. };
  53559. axisMeshNames: string[];
  53560. pointingPoseMeshName: string;
  53561. };
  53562. /**
  53563. * Construct a new XR-Based windows motion controller
  53564. *
  53565. * @param gamepadInfo the gamepad object from the browser
  53566. */
  53567. constructor(gamepadInfo: any);
  53568. /**
  53569. * holds the thumbstick values (X,Y)
  53570. */
  53571. thumbstickValues: StickValues;
  53572. /**
  53573. * Fired when the thumbstick on this controller is clicked
  53574. */
  53575. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  53576. /**
  53577. * Fired when the thumbstick on this controller is modified
  53578. */
  53579. onThumbstickValuesChangedObservable: Observable<StickValues>;
  53580. /**
  53581. * Fired when the touchpad button on this controller is modified
  53582. */
  53583. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53584. /**
  53585. * Fired when the touchpad values on this controller are modified
  53586. */
  53587. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53588. /**
  53589. * Fired when the thumbstick button on this controller is modified
  53590. * here to prevent breaking changes
  53591. */
  53592. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53593. /**
  53594. * updating the thumbstick(!) and not the trackpad.
  53595. * This is named this way due to the difference between WebVR and XR and to avoid
  53596. * changing the parent class.
  53597. */
  53598. protected _updateTrackpad(): void;
  53599. /**
  53600. * Disposes the class with joy
  53601. */
  53602. dispose(): void;
  53603. }
  53604. }
  53605. declare module BABYLON {
  53606. /**
  53607. * Class containing static functions to help procedurally build meshes
  53608. */
  53609. export class PolyhedronBuilder {
  53610. /**
  53611. * Creates a polyhedron mesh
  53612. * * 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
  53613. * * The parameter `size` (positive float, default 1) sets the polygon size
  53614. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53615. * * 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`
  53616. * * 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
  53617. * * 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)`)
  53618. * * 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
  53619. * * 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
  53620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53621. * * 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
  53622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53623. * @param name defines the name of the mesh
  53624. * @param options defines the options used to create the mesh
  53625. * @param scene defines the hosting scene
  53626. * @returns the polyhedron mesh
  53627. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53628. */
  53629. static CreatePolyhedron(name: string, options: {
  53630. type?: number;
  53631. size?: number;
  53632. sizeX?: number;
  53633. sizeY?: number;
  53634. sizeZ?: number;
  53635. custom?: any;
  53636. faceUV?: Vector4[];
  53637. faceColors?: Color4[];
  53638. flat?: boolean;
  53639. updatable?: boolean;
  53640. sideOrientation?: number;
  53641. frontUVs?: Vector4;
  53642. backUVs?: Vector4;
  53643. }, scene?: Nullable<Scene>): Mesh;
  53644. }
  53645. }
  53646. declare module BABYLON {
  53647. /**
  53648. * Gizmo that enables scaling a mesh along 3 axis
  53649. */
  53650. export class ScaleGizmo extends Gizmo {
  53651. /**
  53652. * Internal gizmo used for interactions on the x axis
  53653. */
  53654. xGizmo: AxisScaleGizmo;
  53655. /**
  53656. * Internal gizmo used for interactions on the y axis
  53657. */
  53658. yGizmo: AxisScaleGizmo;
  53659. /**
  53660. * Internal gizmo used for interactions on the z axis
  53661. */
  53662. zGizmo: AxisScaleGizmo;
  53663. /**
  53664. * Internal gizmo used to scale all axis equally
  53665. */
  53666. uniformScaleGizmo: AxisScaleGizmo;
  53667. private _meshAttached;
  53668. private _nodeAttached;
  53669. private _snapDistance;
  53670. private _uniformScalingMesh;
  53671. private _octahedron;
  53672. private _sensitivity;
  53673. /** Fires an event when any of it's sub gizmos are dragged */
  53674. onDragStartObservable: Observable<unknown>;
  53675. /** Fires an event when any of it's sub gizmos are released from dragging */
  53676. onDragEndObservable: Observable<unknown>;
  53677. get attachedMesh(): Nullable<AbstractMesh>;
  53678. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53679. get attachedNode(): Nullable<Node>;
  53680. set attachedNode(node: Nullable<Node>);
  53681. /**
  53682. * True when the mouse pointer is hovering a gizmo mesh
  53683. */
  53684. get isHovered(): boolean;
  53685. /**
  53686. * Creates a ScaleGizmo
  53687. * @param gizmoLayer The utility layer the gizmo will be added to
  53688. * @param thickness display gizmo axis thickness
  53689. */
  53690. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53691. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53692. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53693. /**
  53694. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53695. */
  53696. set snapDistance(value: number);
  53697. get snapDistance(): number;
  53698. /**
  53699. * Ratio for the scale of the gizmo (Default: 1)
  53700. */
  53701. set scaleRatio(value: number);
  53702. get scaleRatio(): number;
  53703. /**
  53704. * Sensitivity factor for dragging (Default: 1)
  53705. */
  53706. set sensitivity(value: number);
  53707. get sensitivity(): number;
  53708. /**
  53709. * Disposes of the gizmo
  53710. */
  53711. dispose(): void;
  53712. }
  53713. }
  53714. declare module BABYLON {
  53715. /**
  53716. * Single axis scale gizmo
  53717. */
  53718. export class AxisScaleGizmo extends Gizmo {
  53719. /**
  53720. * Drag behavior responsible for the gizmos dragging interactions
  53721. */
  53722. dragBehavior: PointerDragBehavior;
  53723. private _pointerObserver;
  53724. /**
  53725. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53726. */
  53727. snapDistance: number;
  53728. /**
  53729. * Event that fires each time the gizmo snaps to a new location.
  53730. * * snapDistance is the the change in distance
  53731. */
  53732. onSnapObservable: Observable<{
  53733. snapDistance: number;
  53734. }>;
  53735. /**
  53736. * If the scaling operation should be done on all axis (default: false)
  53737. */
  53738. uniformScaling: boolean;
  53739. /**
  53740. * Custom sensitivity value for the drag strength
  53741. */
  53742. sensitivity: number;
  53743. private _isEnabled;
  53744. private _parent;
  53745. private _arrow;
  53746. private _coloredMaterial;
  53747. private _hoverMaterial;
  53748. /**
  53749. * Creates an AxisScaleGizmo
  53750. * @param gizmoLayer The utility layer the gizmo will be added to
  53751. * @param dragAxis The axis which the gizmo will be able to scale on
  53752. * @param color The color of the gizmo
  53753. * @param thickness display gizmo axis thickness
  53754. */
  53755. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  53756. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53757. /**
  53758. * If the gizmo is enabled
  53759. */
  53760. set isEnabled(value: boolean);
  53761. get isEnabled(): boolean;
  53762. /**
  53763. * Disposes of the gizmo
  53764. */
  53765. dispose(): void;
  53766. /**
  53767. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53768. * @param mesh The mesh to replace the default mesh of the gizmo
  53769. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  53770. */
  53771. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  53772. }
  53773. }
  53774. declare module BABYLON {
  53775. /**
  53776. * Bounding box gizmo
  53777. */
  53778. export class BoundingBoxGizmo extends Gizmo {
  53779. private _lineBoundingBox;
  53780. private _rotateSpheresParent;
  53781. private _scaleBoxesParent;
  53782. private _boundingDimensions;
  53783. private _renderObserver;
  53784. private _pointerObserver;
  53785. private _scaleDragSpeed;
  53786. private _tmpQuaternion;
  53787. private _tmpVector;
  53788. private _tmpRotationMatrix;
  53789. /**
  53790. * 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)
  53791. */
  53792. ignoreChildren: boolean;
  53793. /**
  53794. * 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)
  53795. */
  53796. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  53797. /**
  53798. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  53799. */
  53800. rotationSphereSize: number;
  53801. /**
  53802. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  53803. */
  53804. scaleBoxSize: number;
  53805. /**
  53806. * 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)
  53807. */
  53808. fixedDragMeshScreenSize: boolean;
  53809. /**
  53810. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  53811. */
  53812. fixedDragMeshScreenSizeDistanceFactor: number;
  53813. /**
  53814. * Fired when a rotation sphere or scale box is dragged
  53815. */
  53816. onDragStartObservable: Observable<{}>;
  53817. /**
  53818. * Fired when a scale box is dragged
  53819. */
  53820. onScaleBoxDragObservable: Observable<{}>;
  53821. /**
  53822. * Fired when a scale box drag is ended
  53823. */
  53824. onScaleBoxDragEndObservable: Observable<{}>;
  53825. /**
  53826. * Fired when a rotation sphere is dragged
  53827. */
  53828. onRotationSphereDragObservable: Observable<{}>;
  53829. /**
  53830. * Fired when a rotation sphere drag is ended
  53831. */
  53832. onRotationSphereDragEndObservable: Observable<{}>;
  53833. /**
  53834. * 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)
  53835. */
  53836. scalePivot: Nullable<Vector3>;
  53837. /**
  53838. * Mesh used as a pivot to rotate the attached node
  53839. */
  53840. private _anchorMesh;
  53841. private _existingMeshScale;
  53842. private _dragMesh;
  53843. private pointerDragBehavior;
  53844. private coloredMaterial;
  53845. private hoverColoredMaterial;
  53846. /**
  53847. * Sets the color of the bounding box gizmo
  53848. * @param color the color to set
  53849. */
  53850. setColor(color: Color3): void;
  53851. /**
  53852. * Creates an BoundingBoxGizmo
  53853. * @param gizmoLayer The utility layer the gizmo will be added to
  53854. * @param color The color of the gizmo
  53855. */
  53856. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  53857. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  53858. private _selectNode;
  53859. /**
  53860. * Updates the bounding box information for the Gizmo
  53861. */
  53862. updateBoundingBox(): void;
  53863. private _updateRotationSpheres;
  53864. private _updateScaleBoxes;
  53865. /**
  53866. * Enables rotation on the specified axis and disables rotation on the others
  53867. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  53868. */
  53869. setEnabledRotationAxis(axis: string): void;
  53870. /**
  53871. * Enables/disables scaling
  53872. * @param enable if scaling should be enabled
  53873. * @param homogeneousScaling defines if scaling should only be homogeneous
  53874. */
  53875. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  53876. private _updateDummy;
  53877. /**
  53878. * Enables a pointer drag behavior on the bounding box of the gizmo
  53879. */
  53880. enableDragBehavior(): void;
  53881. /**
  53882. * Disposes of the gizmo
  53883. */
  53884. dispose(): void;
  53885. /**
  53886. * 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)
  53887. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  53888. * @returns the bounding box mesh with the passed in mesh as a child
  53889. */
  53890. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  53891. /**
  53892. * CustomMeshes are not supported by this gizmo
  53893. * @param mesh The mesh to replace the default mesh of the gizmo
  53894. */
  53895. setCustomMesh(mesh: Mesh): void;
  53896. }
  53897. }
  53898. declare module BABYLON {
  53899. /**
  53900. * Single plane rotation gizmo
  53901. */
  53902. export class PlaneRotationGizmo extends Gizmo {
  53903. /**
  53904. * Drag behavior responsible for the gizmos dragging interactions
  53905. */
  53906. dragBehavior: PointerDragBehavior;
  53907. private _pointerObserver;
  53908. /**
  53909. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  53910. */
  53911. snapDistance: number;
  53912. /**
  53913. * Event that fires each time the gizmo snaps to a new location.
  53914. * * snapDistance is the the change in distance
  53915. */
  53916. onSnapObservable: Observable<{
  53917. snapDistance: number;
  53918. }>;
  53919. private _isEnabled;
  53920. private _parent;
  53921. /**
  53922. * Creates a PlaneRotationGizmo
  53923. * @param gizmoLayer The utility layer the gizmo will be added to
  53924. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  53925. * @param color The color of the gizmo
  53926. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53927. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53928. * @param thickness display gizmo axis thickness
  53929. */
  53930. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  53931. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53932. /**
  53933. * If the gizmo is enabled
  53934. */
  53935. set isEnabled(value: boolean);
  53936. get isEnabled(): boolean;
  53937. /**
  53938. * Disposes of the gizmo
  53939. */
  53940. dispose(): void;
  53941. }
  53942. }
  53943. declare module BABYLON {
  53944. /**
  53945. * Gizmo that enables rotating a mesh along 3 axis
  53946. */
  53947. export class RotationGizmo extends Gizmo {
  53948. /**
  53949. * Internal gizmo used for interactions on the x axis
  53950. */
  53951. xGizmo: PlaneRotationGizmo;
  53952. /**
  53953. * Internal gizmo used for interactions on the y axis
  53954. */
  53955. yGizmo: PlaneRotationGizmo;
  53956. /**
  53957. * Internal gizmo used for interactions on the z axis
  53958. */
  53959. zGizmo: PlaneRotationGizmo;
  53960. /** Fires an event when any of it's sub gizmos are dragged */
  53961. onDragStartObservable: Observable<unknown>;
  53962. /** Fires an event when any of it's sub gizmos are released from dragging */
  53963. onDragEndObservable: Observable<unknown>;
  53964. private _meshAttached;
  53965. private _nodeAttached;
  53966. get attachedMesh(): Nullable<AbstractMesh>;
  53967. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53968. get attachedNode(): Nullable<Node>;
  53969. set attachedNode(node: Nullable<Node>);
  53970. /**
  53971. * True when the mouse pointer is hovering a gizmo mesh
  53972. */
  53973. get isHovered(): boolean;
  53974. /**
  53975. * Creates a RotationGizmo
  53976. * @param gizmoLayer The utility layer the gizmo will be added to
  53977. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53978. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53979. * @param thickness display gizmo axis thickness
  53980. */
  53981. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  53982. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53983. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53984. /**
  53985. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53986. */
  53987. set snapDistance(value: number);
  53988. get snapDistance(): number;
  53989. /**
  53990. * Ratio for the scale of the gizmo (Default: 1)
  53991. */
  53992. set scaleRatio(value: number);
  53993. get scaleRatio(): number;
  53994. /**
  53995. * Disposes of the gizmo
  53996. */
  53997. dispose(): void;
  53998. /**
  53999. * CustomMeshes are not supported by this gizmo
  54000. * @param mesh The mesh to replace the default mesh of the gizmo
  54001. */
  54002. setCustomMesh(mesh: Mesh): void;
  54003. }
  54004. }
  54005. declare module BABYLON {
  54006. /**
  54007. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  54008. */
  54009. export class GizmoManager implements IDisposable {
  54010. private scene;
  54011. /**
  54012. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54013. */
  54014. gizmos: {
  54015. positionGizmo: Nullable<PositionGizmo>;
  54016. rotationGizmo: Nullable<RotationGizmo>;
  54017. scaleGizmo: Nullable<ScaleGizmo>;
  54018. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54019. };
  54020. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54021. clearGizmoOnEmptyPointerEvent: boolean;
  54022. /** Fires an event when the manager is attached to a mesh */
  54023. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54024. /** Fires an event when the manager is attached to a node */
  54025. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  54026. private _gizmosEnabled;
  54027. private _pointerObserver;
  54028. private _attachedMesh;
  54029. private _attachedNode;
  54030. private _boundingBoxColor;
  54031. private _defaultUtilityLayer;
  54032. private _defaultKeepDepthUtilityLayer;
  54033. private _thickness;
  54034. /**
  54035. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54036. */
  54037. boundingBoxDragBehavior: SixDofDragBehavior;
  54038. /**
  54039. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54040. */
  54041. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54042. /**
  54043. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  54044. */
  54045. attachableNodes: Nullable<Array<Node>>;
  54046. /**
  54047. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  54048. */
  54049. usePointerToAttachGizmos: boolean;
  54050. /**
  54051. * Utility layer that the bounding box gizmo belongs to
  54052. */
  54053. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54054. /**
  54055. * Utility layer that all gizmos besides bounding box belong to
  54056. */
  54057. get utilityLayer(): UtilityLayerRenderer;
  54058. /**
  54059. * True when the mouse pointer is hovering a gizmo mesh
  54060. */
  54061. get isHovered(): boolean;
  54062. /**
  54063. * Instatiates a gizmo manager
  54064. * @param scene the scene to overlay the gizmos on top of
  54065. * @param thickness display gizmo axis thickness
  54066. */
  54067. constructor(scene: Scene, thickness?: number);
  54068. /**
  54069. * Attaches a set of gizmos to the specified mesh
  54070. * @param mesh The mesh the gizmo's should be attached to
  54071. */
  54072. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54073. /**
  54074. * Attaches a set of gizmos to the specified node
  54075. * @param node The node the gizmo's should be attached to
  54076. */
  54077. attachToNode(node: Nullable<Node>): void;
  54078. /**
  54079. * If the position gizmo is enabled
  54080. */
  54081. set positionGizmoEnabled(value: boolean);
  54082. get positionGizmoEnabled(): boolean;
  54083. /**
  54084. * If the rotation gizmo is enabled
  54085. */
  54086. set rotationGizmoEnabled(value: boolean);
  54087. get rotationGizmoEnabled(): boolean;
  54088. /**
  54089. * If the scale gizmo is enabled
  54090. */
  54091. set scaleGizmoEnabled(value: boolean);
  54092. get scaleGizmoEnabled(): boolean;
  54093. /**
  54094. * If the boundingBox gizmo is enabled
  54095. */
  54096. set boundingBoxGizmoEnabled(value: boolean);
  54097. get boundingBoxGizmoEnabled(): boolean;
  54098. /**
  54099. * Disposes of the gizmo manager
  54100. */
  54101. dispose(): void;
  54102. }
  54103. }
  54104. declare module BABYLON {
  54105. /**
  54106. * A directional light is defined by a direction (what a surprise!).
  54107. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  54108. * 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.
  54109. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54110. */
  54111. export class DirectionalLight extends ShadowLight {
  54112. private _shadowFrustumSize;
  54113. /**
  54114. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  54115. */
  54116. get shadowFrustumSize(): number;
  54117. /**
  54118. * Specifies a fix frustum size for the shadow generation.
  54119. */
  54120. set shadowFrustumSize(value: number);
  54121. private _shadowOrthoScale;
  54122. /**
  54123. * Gets the shadow projection scale against the optimal computed one.
  54124. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54125. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54126. */
  54127. get shadowOrthoScale(): number;
  54128. /**
  54129. * Sets the shadow projection scale against the optimal computed one.
  54130. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54131. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54132. */
  54133. set shadowOrthoScale(value: number);
  54134. /**
  54135. * Automatically compute the projection matrix to best fit (including all the casters)
  54136. * on each frame.
  54137. */
  54138. autoUpdateExtends: boolean;
  54139. /**
  54140. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  54141. * on each frame. autoUpdateExtends must be set to true for this to work
  54142. */
  54143. autoCalcShadowZBounds: boolean;
  54144. private _orthoLeft;
  54145. private _orthoRight;
  54146. private _orthoTop;
  54147. private _orthoBottom;
  54148. /**
  54149. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  54150. * The directional light is emitted from everywhere in the given direction.
  54151. * It can cast shadows.
  54152. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54153. * @param name The friendly name of the light
  54154. * @param direction The direction of the light
  54155. * @param scene The scene the light belongs to
  54156. */
  54157. constructor(name: string, direction: Vector3, scene: Scene);
  54158. /**
  54159. * Returns the string "DirectionalLight".
  54160. * @return The class name
  54161. */
  54162. getClassName(): string;
  54163. /**
  54164. * Returns the integer 1.
  54165. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54166. */
  54167. getTypeID(): number;
  54168. /**
  54169. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  54170. * Returns the DirectionalLight Shadow projection matrix.
  54171. */
  54172. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54173. /**
  54174. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  54175. * Returns the DirectionalLight Shadow projection matrix.
  54176. */
  54177. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  54178. /**
  54179. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  54180. * Returns the DirectionalLight Shadow projection matrix.
  54181. */
  54182. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54183. protected _buildUniformLayout(): void;
  54184. /**
  54185. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  54186. * @param effect The effect to update
  54187. * @param lightIndex The index of the light in the effect to update
  54188. * @returns The directional light
  54189. */
  54190. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  54191. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  54192. /**
  54193. * Gets the minZ used for shadow according to both the scene and the light.
  54194. *
  54195. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54196. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54197. * @param activeCamera The camera we are returning the min for
  54198. * @returns the depth min z
  54199. */
  54200. getDepthMinZ(activeCamera: Camera): number;
  54201. /**
  54202. * Gets the maxZ 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 max for
  54207. * @returns the depth max z
  54208. */
  54209. getDepthMaxZ(activeCamera: Camera): number;
  54210. /**
  54211. * Prepares the list of defines specific to the light type.
  54212. * @param defines the list of defines
  54213. * @param lightIndex defines the index of the light for the effect
  54214. */
  54215. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54216. }
  54217. }
  54218. declare module BABYLON {
  54219. /**
  54220. * Class containing static functions to help procedurally build meshes
  54221. */
  54222. export class HemisphereBuilder {
  54223. /**
  54224. * Creates a hemisphere mesh
  54225. * @param name defines the name of the mesh
  54226. * @param options defines the options used to create the mesh
  54227. * @param scene defines the hosting scene
  54228. * @returns the hemisphere mesh
  54229. */
  54230. static CreateHemisphere(name: string, options: {
  54231. segments?: number;
  54232. diameter?: number;
  54233. sideOrientation?: number;
  54234. }, scene: any): Mesh;
  54235. }
  54236. }
  54237. declare module BABYLON {
  54238. /**
  54239. * A spot light is defined by a position, a direction, an angle, and an exponent.
  54240. * These values define a cone of light starting from the position, emitting toward the direction.
  54241. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  54242. * and the exponent defines the speed of the decay of the light with distance (reach).
  54243. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54244. */
  54245. export class SpotLight extends ShadowLight {
  54246. private _angle;
  54247. private _innerAngle;
  54248. private _cosHalfAngle;
  54249. private _lightAngleScale;
  54250. private _lightAngleOffset;
  54251. /**
  54252. * Gets the cone angle of the spot light in Radians.
  54253. */
  54254. get angle(): number;
  54255. /**
  54256. * Sets the cone angle of the spot light in Radians.
  54257. */
  54258. set angle(value: number);
  54259. /**
  54260. * Only used in gltf falloff mode, this defines the angle where
  54261. * the directional falloff will start before cutting at angle which could be seen
  54262. * as outer angle.
  54263. */
  54264. get innerAngle(): number;
  54265. /**
  54266. * Only used in gltf falloff mode, this defines the angle where
  54267. * the directional falloff will start before cutting at angle which could be seen
  54268. * as outer angle.
  54269. */
  54270. set innerAngle(value: number);
  54271. private _shadowAngleScale;
  54272. /**
  54273. * Allows scaling the angle of the light for shadow generation only.
  54274. */
  54275. get shadowAngleScale(): number;
  54276. /**
  54277. * Allows scaling the angle of the light for shadow generation only.
  54278. */
  54279. set shadowAngleScale(value: number);
  54280. /**
  54281. * The light decay speed with the distance from the emission spot.
  54282. */
  54283. exponent: number;
  54284. private _projectionTextureMatrix;
  54285. /**
  54286. * Allows reading the projecton texture
  54287. */
  54288. get projectionTextureMatrix(): Matrix;
  54289. protected _projectionTextureLightNear: number;
  54290. /**
  54291. * Gets the near clip of the Spotlight for texture projection.
  54292. */
  54293. get projectionTextureLightNear(): number;
  54294. /**
  54295. * Sets the near clip of the Spotlight for texture projection.
  54296. */
  54297. set projectionTextureLightNear(value: number);
  54298. protected _projectionTextureLightFar: number;
  54299. /**
  54300. * Gets the far clip of the Spotlight for texture projection.
  54301. */
  54302. get projectionTextureLightFar(): number;
  54303. /**
  54304. * Sets the far clip of the Spotlight for texture projection.
  54305. */
  54306. set projectionTextureLightFar(value: number);
  54307. protected _projectionTextureUpDirection: Vector3;
  54308. /**
  54309. * Gets the Up vector of the Spotlight for texture projection.
  54310. */
  54311. get projectionTextureUpDirection(): Vector3;
  54312. /**
  54313. * Sets the Up vector of the Spotlight for texture projection.
  54314. */
  54315. set projectionTextureUpDirection(value: Vector3);
  54316. private _projectionTexture;
  54317. /**
  54318. * Gets the projection texture of the light.
  54319. */
  54320. get projectionTexture(): Nullable<BaseTexture>;
  54321. /**
  54322. * Sets the projection texture of the light.
  54323. */
  54324. set projectionTexture(value: Nullable<BaseTexture>);
  54325. private _projectionTextureViewLightDirty;
  54326. private _projectionTextureProjectionLightDirty;
  54327. private _projectionTextureDirty;
  54328. private _projectionTextureViewTargetVector;
  54329. private _projectionTextureViewLightMatrix;
  54330. private _projectionTextureProjectionLightMatrix;
  54331. private _projectionTextureScalingMatrix;
  54332. /**
  54333. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  54334. * It can cast shadows.
  54335. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54336. * @param name The light friendly name
  54337. * @param position The position of the spot light in the scene
  54338. * @param direction The direction of the light in the scene
  54339. * @param angle The cone angle of the light in Radians
  54340. * @param exponent The light decay speed with the distance from the emission spot
  54341. * @param scene The scene the lights belongs to
  54342. */
  54343. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  54344. /**
  54345. * Returns the string "SpotLight".
  54346. * @returns the class name
  54347. */
  54348. getClassName(): string;
  54349. /**
  54350. * Returns the integer 2.
  54351. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54352. */
  54353. getTypeID(): number;
  54354. /**
  54355. * Overrides the direction setter to recompute the projection texture view light Matrix.
  54356. */
  54357. protected _setDirection(value: Vector3): void;
  54358. /**
  54359. * Overrides the position setter to recompute the projection texture view light Matrix.
  54360. */
  54361. protected _setPosition(value: Vector3): void;
  54362. /**
  54363. * 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.
  54364. * Returns the SpotLight.
  54365. */
  54366. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54367. protected _computeProjectionTextureViewLightMatrix(): void;
  54368. protected _computeProjectionTextureProjectionLightMatrix(): void;
  54369. /**
  54370. * Main function for light texture projection matrix computing.
  54371. */
  54372. protected _computeProjectionTextureMatrix(): void;
  54373. protected _buildUniformLayout(): void;
  54374. private _computeAngleValues;
  54375. /**
  54376. * Sets the passed Effect "effect" with the Light textures.
  54377. * @param effect The effect to update
  54378. * @param lightIndex The index of the light in the effect to update
  54379. * @returns The light
  54380. */
  54381. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  54382. /**
  54383. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  54384. * @param effect The effect to update
  54385. * @param lightIndex The index of the light in the effect to update
  54386. * @returns The spot light
  54387. */
  54388. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  54389. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54390. /**
  54391. * Disposes the light and the associated resources.
  54392. */
  54393. dispose(): void;
  54394. /**
  54395. * Prepares the list of defines specific to the light type.
  54396. * @param defines the list of defines
  54397. * @param lightIndex defines the index of the light for the effect
  54398. */
  54399. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54400. }
  54401. }
  54402. declare module BABYLON {
  54403. /**
  54404. * Gizmo that enables viewing a light
  54405. */
  54406. export class LightGizmo extends Gizmo {
  54407. private _lightMesh;
  54408. private _material;
  54409. private _cachedPosition;
  54410. private _cachedForward;
  54411. private _attachedMeshParent;
  54412. private _pointerObserver;
  54413. /**
  54414. * Event that fires each time the gizmo is clicked
  54415. */
  54416. onClickedObservable: Observable<Light>;
  54417. /**
  54418. * Creates a LightGizmo
  54419. * @param gizmoLayer The utility layer the gizmo will be added to
  54420. */
  54421. constructor(gizmoLayer?: UtilityLayerRenderer);
  54422. private _light;
  54423. /**
  54424. * The light that the gizmo is attached to
  54425. */
  54426. set light(light: Nullable<Light>);
  54427. get light(): Nullable<Light>;
  54428. /**
  54429. * Gets the material used to render the light gizmo
  54430. */
  54431. get material(): StandardMaterial;
  54432. /**
  54433. * @hidden
  54434. * Updates the gizmo to match the attached mesh's position/rotation
  54435. */
  54436. protected _update(): void;
  54437. private static _Scale;
  54438. /**
  54439. * Creates the lines for a light mesh
  54440. */
  54441. private static _CreateLightLines;
  54442. /**
  54443. * Disposes of the light gizmo
  54444. */
  54445. dispose(): void;
  54446. private static _CreateHemisphericLightMesh;
  54447. private static _CreatePointLightMesh;
  54448. private static _CreateSpotLightMesh;
  54449. private static _CreateDirectionalLightMesh;
  54450. }
  54451. }
  54452. declare module BABYLON {
  54453. /**
  54454. * Gizmo that enables viewing a camera
  54455. */
  54456. export class CameraGizmo extends Gizmo {
  54457. private _cameraMesh;
  54458. private _cameraLinesMesh;
  54459. private _material;
  54460. private _pointerObserver;
  54461. /**
  54462. * Event that fires each time the gizmo is clicked
  54463. */
  54464. onClickedObservable: Observable<Camera>;
  54465. /**
  54466. * Creates a CameraGizmo
  54467. * @param gizmoLayer The utility layer the gizmo will be added to
  54468. */
  54469. constructor(gizmoLayer?: UtilityLayerRenderer);
  54470. private _camera;
  54471. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  54472. get displayFrustum(): boolean;
  54473. set displayFrustum(value: boolean);
  54474. /**
  54475. * The camera that the gizmo is attached to
  54476. */
  54477. set camera(camera: Nullable<Camera>);
  54478. get camera(): Nullable<Camera>;
  54479. /**
  54480. * Gets the material used to render the camera gizmo
  54481. */
  54482. get material(): StandardMaterial;
  54483. /**
  54484. * @hidden
  54485. * Updates the gizmo to match the attached mesh's position/rotation
  54486. */
  54487. protected _update(): void;
  54488. private static _Scale;
  54489. private _invProjection;
  54490. /**
  54491. * Disposes of the camera gizmo
  54492. */
  54493. dispose(): void;
  54494. private static _CreateCameraMesh;
  54495. private static _CreateCameraFrustum;
  54496. }
  54497. }
  54498. declare module BABYLON {
  54499. /** @hidden */
  54500. export var backgroundFragmentDeclaration: {
  54501. name: string;
  54502. shader: string;
  54503. };
  54504. }
  54505. declare module BABYLON {
  54506. /** @hidden */
  54507. export var backgroundUboDeclaration: {
  54508. name: string;
  54509. shader: string;
  54510. };
  54511. }
  54512. declare module BABYLON {
  54513. /** @hidden */
  54514. export var backgroundPixelShader: {
  54515. name: string;
  54516. shader: string;
  54517. };
  54518. }
  54519. declare module BABYLON {
  54520. /** @hidden */
  54521. export var backgroundVertexDeclaration: {
  54522. name: string;
  54523. shader: string;
  54524. };
  54525. }
  54526. declare module BABYLON {
  54527. /** @hidden */
  54528. export var backgroundVertexShader: {
  54529. name: string;
  54530. shader: string;
  54531. };
  54532. }
  54533. declare module BABYLON {
  54534. /**
  54535. * Background material used to create an efficient environement around your scene.
  54536. */
  54537. export class BackgroundMaterial extends PushMaterial {
  54538. /**
  54539. * Standard reflectance value at parallel view angle.
  54540. */
  54541. static StandardReflectance0: number;
  54542. /**
  54543. * Standard reflectance value at grazing angle.
  54544. */
  54545. static StandardReflectance90: number;
  54546. protected _primaryColor: Color3;
  54547. /**
  54548. * Key light Color (multiply against the environement texture)
  54549. */
  54550. primaryColor: Color3;
  54551. protected __perceptualColor: Nullable<Color3>;
  54552. /**
  54553. * Experimental Internal Use Only.
  54554. *
  54555. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  54556. * This acts as a helper to set the primary color to a more "human friendly" value.
  54557. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  54558. * output color as close as possible from the chosen value.
  54559. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  54560. * part of lighting setup.)
  54561. */
  54562. get _perceptualColor(): Nullable<Color3>;
  54563. set _perceptualColor(value: Nullable<Color3>);
  54564. protected _primaryColorShadowLevel: float;
  54565. /**
  54566. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  54567. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  54568. */
  54569. get primaryColorShadowLevel(): float;
  54570. set primaryColorShadowLevel(value: float);
  54571. protected _primaryColorHighlightLevel: float;
  54572. /**
  54573. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  54574. * The primary color is used at the level chosen to define what the white area would look.
  54575. */
  54576. get primaryColorHighlightLevel(): float;
  54577. set primaryColorHighlightLevel(value: float);
  54578. protected _reflectionTexture: Nullable<BaseTexture>;
  54579. /**
  54580. * Reflection Texture used in the material.
  54581. * Should be author in a specific way for the best result (refer to the documentation).
  54582. */
  54583. reflectionTexture: Nullable<BaseTexture>;
  54584. protected _reflectionBlur: float;
  54585. /**
  54586. * Reflection Texture level of blur.
  54587. *
  54588. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  54589. * texture twice.
  54590. */
  54591. reflectionBlur: float;
  54592. protected _diffuseTexture: Nullable<BaseTexture>;
  54593. /**
  54594. * Diffuse Texture used in the material.
  54595. * Should be author in a specific way for the best result (refer to the documentation).
  54596. */
  54597. diffuseTexture: Nullable<BaseTexture>;
  54598. protected _shadowLights: Nullable<IShadowLight[]>;
  54599. /**
  54600. * Specify the list of lights casting shadow on the material.
  54601. * All scene shadow lights will be included if null.
  54602. */
  54603. shadowLights: Nullable<IShadowLight[]>;
  54604. protected _shadowLevel: float;
  54605. /**
  54606. * Helps adjusting the shadow to a softer level if required.
  54607. * 0 means black shadows and 1 means no shadows.
  54608. */
  54609. shadowLevel: float;
  54610. protected _sceneCenter: Vector3;
  54611. /**
  54612. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  54613. * It is usually zero but might be interesting to modify according to your setup.
  54614. */
  54615. sceneCenter: Vector3;
  54616. protected _opacityFresnel: boolean;
  54617. /**
  54618. * This helps specifying that the material is falling off to the sky box at grazing angle.
  54619. * This helps ensuring a nice transition when the camera goes under the ground.
  54620. */
  54621. opacityFresnel: boolean;
  54622. protected _reflectionFresnel: boolean;
  54623. /**
  54624. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  54625. * This helps adding a mirror texture on the ground.
  54626. */
  54627. reflectionFresnel: boolean;
  54628. protected _reflectionFalloffDistance: number;
  54629. /**
  54630. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  54631. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  54632. */
  54633. reflectionFalloffDistance: number;
  54634. protected _reflectionAmount: number;
  54635. /**
  54636. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  54637. */
  54638. reflectionAmount: number;
  54639. protected _reflectionReflectance0: number;
  54640. /**
  54641. * This specifies the weight of the reflection at grazing angle.
  54642. */
  54643. reflectionReflectance0: number;
  54644. protected _reflectionReflectance90: number;
  54645. /**
  54646. * This specifies the weight of the reflection at a perpendicular point of view.
  54647. */
  54648. reflectionReflectance90: number;
  54649. /**
  54650. * Sets the reflection reflectance fresnel values according to the default standard
  54651. * empirically know to work well :-)
  54652. */
  54653. set reflectionStandardFresnelWeight(value: number);
  54654. protected _useRGBColor: boolean;
  54655. /**
  54656. * Helps to directly use the maps channels instead of their level.
  54657. */
  54658. useRGBColor: boolean;
  54659. protected _enableNoise: boolean;
  54660. /**
  54661. * This helps reducing the banding effect that could occur on the background.
  54662. */
  54663. enableNoise: boolean;
  54664. /**
  54665. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54666. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  54667. * Recommended to be keep at 1.0 except for special cases.
  54668. */
  54669. get fovMultiplier(): number;
  54670. set fovMultiplier(value: number);
  54671. private _fovMultiplier;
  54672. /**
  54673. * Enable the FOV adjustment feature controlled by fovMultiplier.
  54674. */
  54675. useEquirectangularFOV: boolean;
  54676. private _maxSimultaneousLights;
  54677. /**
  54678. * Number of Simultaneous lights allowed on the material.
  54679. */
  54680. maxSimultaneousLights: int;
  54681. private _shadowOnly;
  54682. /**
  54683. * Make the material only render shadows
  54684. */
  54685. shadowOnly: boolean;
  54686. /**
  54687. * Default configuration related to image processing available in the Background Material.
  54688. */
  54689. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54690. /**
  54691. * Keep track of the image processing observer to allow dispose and replace.
  54692. */
  54693. private _imageProcessingObserver;
  54694. /**
  54695. * Attaches a new image processing configuration to the PBR Material.
  54696. * @param configuration (if null the scene configuration will be use)
  54697. */
  54698. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54699. /**
  54700. * Gets the image processing configuration used either in this material.
  54701. */
  54702. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  54703. /**
  54704. * Sets the Default image processing configuration used either in the this material.
  54705. *
  54706. * If sets to null, the scene one is in use.
  54707. */
  54708. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  54709. /**
  54710. * Gets wether the color curves effect is enabled.
  54711. */
  54712. get cameraColorCurvesEnabled(): boolean;
  54713. /**
  54714. * Sets wether the color curves effect is enabled.
  54715. */
  54716. set cameraColorCurvesEnabled(value: boolean);
  54717. /**
  54718. * Gets wether the color grading effect is enabled.
  54719. */
  54720. get cameraColorGradingEnabled(): boolean;
  54721. /**
  54722. * Gets wether the color grading effect is enabled.
  54723. */
  54724. set cameraColorGradingEnabled(value: boolean);
  54725. /**
  54726. * Gets wether tonemapping is enabled or not.
  54727. */
  54728. get cameraToneMappingEnabled(): boolean;
  54729. /**
  54730. * Sets wether tonemapping is enabled or not
  54731. */
  54732. set cameraToneMappingEnabled(value: boolean);
  54733. /**
  54734. * The camera exposure used on this material.
  54735. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54736. * This corresponds to a photographic exposure.
  54737. */
  54738. get cameraExposure(): float;
  54739. /**
  54740. * The camera exposure used on this material.
  54741. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54742. * This corresponds to a photographic exposure.
  54743. */
  54744. set cameraExposure(value: float);
  54745. /**
  54746. * Gets The camera contrast used on this material.
  54747. */
  54748. get cameraContrast(): float;
  54749. /**
  54750. * Sets The camera contrast used on this material.
  54751. */
  54752. set cameraContrast(value: float);
  54753. /**
  54754. * Gets the Color Grading 2D Lookup Texture.
  54755. */
  54756. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54757. /**
  54758. * Sets the Color Grading 2D Lookup Texture.
  54759. */
  54760. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54761. /**
  54762. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54763. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54764. * 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;
  54765. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54766. */
  54767. get cameraColorCurves(): Nullable<ColorCurves>;
  54768. /**
  54769. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54770. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54771. * 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;
  54772. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54773. */
  54774. set cameraColorCurves(value: Nullable<ColorCurves>);
  54775. /**
  54776. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  54777. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  54778. */
  54779. switchToBGR: boolean;
  54780. private _renderTargets;
  54781. private _reflectionControls;
  54782. private _white;
  54783. private _primaryShadowColor;
  54784. private _primaryHighlightColor;
  54785. /**
  54786. * Instantiates a Background Material in the given scene
  54787. * @param name The friendly name of the material
  54788. * @param scene The scene to add the material to
  54789. */
  54790. constructor(name: string, scene: Scene);
  54791. /**
  54792. * Gets a boolean indicating that current material needs to register RTT
  54793. */
  54794. get hasRenderTargetTextures(): boolean;
  54795. /**
  54796. * The entire material has been created in order to prevent overdraw.
  54797. * @returns false
  54798. */
  54799. needAlphaTesting(): boolean;
  54800. /**
  54801. * The entire material has been created in order to prevent overdraw.
  54802. * @returns true if blending is enable
  54803. */
  54804. needAlphaBlending(): boolean;
  54805. /**
  54806. * Checks wether the material is ready to be rendered for a given mesh.
  54807. * @param mesh The mesh to render
  54808. * @param subMesh The submesh to check against
  54809. * @param useInstances Specify wether or not the material is used with instances
  54810. * @returns true if all the dependencies are ready (Textures, Effects...)
  54811. */
  54812. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54813. /**
  54814. * Compute the primary color according to the chosen perceptual color.
  54815. */
  54816. private _computePrimaryColorFromPerceptualColor;
  54817. /**
  54818. * Compute the highlights and shadow colors according to their chosen levels.
  54819. */
  54820. private _computePrimaryColors;
  54821. /**
  54822. * Build the uniform buffer used in the material.
  54823. */
  54824. buildUniformLayout(): void;
  54825. /**
  54826. * Unbind the material.
  54827. */
  54828. unbind(): void;
  54829. /**
  54830. * Bind only the world matrix to the material.
  54831. * @param world The world matrix to bind.
  54832. */
  54833. bindOnlyWorldMatrix(world: Matrix): void;
  54834. /**
  54835. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  54836. * @param world The world matrix to bind.
  54837. * @param subMesh The submesh to bind for.
  54838. */
  54839. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54840. /**
  54841. * Checks to see if a texture is used in the material.
  54842. * @param texture - Base texture to use.
  54843. * @returns - Boolean specifying if a texture is used in the material.
  54844. */
  54845. hasTexture(texture: BaseTexture): boolean;
  54846. /**
  54847. * Dispose the material.
  54848. * @param forceDisposeEffect Force disposal of the associated effect.
  54849. * @param forceDisposeTextures Force disposal of the associated textures.
  54850. */
  54851. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54852. /**
  54853. * Clones the material.
  54854. * @param name The cloned name.
  54855. * @returns The cloned material.
  54856. */
  54857. clone(name: string): BackgroundMaterial;
  54858. /**
  54859. * Serializes the current material to its JSON representation.
  54860. * @returns The JSON representation.
  54861. */
  54862. serialize(): any;
  54863. /**
  54864. * Gets the class name of the material
  54865. * @returns "BackgroundMaterial"
  54866. */
  54867. getClassName(): string;
  54868. /**
  54869. * Parse a JSON input to create back a background material.
  54870. * @param source The JSON data to parse
  54871. * @param scene The scene to create the parsed material in
  54872. * @param rootUrl The root url of the assets the material depends upon
  54873. * @returns the instantiated BackgroundMaterial.
  54874. */
  54875. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  54876. }
  54877. }
  54878. declare module BABYLON {
  54879. /**
  54880. * Represents the different options available during the creation of
  54881. * a Environment helper.
  54882. *
  54883. * This can control the default ground, skybox and image processing setup of your scene.
  54884. */
  54885. export interface IEnvironmentHelperOptions {
  54886. /**
  54887. * Specifies whether or not to create a ground.
  54888. * True by default.
  54889. */
  54890. createGround: boolean;
  54891. /**
  54892. * Specifies the ground size.
  54893. * 15 by default.
  54894. */
  54895. groundSize: number;
  54896. /**
  54897. * The texture used on the ground for the main color.
  54898. * Comes from the BabylonJS CDN by default.
  54899. *
  54900. * Remarks: Can be either a texture or a url.
  54901. */
  54902. groundTexture: string | BaseTexture;
  54903. /**
  54904. * The color mixed in the ground texture by default.
  54905. * BabylonJS clearColor by default.
  54906. */
  54907. groundColor: Color3;
  54908. /**
  54909. * Specifies the ground opacity.
  54910. * 1 by default.
  54911. */
  54912. groundOpacity: number;
  54913. /**
  54914. * Enables the ground to receive shadows.
  54915. * True by default.
  54916. */
  54917. enableGroundShadow: boolean;
  54918. /**
  54919. * Helps preventing the shadow to be fully black on the ground.
  54920. * 0.5 by default.
  54921. */
  54922. groundShadowLevel: number;
  54923. /**
  54924. * Creates a mirror texture attach to the ground.
  54925. * false by default.
  54926. */
  54927. enableGroundMirror: boolean;
  54928. /**
  54929. * Specifies the ground mirror size ratio.
  54930. * 0.3 by default as the default kernel is 64.
  54931. */
  54932. groundMirrorSizeRatio: number;
  54933. /**
  54934. * Specifies the ground mirror blur kernel size.
  54935. * 64 by default.
  54936. */
  54937. groundMirrorBlurKernel: number;
  54938. /**
  54939. * Specifies the ground mirror visibility amount.
  54940. * 1 by default
  54941. */
  54942. groundMirrorAmount: number;
  54943. /**
  54944. * Specifies the ground mirror reflectance weight.
  54945. * This uses the standard weight of the background material to setup the fresnel effect
  54946. * of the mirror.
  54947. * 1 by default.
  54948. */
  54949. groundMirrorFresnelWeight: number;
  54950. /**
  54951. * Specifies the ground mirror Falloff distance.
  54952. * This can helps reducing the size of the reflection.
  54953. * 0 by Default.
  54954. */
  54955. groundMirrorFallOffDistance: number;
  54956. /**
  54957. * Specifies the ground mirror texture type.
  54958. * Unsigned Int by Default.
  54959. */
  54960. groundMirrorTextureType: number;
  54961. /**
  54962. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  54963. * the shown objects.
  54964. */
  54965. groundYBias: number;
  54966. /**
  54967. * Specifies whether or not to create a skybox.
  54968. * True by default.
  54969. */
  54970. createSkybox: boolean;
  54971. /**
  54972. * Specifies the skybox size.
  54973. * 20 by default.
  54974. */
  54975. skyboxSize: number;
  54976. /**
  54977. * The texture used on the skybox for the main color.
  54978. * Comes from the BabylonJS CDN by default.
  54979. *
  54980. * Remarks: Can be either a texture or a url.
  54981. */
  54982. skyboxTexture: string | BaseTexture;
  54983. /**
  54984. * The color mixed in the skybox texture by default.
  54985. * BabylonJS clearColor by default.
  54986. */
  54987. skyboxColor: Color3;
  54988. /**
  54989. * The background rotation around the Y axis of the scene.
  54990. * This helps aligning the key lights of your scene with the background.
  54991. * 0 by default.
  54992. */
  54993. backgroundYRotation: number;
  54994. /**
  54995. * Compute automatically the size of the elements to best fit with the scene.
  54996. */
  54997. sizeAuto: boolean;
  54998. /**
  54999. * Default position of the rootMesh if autoSize is not true.
  55000. */
  55001. rootPosition: Vector3;
  55002. /**
  55003. * Sets up the image processing in the scene.
  55004. * true by default.
  55005. */
  55006. setupImageProcessing: boolean;
  55007. /**
  55008. * The texture used as your environment texture in the scene.
  55009. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  55010. *
  55011. * Remarks: Can be either a texture or a url.
  55012. */
  55013. environmentTexture: string | BaseTexture;
  55014. /**
  55015. * The value of the exposure to apply to the scene.
  55016. * 0.6 by default if setupImageProcessing is true.
  55017. */
  55018. cameraExposure: number;
  55019. /**
  55020. * The value of the contrast to apply to the scene.
  55021. * 1.6 by default if setupImageProcessing is true.
  55022. */
  55023. cameraContrast: number;
  55024. /**
  55025. * Specifies whether or not tonemapping should be enabled in the scene.
  55026. * true by default if setupImageProcessing is true.
  55027. */
  55028. toneMappingEnabled: boolean;
  55029. }
  55030. /**
  55031. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  55032. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  55033. * It also helps with the default setup of your imageProcessing configuration.
  55034. */
  55035. export class EnvironmentHelper {
  55036. /**
  55037. * Default ground texture URL.
  55038. */
  55039. private static _groundTextureCDNUrl;
  55040. /**
  55041. * Default skybox texture URL.
  55042. */
  55043. private static _skyboxTextureCDNUrl;
  55044. /**
  55045. * Default environment texture URL.
  55046. */
  55047. private static _environmentTextureCDNUrl;
  55048. /**
  55049. * Creates the default options for the helper.
  55050. */
  55051. private static _getDefaultOptions;
  55052. private _rootMesh;
  55053. /**
  55054. * Gets the root mesh created by the helper.
  55055. */
  55056. get rootMesh(): Mesh;
  55057. private _skybox;
  55058. /**
  55059. * Gets the skybox created by the helper.
  55060. */
  55061. get skybox(): Nullable<Mesh>;
  55062. private _skyboxTexture;
  55063. /**
  55064. * Gets the skybox texture created by the helper.
  55065. */
  55066. get skyboxTexture(): Nullable<BaseTexture>;
  55067. private _skyboxMaterial;
  55068. /**
  55069. * Gets the skybox material created by the helper.
  55070. */
  55071. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  55072. private _ground;
  55073. /**
  55074. * Gets the ground mesh created by the helper.
  55075. */
  55076. get ground(): Nullable<Mesh>;
  55077. private _groundTexture;
  55078. /**
  55079. * Gets the ground texture created by the helper.
  55080. */
  55081. get groundTexture(): Nullable<BaseTexture>;
  55082. private _groundMirror;
  55083. /**
  55084. * Gets the ground mirror created by the helper.
  55085. */
  55086. get groundMirror(): Nullable<MirrorTexture>;
  55087. /**
  55088. * Gets the ground mirror render list to helps pushing the meshes
  55089. * you wish in the ground reflection.
  55090. */
  55091. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  55092. private _groundMaterial;
  55093. /**
  55094. * Gets the ground material created by the helper.
  55095. */
  55096. get groundMaterial(): Nullable<BackgroundMaterial>;
  55097. /**
  55098. * Stores the creation options.
  55099. */
  55100. private readonly _scene;
  55101. private _options;
  55102. /**
  55103. * This observable will be notified with any error during the creation of the environment,
  55104. * mainly texture creation errors.
  55105. */
  55106. onErrorObservable: Observable<{
  55107. message?: string;
  55108. exception?: any;
  55109. }>;
  55110. /**
  55111. * constructor
  55112. * @param options Defines the options we want to customize the helper
  55113. * @param scene The scene to add the material to
  55114. */
  55115. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  55116. /**
  55117. * Updates the background according to the new options
  55118. * @param options
  55119. */
  55120. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  55121. /**
  55122. * Sets the primary color of all the available elements.
  55123. * @param color the main color to affect to the ground and the background
  55124. */
  55125. setMainColor(color: Color3): void;
  55126. /**
  55127. * Setup the image processing according to the specified options.
  55128. */
  55129. private _setupImageProcessing;
  55130. /**
  55131. * Setup the environment texture according to the specified options.
  55132. */
  55133. private _setupEnvironmentTexture;
  55134. /**
  55135. * Setup the background according to the specified options.
  55136. */
  55137. private _setupBackground;
  55138. /**
  55139. * Get the scene sizes according to the setup.
  55140. */
  55141. private _getSceneSize;
  55142. /**
  55143. * Setup the ground according to the specified options.
  55144. */
  55145. private _setupGround;
  55146. /**
  55147. * Setup the ground material according to the specified options.
  55148. */
  55149. private _setupGroundMaterial;
  55150. /**
  55151. * Setup the ground diffuse texture according to the specified options.
  55152. */
  55153. private _setupGroundDiffuseTexture;
  55154. /**
  55155. * Setup the ground mirror texture according to the specified options.
  55156. */
  55157. private _setupGroundMirrorTexture;
  55158. /**
  55159. * Setup the ground to receive the mirror texture.
  55160. */
  55161. private _setupMirrorInGroundMaterial;
  55162. /**
  55163. * Setup the skybox according to the specified options.
  55164. */
  55165. private _setupSkybox;
  55166. /**
  55167. * Setup the skybox material according to the specified options.
  55168. */
  55169. private _setupSkyboxMaterial;
  55170. /**
  55171. * Setup the skybox reflection texture according to the specified options.
  55172. */
  55173. private _setupSkyboxReflectionTexture;
  55174. private _errorHandler;
  55175. /**
  55176. * Dispose all the elements created by the Helper.
  55177. */
  55178. dispose(): void;
  55179. }
  55180. }
  55181. declare module BABYLON {
  55182. /**
  55183. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  55184. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  55185. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55186. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55187. */
  55188. export abstract class TextureDome<T extends Texture> extends TransformNode {
  55189. protected onError: Nullable<(message?: string, exception?: any) => void>;
  55190. /**
  55191. * Define the source as a Monoscopic panoramic 360/180.
  55192. */
  55193. static readonly MODE_MONOSCOPIC: number;
  55194. /**
  55195. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  55196. */
  55197. static readonly MODE_TOPBOTTOM: number;
  55198. /**
  55199. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  55200. */
  55201. static readonly MODE_SIDEBYSIDE: number;
  55202. private _halfDome;
  55203. protected _useDirectMapping: boolean;
  55204. /**
  55205. * The texture being displayed on the sphere
  55206. */
  55207. protected _texture: T;
  55208. /**
  55209. * Gets the texture being displayed on the sphere
  55210. */
  55211. get texture(): T;
  55212. /**
  55213. * Sets the texture being displayed on the sphere
  55214. */
  55215. set texture(newTexture: T);
  55216. /**
  55217. * The skybox material
  55218. */
  55219. protected _material: BackgroundMaterial;
  55220. /**
  55221. * The surface used for the dome
  55222. */
  55223. protected _mesh: Mesh;
  55224. /**
  55225. * Gets the mesh used for the dome.
  55226. */
  55227. get mesh(): Mesh;
  55228. /**
  55229. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  55230. */
  55231. private _halfDomeMask;
  55232. /**
  55233. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55234. * Also see the options.resolution property.
  55235. */
  55236. get fovMultiplier(): number;
  55237. set fovMultiplier(value: number);
  55238. protected _textureMode: number;
  55239. /**
  55240. * Gets or set the current texture mode for the texture. It can be:
  55241. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55242. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55243. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55244. */
  55245. get textureMode(): number;
  55246. /**
  55247. * Sets the current texture mode for the texture. It can be:
  55248. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55249. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55250. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55251. */
  55252. set textureMode(value: number);
  55253. /**
  55254. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  55255. */
  55256. get halfDome(): boolean;
  55257. /**
  55258. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55259. */
  55260. set halfDome(enabled: boolean);
  55261. /**
  55262. * Oberserver used in Stereoscopic VR Mode.
  55263. */
  55264. private _onBeforeCameraRenderObserver;
  55265. /**
  55266. * Observable raised when an error occured while loading the 360 image
  55267. */
  55268. onLoadErrorObservable: Observable<string>;
  55269. /**
  55270. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  55271. * @param name Element's name, child elements will append suffixes for their own names.
  55272. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  55273. * @param options An object containing optional or exposed sub element properties
  55274. */
  55275. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  55276. resolution?: number;
  55277. clickToPlay?: boolean;
  55278. autoPlay?: boolean;
  55279. loop?: boolean;
  55280. size?: number;
  55281. poster?: string;
  55282. faceForward?: boolean;
  55283. useDirectMapping?: boolean;
  55284. halfDomeMode?: boolean;
  55285. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  55286. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  55287. protected _changeTextureMode(value: number): void;
  55288. /**
  55289. * Releases resources associated with this node.
  55290. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55291. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55292. */
  55293. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55294. }
  55295. }
  55296. declare module BABYLON {
  55297. /**
  55298. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  55299. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  55300. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55301. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55302. */
  55303. export class PhotoDome extends TextureDome<Texture> {
  55304. /**
  55305. * Define the image as a Monoscopic panoramic 360 image.
  55306. */
  55307. static readonly MODE_MONOSCOPIC: number;
  55308. /**
  55309. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55310. */
  55311. static readonly MODE_TOPBOTTOM: number;
  55312. /**
  55313. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55314. */
  55315. static readonly MODE_SIDEBYSIDE: number;
  55316. /**
  55317. * Gets or sets the texture being displayed on the sphere
  55318. */
  55319. get photoTexture(): Texture;
  55320. /**
  55321. * sets the texture being displayed on the sphere
  55322. */
  55323. set photoTexture(value: Texture);
  55324. /**
  55325. * Gets the current video mode for the video. It can be:
  55326. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55327. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55328. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55329. */
  55330. get imageMode(): number;
  55331. /**
  55332. * Sets the current video mode for the video. It can be:
  55333. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55334. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55335. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55336. */
  55337. set imageMode(value: number);
  55338. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  55339. }
  55340. }
  55341. declare module BABYLON {
  55342. /**
  55343. * Class used to host RGBD texture specific utilities
  55344. */
  55345. export class RGBDTextureTools {
  55346. /**
  55347. * Expand the RGBD Texture from RGBD to Half Float if possible.
  55348. * @param texture the texture to expand.
  55349. */
  55350. static ExpandRGBDTexture(texture: Texture): void;
  55351. }
  55352. }
  55353. declare module BABYLON {
  55354. /**
  55355. * Class used to host texture specific utilities
  55356. */
  55357. export class BRDFTextureTools {
  55358. /**
  55359. * Prevents texture cache collision
  55360. */
  55361. private static _instanceNumber;
  55362. /**
  55363. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  55364. * @param scene defines the hosting scene
  55365. * @returns the environment BRDF texture
  55366. */
  55367. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  55368. private static _environmentBRDFBase64Texture;
  55369. }
  55370. }
  55371. declare module BABYLON {
  55372. /**
  55373. * @hidden
  55374. */
  55375. export interface IMaterialClearCoatDefines {
  55376. CLEARCOAT: boolean;
  55377. CLEARCOAT_DEFAULTIOR: boolean;
  55378. CLEARCOAT_TEXTURE: boolean;
  55379. CLEARCOAT_TEXTUREDIRECTUV: number;
  55380. CLEARCOAT_BUMP: boolean;
  55381. CLEARCOAT_BUMPDIRECTUV: number;
  55382. CLEARCOAT_TINT: boolean;
  55383. CLEARCOAT_TINT_TEXTURE: boolean;
  55384. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55385. /** @hidden */
  55386. _areTexturesDirty: boolean;
  55387. }
  55388. /**
  55389. * Define the code related to the clear coat parameters of the pbr material.
  55390. */
  55391. export class PBRClearCoatConfiguration {
  55392. /**
  55393. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55394. * The default fits with a polyurethane material.
  55395. */
  55396. private static readonly _DefaultIndexOfRefraction;
  55397. private _isEnabled;
  55398. /**
  55399. * Defines if the clear coat is enabled in the material.
  55400. */
  55401. isEnabled: boolean;
  55402. /**
  55403. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  55404. */
  55405. intensity: number;
  55406. /**
  55407. * Defines the clear coat layer roughness.
  55408. */
  55409. roughness: number;
  55410. private _indexOfRefraction;
  55411. /**
  55412. * Defines the index of refraction of the clear coat.
  55413. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55414. * The default fits with a polyurethane material.
  55415. * Changing the default value is more performance intensive.
  55416. */
  55417. indexOfRefraction: number;
  55418. private _texture;
  55419. /**
  55420. * Stores the clear coat values in a texture.
  55421. */
  55422. texture: Nullable<BaseTexture>;
  55423. private _bumpTexture;
  55424. /**
  55425. * Define the clear coat specific bump texture.
  55426. */
  55427. bumpTexture: Nullable<BaseTexture>;
  55428. private _isTintEnabled;
  55429. /**
  55430. * Defines if the clear coat tint is enabled in the material.
  55431. */
  55432. isTintEnabled: boolean;
  55433. /**
  55434. * Defines the clear coat tint of the material.
  55435. * This is only use if tint is enabled
  55436. */
  55437. tintColor: Color3;
  55438. /**
  55439. * Defines the distance at which the tint color should be found in the
  55440. * clear coat media.
  55441. * This is only use if tint is enabled
  55442. */
  55443. tintColorAtDistance: number;
  55444. /**
  55445. * Defines the clear coat layer thickness.
  55446. * This is only use if tint is enabled
  55447. */
  55448. tintThickness: number;
  55449. private _tintTexture;
  55450. /**
  55451. * Stores the clear tint values in a texture.
  55452. * rgb is tint
  55453. * a is a thickness factor
  55454. */
  55455. tintTexture: Nullable<BaseTexture>;
  55456. /** @hidden */
  55457. private _internalMarkAllSubMeshesAsTexturesDirty;
  55458. /** @hidden */
  55459. _markAllSubMeshesAsTexturesDirty(): void;
  55460. /**
  55461. * Instantiate a new istance of clear coat configuration.
  55462. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55463. */
  55464. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55465. /**
  55466. * Gets wehter the submesh is ready to be used or not.
  55467. * @param defines the list of "defines" to update.
  55468. * @param scene defines the scene the material belongs to.
  55469. * @param engine defines the engine the material belongs to.
  55470. * @param disableBumpMap defines wether the material disables bump or not.
  55471. * @returns - boolean indicating that the submesh is ready or not.
  55472. */
  55473. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  55474. /**
  55475. * Checks to see if a texture is used in the material.
  55476. * @param defines the list of "defines" to update.
  55477. * @param scene defines the scene to the material belongs to.
  55478. */
  55479. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  55480. /**
  55481. * Binds the material data.
  55482. * @param uniformBuffer defines the Uniform buffer to fill in.
  55483. * @param scene defines the scene the material belongs to.
  55484. * @param engine defines the engine the material belongs to.
  55485. * @param disableBumpMap defines wether the material disables bump or not.
  55486. * @param isFrozen defines wether the material is frozen or not.
  55487. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55488. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55489. */
  55490. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  55491. /**
  55492. * Checks to see if a texture is used in the material.
  55493. * @param texture - Base texture to use.
  55494. * @returns - Boolean specifying if a texture is used in the material.
  55495. */
  55496. hasTexture(texture: BaseTexture): boolean;
  55497. /**
  55498. * Returns an array of the actively used textures.
  55499. * @param activeTextures Array of BaseTextures
  55500. */
  55501. getActiveTextures(activeTextures: BaseTexture[]): void;
  55502. /**
  55503. * Returns the animatable textures.
  55504. * @param animatables Array of animatable textures.
  55505. */
  55506. getAnimatables(animatables: IAnimatable[]): void;
  55507. /**
  55508. * Disposes the resources of the material.
  55509. * @param forceDisposeTextures - Forces the disposal of all textures.
  55510. */
  55511. dispose(forceDisposeTextures?: boolean): void;
  55512. /**
  55513. * Get the current class name of the texture useful for serialization or dynamic coding.
  55514. * @returns "PBRClearCoatConfiguration"
  55515. */
  55516. getClassName(): string;
  55517. /**
  55518. * Add fallbacks to the effect fallbacks list.
  55519. * @param defines defines the Base texture to use.
  55520. * @param fallbacks defines the current fallback list.
  55521. * @param currentRank defines the current fallback rank.
  55522. * @returns the new fallback rank.
  55523. */
  55524. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55525. /**
  55526. * Add the required uniforms to the current list.
  55527. * @param uniforms defines the current uniform list.
  55528. */
  55529. static AddUniforms(uniforms: string[]): void;
  55530. /**
  55531. * Add the required samplers to the current list.
  55532. * @param samplers defines the current sampler list.
  55533. */
  55534. static AddSamplers(samplers: string[]): void;
  55535. /**
  55536. * Add the required uniforms to the current buffer.
  55537. * @param uniformBuffer defines the current uniform buffer.
  55538. */
  55539. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55540. /**
  55541. * Makes a duplicate of the current configuration into another one.
  55542. * @param clearCoatConfiguration define the config where to copy the info
  55543. */
  55544. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  55545. /**
  55546. * Serializes this clear coat configuration.
  55547. * @returns - An object with the serialized config.
  55548. */
  55549. serialize(): any;
  55550. /**
  55551. * Parses a anisotropy Configuration from a serialized object.
  55552. * @param source - Serialized object.
  55553. * @param scene Defines the scene we are parsing for
  55554. * @param rootUrl Defines the rootUrl to load from
  55555. */
  55556. parse(source: any, scene: Scene, rootUrl: string): void;
  55557. }
  55558. }
  55559. declare module BABYLON {
  55560. /**
  55561. * @hidden
  55562. */
  55563. export interface IMaterialAnisotropicDefines {
  55564. ANISOTROPIC: boolean;
  55565. ANISOTROPIC_TEXTURE: boolean;
  55566. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55567. MAINUV1: boolean;
  55568. _areTexturesDirty: boolean;
  55569. _needUVs: boolean;
  55570. }
  55571. /**
  55572. * Define the code related to the anisotropic parameters of the pbr material.
  55573. */
  55574. export class PBRAnisotropicConfiguration {
  55575. private _isEnabled;
  55576. /**
  55577. * Defines if the anisotropy is enabled in the material.
  55578. */
  55579. isEnabled: boolean;
  55580. /**
  55581. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  55582. */
  55583. intensity: number;
  55584. /**
  55585. * Defines if the effect is along the tangents, bitangents or in between.
  55586. * By default, the effect is "strectching" the highlights along the tangents.
  55587. */
  55588. direction: Vector2;
  55589. private _texture;
  55590. /**
  55591. * Stores the anisotropy values in a texture.
  55592. * rg is direction (like normal from -1 to 1)
  55593. * b is a intensity
  55594. */
  55595. texture: Nullable<BaseTexture>;
  55596. /** @hidden */
  55597. private _internalMarkAllSubMeshesAsTexturesDirty;
  55598. /** @hidden */
  55599. _markAllSubMeshesAsTexturesDirty(): void;
  55600. /**
  55601. * Instantiate a new istance of anisotropy configuration.
  55602. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55603. */
  55604. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55605. /**
  55606. * Specifies that the submesh is ready to be used.
  55607. * @param defines the list of "defines" to update.
  55608. * @param scene defines the scene the material belongs to.
  55609. * @returns - boolean indicating that the submesh is ready or not.
  55610. */
  55611. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  55612. /**
  55613. * Checks to see if a texture is used in the material.
  55614. * @param defines the list of "defines" to update.
  55615. * @param mesh the mesh we are preparing the defines for.
  55616. * @param scene defines the scene the material belongs to.
  55617. */
  55618. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  55619. /**
  55620. * Binds the material data.
  55621. * @param uniformBuffer defines the Uniform buffer to fill in.
  55622. * @param scene defines the scene the material belongs to.
  55623. * @param isFrozen defines wether the material is frozen or not.
  55624. */
  55625. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55626. /**
  55627. * Checks to see if a texture is used in the material.
  55628. * @param texture - Base texture to use.
  55629. * @returns - Boolean specifying if a texture is used in the material.
  55630. */
  55631. hasTexture(texture: BaseTexture): boolean;
  55632. /**
  55633. * Returns an array of the actively used textures.
  55634. * @param activeTextures Array of BaseTextures
  55635. */
  55636. getActiveTextures(activeTextures: BaseTexture[]): void;
  55637. /**
  55638. * Returns the animatable textures.
  55639. * @param animatables Array of animatable textures.
  55640. */
  55641. getAnimatables(animatables: IAnimatable[]): void;
  55642. /**
  55643. * Disposes the resources of the material.
  55644. * @param forceDisposeTextures - Forces the disposal of all textures.
  55645. */
  55646. dispose(forceDisposeTextures?: boolean): void;
  55647. /**
  55648. * Get the current class name of the texture useful for serialization or dynamic coding.
  55649. * @returns "PBRAnisotropicConfiguration"
  55650. */
  55651. getClassName(): string;
  55652. /**
  55653. * Add fallbacks to the effect fallbacks list.
  55654. * @param defines defines the Base texture to use.
  55655. * @param fallbacks defines the current fallback list.
  55656. * @param currentRank defines the current fallback rank.
  55657. * @returns the new fallback rank.
  55658. */
  55659. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55660. /**
  55661. * Add the required uniforms to the current list.
  55662. * @param uniforms defines the current uniform list.
  55663. */
  55664. static AddUniforms(uniforms: string[]): void;
  55665. /**
  55666. * Add the required uniforms to the current buffer.
  55667. * @param uniformBuffer defines the current uniform buffer.
  55668. */
  55669. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55670. /**
  55671. * Add the required samplers to the current list.
  55672. * @param samplers defines the current sampler list.
  55673. */
  55674. static AddSamplers(samplers: string[]): void;
  55675. /**
  55676. * Makes a duplicate of the current configuration into another one.
  55677. * @param anisotropicConfiguration define the config where to copy the info
  55678. */
  55679. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  55680. /**
  55681. * Serializes this anisotropy configuration.
  55682. * @returns - An object with the serialized config.
  55683. */
  55684. serialize(): any;
  55685. /**
  55686. * Parses a anisotropy Configuration from a serialized object.
  55687. * @param source - Serialized object.
  55688. * @param scene Defines the scene we are parsing for
  55689. * @param rootUrl Defines the rootUrl to load from
  55690. */
  55691. parse(source: any, scene: Scene, rootUrl: string): void;
  55692. }
  55693. }
  55694. declare module BABYLON {
  55695. /**
  55696. * @hidden
  55697. */
  55698. export interface IMaterialBRDFDefines {
  55699. BRDF_V_HEIGHT_CORRELATED: boolean;
  55700. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55701. SPHERICAL_HARMONICS: boolean;
  55702. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55703. /** @hidden */
  55704. _areMiscDirty: boolean;
  55705. }
  55706. /**
  55707. * Define the code related to the BRDF parameters of the pbr material.
  55708. */
  55709. export class PBRBRDFConfiguration {
  55710. /**
  55711. * Default value used for the energy conservation.
  55712. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55713. */
  55714. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  55715. /**
  55716. * Default value used for the Smith Visibility Height Correlated mode.
  55717. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55718. */
  55719. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  55720. /**
  55721. * Default value used for the IBL diffuse part.
  55722. * This can help switching back to the polynomials mode globally which is a tiny bit
  55723. * less GPU intensive at the drawback of a lower quality.
  55724. */
  55725. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  55726. /**
  55727. * Default value used for activating energy conservation for the specular workflow.
  55728. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55729. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55730. */
  55731. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  55732. private _useEnergyConservation;
  55733. /**
  55734. * Defines if the material uses energy conservation.
  55735. */
  55736. useEnergyConservation: boolean;
  55737. private _useSmithVisibilityHeightCorrelated;
  55738. /**
  55739. * LEGACY Mode set to false
  55740. * Defines if the material uses height smith correlated visibility term.
  55741. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  55742. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  55743. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  55744. * Not relying on height correlated will also disable energy conservation.
  55745. */
  55746. useSmithVisibilityHeightCorrelated: boolean;
  55747. private _useSphericalHarmonics;
  55748. /**
  55749. * LEGACY Mode set to false
  55750. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  55751. * diffuse part of the IBL.
  55752. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  55753. * to the ground truth.
  55754. */
  55755. useSphericalHarmonics: boolean;
  55756. private _useSpecularGlossinessInputEnergyConservation;
  55757. /**
  55758. * Defines if the material uses energy conservation, when the specular workflow is active.
  55759. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55760. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55761. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  55762. */
  55763. useSpecularGlossinessInputEnergyConservation: boolean;
  55764. /** @hidden */
  55765. private _internalMarkAllSubMeshesAsMiscDirty;
  55766. /** @hidden */
  55767. _markAllSubMeshesAsMiscDirty(): void;
  55768. /**
  55769. * Instantiate a new istance of clear coat configuration.
  55770. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  55771. */
  55772. constructor(markAllSubMeshesAsMiscDirty: () => void);
  55773. /**
  55774. * Checks to see if a texture is used in the material.
  55775. * @param defines the list of "defines" to update.
  55776. */
  55777. prepareDefines(defines: IMaterialBRDFDefines): void;
  55778. /**
  55779. * Get the current class name of the texture useful for serialization or dynamic coding.
  55780. * @returns "PBRClearCoatConfiguration"
  55781. */
  55782. getClassName(): string;
  55783. /**
  55784. * Makes a duplicate of the current configuration into another one.
  55785. * @param brdfConfiguration define the config where to copy the info
  55786. */
  55787. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  55788. /**
  55789. * Serializes this BRDF configuration.
  55790. * @returns - An object with the serialized config.
  55791. */
  55792. serialize(): any;
  55793. /**
  55794. * Parses a anisotropy Configuration from a serialized object.
  55795. * @param source - Serialized object.
  55796. * @param scene Defines the scene we are parsing for
  55797. * @param rootUrl Defines the rootUrl to load from
  55798. */
  55799. parse(source: any, scene: Scene, rootUrl: string): void;
  55800. }
  55801. }
  55802. declare module BABYLON {
  55803. /**
  55804. * @hidden
  55805. */
  55806. export interface IMaterialSheenDefines {
  55807. SHEEN: boolean;
  55808. SHEEN_TEXTURE: boolean;
  55809. SHEEN_TEXTUREDIRECTUV: number;
  55810. SHEEN_LINKWITHALBEDO: boolean;
  55811. SHEEN_ROUGHNESS: boolean;
  55812. SHEEN_ALBEDOSCALING: boolean;
  55813. /** @hidden */
  55814. _areTexturesDirty: boolean;
  55815. }
  55816. /**
  55817. * Define the code related to the Sheen parameters of the pbr material.
  55818. */
  55819. export class PBRSheenConfiguration {
  55820. private _isEnabled;
  55821. /**
  55822. * Defines if the material uses sheen.
  55823. */
  55824. isEnabled: boolean;
  55825. private _linkSheenWithAlbedo;
  55826. /**
  55827. * Defines if the sheen is linked to the sheen color.
  55828. */
  55829. linkSheenWithAlbedo: boolean;
  55830. /**
  55831. * Defines the sheen intensity.
  55832. */
  55833. intensity: number;
  55834. /**
  55835. * Defines the sheen color.
  55836. */
  55837. color: Color3;
  55838. private _texture;
  55839. /**
  55840. * Stores the sheen tint values in a texture.
  55841. * rgb is tint
  55842. * a is a intensity or roughness if roughness has been defined
  55843. */
  55844. texture: Nullable<BaseTexture>;
  55845. private _roughness;
  55846. /**
  55847. * Defines the sheen roughness.
  55848. * It is not taken into account if linkSheenWithAlbedo is true.
  55849. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  55850. */
  55851. roughness: Nullable<number>;
  55852. private _albedoScaling;
  55853. /**
  55854. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  55855. * It allows the strength of the sheen effect to not depend on the base color of the material,
  55856. * making it easier to setup and tweak the effect
  55857. */
  55858. albedoScaling: boolean;
  55859. /** @hidden */
  55860. private _internalMarkAllSubMeshesAsTexturesDirty;
  55861. /** @hidden */
  55862. _markAllSubMeshesAsTexturesDirty(): void;
  55863. /**
  55864. * Instantiate a new istance of clear coat configuration.
  55865. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55866. */
  55867. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55868. /**
  55869. * Specifies that the submesh is ready to be used.
  55870. * @param defines the list of "defines" to update.
  55871. * @param scene defines the scene the material belongs to.
  55872. * @returns - boolean indicating that the submesh is ready or not.
  55873. */
  55874. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  55875. /**
  55876. * Checks to see if a texture is used in the material.
  55877. * @param defines the list of "defines" to update.
  55878. * @param scene defines the scene the material belongs to.
  55879. */
  55880. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  55881. /**
  55882. * Binds the material data.
  55883. * @param uniformBuffer defines the Uniform buffer to fill in.
  55884. * @param scene defines the scene the material belongs to.
  55885. * @param isFrozen defines wether the material is frozen or not.
  55886. */
  55887. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55888. /**
  55889. * Checks to see if a texture is used in the material.
  55890. * @param texture - Base texture to use.
  55891. * @returns - Boolean specifying if a texture is used in the material.
  55892. */
  55893. hasTexture(texture: BaseTexture): boolean;
  55894. /**
  55895. * Returns an array of the actively used textures.
  55896. * @param activeTextures Array of BaseTextures
  55897. */
  55898. getActiveTextures(activeTextures: BaseTexture[]): void;
  55899. /**
  55900. * Returns the animatable textures.
  55901. * @param animatables Array of animatable textures.
  55902. */
  55903. getAnimatables(animatables: IAnimatable[]): void;
  55904. /**
  55905. * Disposes the resources of the material.
  55906. * @param forceDisposeTextures - Forces the disposal of all textures.
  55907. */
  55908. dispose(forceDisposeTextures?: boolean): void;
  55909. /**
  55910. * Get the current class name of the texture useful for serialization or dynamic coding.
  55911. * @returns "PBRSheenConfiguration"
  55912. */
  55913. getClassName(): string;
  55914. /**
  55915. * Add fallbacks to the effect fallbacks list.
  55916. * @param defines defines the Base texture to use.
  55917. * @param fallbacks defines the current fallback list.
  55918. * @param currentRank defines the current fallback rank.
  55919. * @returns the new fallback rank.
  55920. */
  55921. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55922. /**
  55923. * Add the required uniforms to the current list.
  55924. * @param uniforms defines the current uniform list.
  55925. */
  55926. static AddUniforms(uniforms: string[]): void;
  55927. /**
  55928. * Add the required uniforms to the current buffer.
  55929. * @param uniformBuffer defines the current uniform buffer.
  55930. */
  55931. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55932. /**
  55933. * Add the required samplers to the current list.
  55934. * @param samplers defines the current sampler list.
  55935. */
  55936. static AddSamplers(samplers: string[]): void;
  55937. /**
  55938. * Makes a duplicate of the current configuration into another one.
  55939. * @param sheenConfiguration define the config where to copy the info
  55940. */
  55941. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  55942. /**
  55943. * Serializes this BRDF configuration.
  55944. * @returns - An object with the serialized config.
  55945. */
  55946. serialize(): any;
  55947. /**
  55948. * Parses a anisotropy Configuration from a serialized object.
  55949. * @param source - Serialized object.
  55950. * @param scene Defines the scene we are parsing for
  55951. * @param rootUrl Defines the rootUrl to load from
  55952. */
  55953. parse(source: any, scene: Scene, rootUrl: string): void;
  55954. }
  55955. }
  55956. declare module BABYLON {
  55957. /**
  55958. * @hidden
  55959. */
  55960. export interface IMaterialSubSurfaceDefines {
  55961. SUBSURFACE: boolean;
  55962. SS_REFRACTION: boolean;
  55963. SS_TRANSLUCENCY: boolean;
  55964. SS_SCATTERING: boolean;
  55965. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55966. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55967. SS_REFRACTIONMAP_3D: boolean;
  55968. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55969. SS_LODINREFRACTIONALPHA: boolean;
  55970. SS_GAMMAREFRACTION: boolean;
  55971. SS_RGBDREFRACTION: boolean;
  55972. SS_LINEARSPECULARREFRACTION: boolean;
  55973. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55974. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55975. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55976. /** @hidden */
  55977. _areTexturesDirty: boolean;
  55978. }
  55979. /**
  55980. * Define the code related to the sub surface parameters of the pbr material.
  55981. */
  55982. export class PBRSubSurfaceConfiguration {
  55983. private _isRefractionEnabled;
  55984. /**
  55985. * Defines if the refraction is enabled in the material.
  55986. */
  55987. isRefractionEnabled: boolean;
  55988. private _isTranslucencyEnabled;
  55989. /**
  55990. * Defines if the translucency is enabled in the material.
  55991. */
  55992. isTranslucencyEnabled: boolean;
  55993. private _isScatteringEnabled;
  55994. /**
  55995. * Defines if the sub surface scattering is enabled in the material.
  55996. */
  55997. isScatteringEnabled: boolean;
  55998. private _scatteringDiffusionProfileIndex;
  55999. /**
  56000. * Diffusion profile for subsurface scattering.
  56001. * Useful for better scattering in the skins or foliages.
  56002. */
  56003. get scatteringDiffusionProfile(): Nullable<Color3>;
  56004. set scatteringDiffusionProfile(c: Nullable<Color3>);
  56005. /**
  56006. * Defines the refraction intensity of the material.
  56007. * The refraction when enabled replaces the Diffuse part of the material.
  56008. * The intensity helps transitionning between diffuse and refraction.
  56009. */
  56010. refractionIntensity: number;
  56011. /**
  56012. * Defines the translucency intensity of the material.
  56013. * When translucency has been enabled, this defines how much of the "translucency"
  56014. * is addded to the diffuse part of the material.
  56015. */
  56016. translucencyIntensity: number;
  56017. /**
  56018. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  56019. */
  56020. useAlbedoToTintRefraction: boolean;
  56021. private _thicknessTexture;
  56022. /**
  56023. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  56024. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  56025. * 0 would mean minimumThickness
  56026. * 1 would mean maximumThickness
  56027. * The other channels might be use as a mask to vary the different effects intensity.
  56028. */
  56029. thicknessTexture: Nullable<BaseTexture>;
  56030. private _refractionTexture;
  56031. /**
  56032. * Defines the texture to use for refraction.
  56033. */
  56034. refractionTexture: Nullable<BaseTexture>;
  56035. private _indexOfRefraction;
  56036. /**
  56037. * Index of refraction of the material base layer.
  56038. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56039. *
  56040. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56041. *
  56042. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56043. */
  56044. indexOfRefraction: number;
  56045. private _volumeIndexOfRefraction;
  56046. /**
  56047. * Index of refraction of the material's volume.
  56048. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56049. *
  56050. * This ONLY impacts refraction. If not provided or given a non-valid value,
  56051. * the volume will use the same IOR as the surface.
  56052. */
  56053. get volumeIndexOfRefraction(): number;
  56054. set volumeIndexOfRefraction(value: number);
  56055. private _invertRefractionY;
  56056. /**
  56057. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56058. */
  56059. invertRefractionY: boolean;
  56060. private _linkRefractionWithTransparency;
  56061. /**
  56062. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56063. * Materials half opaque for instance using refraction could benefit from this control.
  56064. */
  56065. linkRefractionWithTransparency: boolean;
  56066. /**
  56067. * Defines the minimum thickness stored in the thickness map.
  56068. * If no thickness map is defined, this value will be used to simulate thickness.
  56069. */
  56070. minimumThickness: number;
  56071. /**
  56072. * Defines the maximum thickness stored in the thickness map.
  56073. */
  56074. maximumThickness: number;
  56075. /**
  56076. * Defines the volume tint of the material.
  56077. * This is used for both translucency and scattering.
  56078. */
  56079. tintColor: Color3;
  56080. /**
  56081. * Defines the distance at which the tint color should be found in the media.
  56082. * This is used for refraction only.
  56083. */
  56084. tintColorAtDistance: number;
  56085. /**
  56086. * Defines how far each channel transmit through the media.
  56087. * It is defined as a color to simplify it selection.
  56088. */
  56089. diffusionDistance: Color3;
  56090. private _useMaskFromThicknessTexture;
  56091. /**
  56092. * Stores the intensity of the different subsurface effects in the thickness texture.
  56093. * * the green channel is the translucency intensity.
  56094. * * the blue channel is the scattering intensity.
  56095. * * the alpha channel is the refraction intensity.
  56096. */
  56097. useMaskFromThicknessTexture: boolean;
  56098. private _scene;
  56099. /** @hidden */
  56100. private _internalMarkAllSubMeshesAsTexturesDirty;
  56101. private _internalMarkScenePrePassDirty;
  56102. /** @hidden */
  56103. _markAllSubMeshesAsTexturesDirty(): void;
  56104. /** @hidden */
  56105. _markScenePrePassDirty(): void;
  56106. /**
  56107. * Instantiate a new istance of sub surface configuration.
  56108. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56109. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  56110. * @param scene The scene
  56111. */
  56112. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  56113. /**
  56114. * Gets wehter the submesh is ready to be used or not.
  56115. * @param defines the list of "defines" to update.
  56116. * @param scene defines the scene the material belongs to.
  56117. * @returns - boolean indicating that the submesh is ready or not.
  56118. */
  56119. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  56120. /**
  56121. * Checks to see if a texture is used in the material.
  56122. * @param defines the list of "defines" to update.
  56123. * @param scene defines the scene to the material belongs to.
  56124. */
  56125. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  56126. /**
  56127. * Binds the material data.
  56128. * @param uniformBuffer defines the Uniform buffer to fill in.
  56129. * @param scene defines the scene the material belongs to.
  56130. * @param engine defines the engine the material belongs to.
  56131. * @param isFrozen defines whether the material is frozen or not.
  56132. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  56133. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  56134. */
  56135. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  56136. /**
  56137. * Unbinds the material from the mesh.
  56138. * @param activeEffect defines the effect that should be unbound from.
  56139. * @returns true if unbound, otherwise false
  56140. */
  56141. unbind(activeEffect: Effect): boolean;
  56142. /**
  56143. * Returns the texture used for refraction or null if none is used.
  56144. * @param scene defines the scene the material belongs to.
  56145. * @returns - Refraction texture if present. If no refraction texture and refraction
  56146. * is linked with transparency, returns environment texture. Otherwise, returns null.
  56147. */
  56148. private _getRefractionTexture;
  56149. /**
  56150. * Returns true if alpha blending should be disabled.
  56151. */
  56152. get disableAlphaBlending(): boolean;
  56153. /**
  56154. * Fills the list of render target textures.
  56155. * @param renderTargets the list of render targets to update
  56156. */
  56157. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  56158. /**
  56159. * Checks to see if a texture is used in the material.
  56160. * @param texture - Base texture to use.
  56161. * @returns - Boolean specifying if a texture is used in the material.
  56162. */
  56163. hasTexture(texture: BaseTexture): boolean;
  56164. /**
  56165. * Gets a boolean indicating that current material needs to register RTT
  56166. * @returns true if this uses a render target otherwise false.
  56167. */
  56168. hasRenderTargetTextures(): boolean;
  56169. /**
  56170. * Returns an array of the actively used textures.
  56171. * @param activeTextures Array of BaseTextures
  56172. */
  56173. getActiveTextures(activeTextures: BaseTexture[]): void;
  56174. /**
  56175. * Returns the animatable textures.
  56176. * @param animatables Array of animatable textures.
  56177. */
  56178. getAnimatables(animatables: IAnimatable[]): void;
  56179. /**
  56180. * Disposes the resources of the material.
  56181. * @param forceDisposeTextures - Forces the disposal of all textures.
  56182. */
  56183. dispose(forceDisposeTextures?: boolean): void;
  56184. /**
  56185. * Get the current class name of the texture useful for serialization or dynamic coding.
  56186. * @returns "PBRSubSurfaceConfiguration"
  56187. */
  56188. getClassName(): string;
  56189. /**
  56190. * Add fallbacks to the effect fallbacks list.
  56191. * @param defines defines the Base texture to use.
  56192. * @param fallbacks defines the current fallback list.
  56193. * @param currentRank defines the current fallback rank.
  56194. * @returns the new fallback rank.
  56195. */
  56196. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56197. /**
  56198. * Add the required uniforms to the current list.
  56199. * @param uniforms defines the current uniform list.
  56200. */
  56201. static AddUniforms(uniforms: string[]): void;
  56202. /**
  56203. * Add the required samplers to the current list.
  56204. * @param samplers defines the current sampler list.
  56205. */
  56206. static AddSamplers(samplers: string[]): void;
  56207. /**
  56208. * Add the required uniforms to the current buffer.
  56209. * @param uniformBuffer defines the current uniform buffer.
  56210. */
  56211. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56212. /**
  56213. * Makes a duplicate of the current configuration into another one.
  56214. * @param configuration define the config where to copy the info
  56215. */
  56216. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  56217. /**
  56218. * Serializes this Sub Surface configuration.
  56219. * @returns - An object with the serialized config.
  56220. */
  56221. serialize(): any;
  56222. /**
  56223. * Parses a anisotropy Configuration from a serialized object.
  56224. * @param source - Serialized object.
  56225. * @param scene Defines the scene we are parsing for
  56226. * @param rootUrl Defines the rootUrl to load from
  56227. */
  56228. parse(source: any, scene: Scene, rootUrl: string): void;
  56229. }
  56230. }
  56231. declare module BABYLON {
  56232. /** @hidden */
  56233. export var pbrFragmentDeclaration: {
  56234. name: string;
  56235. shader: string;
  56236. };
  56237. }
  56238. declare module BABYLON {
  56239. /** @hidden */
  56240. export var pbrUboDeclaration: {
  56241. name: string;
  56242. shader: string;
  56243. };
  56244. }
  56245. declare module BABYLON {
  56246. /** @hidden */
  56247. export var pbrFragmentExtraDeclaration: {
  56248. name: string;
  56249. shader: string;
  56250. };
  56251. }
  56252. declare module BABYLON {
  56253. /** @hidden */
  56254. export var pbrFragmentSamplersDeclaration: {
  56255. name: string;
  56256. shader: string;
  56257. };
  56258. }
  56259. declare module BABYLON {
  56260. /** @hidden */
  56261. export var subSurfaceScatteringFunctions: {
  56262. name: string;
  56263. shader: string;
  56264. };
  56265. }
  56266. declare module BABYLON {
  56267. /** @hidden */
  56268. export var importanceSampling: {
  56269. name: string;
  56270. shader: string;
  56271. };
  56272. }
  56273. declare module BABYLON {
  56274. /** @hidden */
  56275. export var pbrHelperFunctions: {
  56276. name: string;
  56277. shader: string;
  56278. };
  56279. }
  56280. declare module BABYLON {
  56281. /** @hidden */
  56282. export var harmonicsFunctions: {
  56283. name: string;
  56284. shader: string;
  56285. };
  56286. }
  56287. declare module BABYLON {
  56288. /** @hidden */
  56289. export var pbrDirectLightingSetupFunctions: {
  56290. name: string;
  56291. shader: string;
  56292. };
  56293. }
  56294. declare module BABYLON {
  56295. /** @hidden */
  56296. export var pbrDirectLightingFalloffFunctions: {
  56297. name: string;
  56298. shader: string;
  56299. };
  56300. }
  56301. declare module BABYLON {
  56302. /** @hidden */
  56303. export var pbrBRDFFunctions: {
  56304. name: string;
  56305. shader: string;
  56306. };
  56307. }
  56308. declare module BABYLON {
  56309. /** @hidden */
  56310. export var hdrFilteringFunctions: {
  56311. name: string;
  56312. shader: string;
  56313. };
  56314. }
  56315. declare module BABYLON {
  56316. /** @hidden */
  56317. export var pbrDirectLightingFunctions: {
  56318. name: string;
  56319. shader: string;
  56320. };
  56321. }
  56322. declare module BABYLON {
  56323. /** @hidden */
  56324. export var pbrIBLFunctions: {
  56325. name: string;
  56326. shader: string;
  56327. };
  56328. }
  56329. declare module BABYLON {
  56330. /** @hidden */
  56331. export var pbrBlockAlbedoOpacity: {
  56332. name: string;
  56333. shader: string;
  56334. };
  56335. }
  56336. declare module BABYLON {
  56337. /** @hidden */
  56338. export var pbrBlockReflectivity: {
  56339. name: string;
  56340. shader: string;
  56341. };
  56342. }
  56343. declare module BABYLON {
  56344. /** @hidden */
  56345. export var pbrBlockAmbientOcclusion: {
  56346. name: string;
  56347. shader: string;
  56348. };
  56349. }
  56350. declare module BABYLON {
  56351. /** @hidden */
  56352. export var pbrBlockAlphaFresnel: {
  56353. name: string;
  56354. shader: string;
  56355. };
  56356. }
  56357. declare module BABYLON {
  56358. /** @hidden */
  56359. export var pbrBlockAnisotropic: {
  56360. name: string;
  56361. shader: string;
  56362. };
  56363. }
  56364. declare module BABYLON {
  56365. /** @hidden */
  56366. export var pbrBlockReflection: {
  56367. name: string;
  56368. shader: string;
  56369. };
  56370. }
  56371. declare module BABYLON {
  56372. /** @hidden */
  56373. export var pbrBlockSheen: {
  56374. name: string;
  56375. shader: string;
  56376. };
  56377. }
  56378. declare module BABYLON {
  56379. /** @hidden */
  56380. export var pbrBlockClearcoat: {
  56381. name: string;
  56382. shader: string;
  56383. };
  56384. }
  56385. declare module BABYLON {
  56386. /** @hidden */
  56387. export var pbrBlockSubSurface: {
  56388. name: string;
  56389. shader: string;
  56390. };
  56391. }
  56392. declare module BABYLON {
  56393. /** @hidden */
  56394. export var pbrBlockNormalGeometric: {
  56395. name: string;
  56396. shader: string;
  56397. };
  56398. }
  56399. declare module BABYLON {
  56400. /** @hidden */
  56401. export var pbrBlockNormalFinal: {
  56402. name: string;
  56403. shader: string;
  56404. };
  56405. }
  56406. declare module BABYLON {
  56407. /** @hidden */
  56408. export var pbrBlockLightmapInit: {
  56409. name: string;
  56410. shader: string;
  56411. };
  56412. }
  56413. declare module BABYLON {
  56414. /** @hidden */
  56415. export var pbrBlockGeometryInfo: {
  56416. name: string;
  56417. shader: string;
  56418. };
  56419. }
  56420. declare module BABYLON {
  56421. /** @hidden */
  56422. export var pbrBlockReflectance0: {
  56423. name: string;
  56424. shader: string;
  56425. };
  56426. }
  56427. declare module BABYLON {
  56428. /** @hidden */
  56429. export var pbrBlockReflectance: {
  56430. name: string;
  56431. shader: string;
  56432. };
  56433. }
  56434. declare module BABYLON {
  56435. /** @hidden */
  56436. export var pbrBlockDirectLighting: {
  56437. name: string;
  56438. shader: string;
  56439. };
  56440. }
  56441. declare module BABYLON {
  56442. /** @hidden */
  56443. export var pbrBlockFinalLitComponents: {
  56444. name: string;
  56445. shader: string;
  56446. };
  56447. }
  56448. declare module BABYLON {
  56449. /** @hidden */
  56450. export var pbrBlockFinalUnlitComponents: {
  56451. name: string;
  56452. shader: string;
  56453. };
  56454. }
  56455. declare module BABYLON {
  56456. /** @hidden */
  56457. export var pbrBlockFinalColorComposition: {
  56458. name: string;
  56459. shader: string;
  56460. };
  56461. }
  56462. declare module BABYLON {
  56463. /** @hidden */
  56464. export var pbrBlockImageProcessing: {
  56465. name: string;
  56466. shader: string;
  56467. };
  56468. }
  56469. declare module BABYLON {
  56470. /** @hidden */
  56471. export var pbrDebug: {
  56472. name: string;
  56473. shader: string;
  56474. };
  56475. }
  56476. declare module BABYLON {
  56477. /** @hidden */
  56478. export var pbrPixelShader: {
  56479. name: string;
  56480. shader: string;
  56481. };
  56482. }
  56483. declare module BABYLON {
  56484. /** @hidden */
  56485. export var pbrVertexDeclaration: {
  56486. name: string;
  56487. shader: string;
  56488. };
  56489. }
  56490. declare module BABYLON {
  56491. /** @hidden */
  56492. export var pbrVertexShader: {
  56493. name: string;
  56494. shader: string;
  56495. };
  56496. }
  56497. declare module BABYLON {
  56498. /**
  56499. * Manages the defines for the PBR Material.
  56500. * @hidden
  56501. */
  56502. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  56503. PBR: boolean;
  56504. NUM_SAMPLES: string;
  56505. REALTIME_FILTERING: boolean;
  56506. MAINUV1: boolean;
  56507. MAINUV2: boolean;
  56508. UV1: boolean;
  56509. UV2: boolean;
  56510. ALBEDO: boolean;
  56511. GAMMAALBEDO: boolean;
  56512. ALBEDODIRECTUV: number;
  56513. VERTEXCOLOR: boolean;
  56514. DETAIL: boolean;
  56515. DETAILDIRECTUV: number;
  56516. DETAIL_NORMALBLENDMETHOD: number;
  56517. AMBIENT: boolean;
  56518. AMBIENTDIRECTUV: number;
  56519. AMBIENTINGRAYSCALE: boolean;
  56520. OPACITY: boolean;
  56521. VERTEXALPHA: boolean;
  56522. OPACITYDIRECTUV: number;
  56523. OPACITYRGB: boolean;
  56524. ALPHATEST: boolean;
  56525. DEPTHPREPASS: boolean;
  56526. ALPHABLEND: boolean;
  56527. ALPHAFROMALBEDO: boolean;
  56528. ALPHATESTVALUE: string;
  56529. SPECULAROVERALPHA: boolean;
  56530. RADIANCEOVERALPHA: boolean;
  56531. ALPHAFRESNEL: boolean;
  56532. LINEARALPHAFRESNEL: boolean;
  56533. PREMULTIPLYALPHA: boolean;
  56534. EMISSIVE: boolean;
  56535. EMISSIVEDIRECTUV: number;
  56536. REFLECTIVITY: boolean;
  56537. REFLECTIVITYDIRECTUV: number;
  56538. SPECULARTERM: boolean;
  56539. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  56540. MICROSURFACEAUTOMATIC: boolean;
  56541. LODBASEDMICROSFURACE: boolean;
  56542. MICROSURFACEMAP: boolean;
  56543. MICROSURFACEMAPDIRECTUV: number;
  56544. METALLICWORKFLOW: boolean;
  56545. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  56546. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  56547. METALLNESSSTOREINMETALMAPBLUE: boolean;
  56548. AOSTOREINMETALMAPRED: boolean;
  56549. METALLIC_REFLECTANCE: boolean;
  56550. METALLIC_REFLECTANCEDIRECTUV: number;
  56551. ENVIRONMENTBRDF: boolean;
  56552. ENVIRONMENTBRDF_RGBD: boolean;
  56553. NORMAL: boolean;
  56554. TANGENT: boolean;
  56555. BUMP: boolean;
  56556. BUMPDIRECTUV: number;
  56557. OBJECTSPACE_NORMALMAP: boolean;
  56558. PARALLAX: boolean;
  56559. PARALLAXOCCLUSION: boolean;
  56560. NORMALXYSCALE: boolean;
  56561. LIGHTMAP: boolean;
  56562. LIGHTMAPDIRECTUV: number;
  56563. USELIGHTMAPASSHADOWMAP: boolean;
  56564. GAMMALIGHTMAP: boolean;
  56565. RGBDLIGHTMAP: boolean;
  56566. REFLECTION: boolean;
  56567. REFLECTIONMAP_3D: boolean;
  56568. REFLECTIONMAP_SPHERICAL: boolean;
  56569. REFLECTIONMAP_PLANAR: boolean;
  56570. REFLECTIONMAP_CUBIC: boolean;
  56571. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  56572. REFLECTIONMAP_PROJECTION: boolean;
  56573. REFLECTIONMAP_SKYBOX: boolean;
  56574. REFLECTIONMAP_EXPLICIT: boolean;
  56575. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  56576. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  56577. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  56578. INVERTCUBICMAP: boolean;
  56579. USESPHERICALFROMREFLECTIONMAP: boolean;
  56580. USEIRRADIANCEMAP: boolean;
  56581. SPHERICAL_HARMONICS: boolean;
  56582. USESPHERICALINVERTEX: boolean;
  56583. REFLECTIONMAP_OPPOSITEZ: boolean;
  56584. LODINREFLECTIONALPHA: boolean;
  56585. GAMMAREFLECTION: boolean;
  56586. RGBDREFLECTION: boolean;
  56587. LINEARSPECULARREFLECTION: boolean;
  56588. RADIANCEOCCLUSION: boolean;
  56589. HORIZONOCCLUSION: boolean;
  56590. INSTANCES: boolean;
  56591. THIN_INSTANCES: boolean;
  56592. PREPASS: boolean;
  56593. PREPASS_IRRADIANCE: boolean;
  56594. PREPASS_IRRADIANCE_INDEX: number;
  56595. PREPASS_ALBEDO: boolean;
  56596. PREPASS_ALBEDO_INDEX: number;
  56597. PREPASS_DEPTHNORMAL: boolean;
  56598. PREPASS_DEPTHNORMAL_INDEX: number;
  56599. SCENE_MRT_COUNT: number;
  56600. NUM_BONE_INFLUENCERS: number;
  56601. BonesPerMesh: number;
  56602. BONETEXTURE: boolean;
  56603. NONUNIFORMSCALING: boolean;
  56604. MORPHTARGETS: boolean;
  56605. MORPHTARGETS_NORMAL: boolean;
  56606. MORPHTARGETS_TANGENT: boolean;
  56607. MORPHTARGETS_UV: boolean;
  56608. NUM_MORPH_INFLUENCERS: number;
  56609. IMAGEPROCESSING: boolean;
  56610. VIGNETTE: boolean;
  56611. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56612. VIGNETTEBLENDMODEOPAQUE: boolean;
  56613. TONEMAPPING: boolean;
  56614. TONEMAPPING_ACES: boolean;
  56615. CONTRAST: boolean;
  56616. COLORCURVES: boolean;
  56617. COLORGRADING: boolean;
  56618. COLORGRADING3D: boolean;
  56619. SAMPLER3DGREENDEPTH: boolean;
  56620. SAMPLER3DBGRMAP: boolean;
  56621. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56622. EXPOSURE: boolean;
  56623. MULTIVIEW: boolean;
  56624. USEPHYSICALLIGHTFALLOFF: boolean;
  56625. USEGLTFLIGHTFALLOFF: boolean;
  56626. TWOSIDEDLIGHTING: boolean;
  56627. SHADOWFLOAT: boolean;
  56628. CLIPPLANE: boolean;
  56629. CLIPPLANE2: boolean;
  56630. CLIPPLANE3: boolean;
  56631. CLIPPLANE4: boolean;
  56632. CLIPPLANE5: boolean;
  56633. CLIPPLANE6: boolean;
  56634. POINTSIZE: boolean;
  56635. FOG: boolean;
  56636. LOGARITHMICDEPTH: boolean;
  56637. FORCENORMALFORWARD: boolean;
  56638. SPECULARAA: boolean;
  56639. CLEARCOAT: boolean;
  56640. CLEARCOAT_DEFAULTIOR: boolean;
  56641. CLEARCOAT_TEXTURE: boolean;
  56642. CLEARCOAT_TEXTUREDIRECTUV: number;
  56643. CLEARCOAT_BUMP: boolean;
  56644. CLEARCOAT_BUMPDIRECTUV: number;
  56645. CLEARCOAT_TINT: boolean;
  56646. CLEARCOAT_TINT_TEXTURE: boolean;
  56647. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56648. ANISOTROPIC: boolean;
  56649. ANISOTROPIC_TEXTURE: boolean;
  56650. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56651. BRDF_V_HEIGHT_CORRELATED: boolean;
  56652. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56653. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56654. SHEEN: boolean;
  56655. SHEEN_TEXTURE: boolean;
  56656. SHEEN_TEXTUREDIRECTUV: number;
  56657. SHEEN_LINKWITHALBEDO: boolean;
  56658. SHEEN_ROUGHNESS: boolean;
  56659. SHEEN_ALBEDOSCALING: boolean;
  56660. SUBSURFACE: boolean;
  56661. SS_REFRACTION: boolean;
  56662. SS_TRANSLUCENCY: boolean;
  56663. SS_SCATTERING: boolean;
  56664. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56665. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56666. SS_REFRACTIONMAP_3D: boolean;
  56667. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56668. SS_LODINREFRACTIONALPHA: boolean;
  56669. SS_GAMMAREFRACTION: boolean;
  56670. SS_RGBDREFRACTION: boolean;
  56671. SS_LINEARSPECULARREFRACTION: boolean;
  56672. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56673. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56674. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56675. UNLIT: boolean;
  56676. DEBUGMODE: number;
  56677. /**
  56678. * Initializes the PBR Material defines.
  56679. */
  56680. constructor();
  56681. /**
  56682. * Resets the PBR Material defines.
  56683. */
  56684. reset(): void;
  56685. }
  56686. /**
  56687. * The Physically based material base class of BJS.
  56688. *
  56689. * This offers the main features of a standard PBR material.
  56690. * For more information, please refer to the documentation :
  56691. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56692. */
  56693. export abstract class PBRBaseMaterial extends PushMaterial {
  56694. /**
  56695. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56696. */
  56697. static readonly PBRMATERIAL_OPAQUE: number;
  56698. /**
  56699. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56700. */
  56701. static readonly PBRMATERIAL_ALPHATEST: number;
  56702. /**
  56703. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56704. */
  56705. static readonly PBRMATERIAL_ALPHABLEND: number;
  56706. /**
  56707. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56708. * They are also discarded below the alpha cutoff threshold to improve performances.
  56709. */
  56710. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56711. /**
  56712. * Defines the default value of how much AO map is occluding the analytical lights
  56713. * (point spot...).
  56714. */
  56715. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56716. /**
  56717. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  56718. */
  56719. static readonly LIGHTFALLOFF_PHYSICAL: number;
  56720. /**
  56721. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  56722. * to enhance interoperability with other engines.
  56723. */
  56724. static readonly LIGHTFALLOFF_GLTF: number;
  56725. /**
  56726. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  56727. * to enhance interoperability with other materials.
  56728. */
  56729. static readonly LIGHTFALLOFF_STANDARD: number;
  56730. /**
  56731. * Intensity of the direct lights e.g. the four lights available in your scene.
  56732. * This impacts both the direct diffuse and specular highlights.
  56733. */
  56734. protected _directIntensity: number;
  56735. /**
  56736. * Intensity of the emissive part of the material.
  56737. * This helps controlling the emissive effect without modifying the emissive color.
  56738. */
  56739. protected _emissiveIntensity: number;
  56740. /**
  56741. * Intensity of the environment e.g. how much the environment will light the object
  56742. * either through harmonics for rough material or through the refelction for shiny ones.
  56743. */
  56744. protected _environmentIntensity: number;
  56745. /**
  56746. * This is a special control allowing the reduction of the specular highlights coming from the
  56747. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56748. */
  56749. protected _specularIntensity: number;
  56750. /**
  56751. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  56752. */
  56753. private _lightingInfos;
  56754. /**
  56755. * Debug Control allowing disabling the bump map on this material.
  56756. */
  56757. protected _disableBumpMap: boolean;
  56758. /**
  56759. * AKA Diffuse Texture in standard nomenclature.
  56760. */
  56761. protected _albedoTexture: Nullable<BaseTexture>;
  56762. /**
  56763. * AKA Occlusion Texture in other nomenclature.
  56764. */
  56765. protected _ambientTexture: Nullable<BaseTexture>;
  56766. /**
  56767. * AKA Occlusion Texture Intensity in other nomenclature.
  56768. */
  56769. protected _ambientTextureStrength: number;
  56770. /**
  56771. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56772. * 1 means it completely occludes it
  56773. * 0 mean it has no impact
  56774. */
  56775. protected _ambientTextureImpactOnAnalyticalLights: number;
  56776. /**
  56777. * Stores the alpha values in a texture.
  56778. */
  56779. protected _opacityTexture: Nullable<BaseTexture>;
  56780. /**
  56781. * Stores the reflection values in a texture.
  56782. */
  56783. protected _reflectionTexture: Nullable<BaseTexture>;
  56784. /**
  56785. * Stores the emissive values in a texture.
  56786. */
  56787. protected _emissiveTexture: Nullable<BaseTexture>;
  56788. /**
  56789. * AKA Specular texture in other nomenclature.
  56790. */
  56791. protected _reflectivityTexture: Nullable<BaseTexture>;
  56792. /**
  56793. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56794. */
  56795. protected _metallicTexture: Nullable<BaseTexture>;
  56796. /**
  56797. * Specifies the metallic scalar of the metallic/roughness workflow.
  56798. * Can also be used to scale the metalness values of the metallic texture.
  56799. */
  56800. protected _metallic: Nullable<number>;
  56801. /**
  56802. * Specifies the roughness scalar of the metallic/roughness workflow.
  56803. * Can also be used to scale the roughness values of the metallic texture.
  56804. */
  56805. protected _roughness: Nullable<number>;
  56806. /**
  56807. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56808. * By default the indexOfrefraction is used to compute F0;
  56809. *
  56810. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56811. *
  56812. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56813. * F90 = metallicReflectanceColor;
  56814. */
  56815. protected _metallicF0Factor: number;
  56816. /**
  56817. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56818. * By default the F90 is always 1;
  56819. *
  56820. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56821. *
  56822. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56823. * F90 = metallicReflectanceColor;
  56824. */
  56825. protected _metallicReflectanceColor: Color3;
  56826. /**
  56827. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56828. * This is multiply against the scalar values defined in the material.
  56829. */
  56830. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  56831. /**
  56832. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56833. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56834. */
  56835. protected _microSurfaceTexture: Nullable<BaseTexture>;
  56836. /**
  56837. * Stores surface normal data used to displace a mesh in a texture.
  56838. */
  56839. protected _bumpTexture: Nullable<BaseTexture>;
  56840. /**
  56841. * Stores the pre-calculated light information of a mesh in a texture.
  56842. */
  56843. protected _lightmapTexture: Nullable<BaseTexture>;
  56844. /**
  56845. * The color of a material in ambient lighting.
  56846. */
  56847. protected _ambientColor: Color3;
  56848. /**
  56849. * AKA Diffuse Color in other nomenclature.
  56850. */
  56851. protected _albedoColor: Color3;
  56852. /**
  56853. * AKA Specular Color in other nomenclature.
  56854. */
  56855. protected _reflectivityColor: Color3;
  56856. /**
  56857. * The color applied when light is reflected from a material.
  56858. */
  56859. protected _reflectionColor: Color3;
  56860. /**
  56861. * The color applied when light is emitted from a material.
  56862. */
  56863. protected _emissiveColor: Color3;
  56864. /**
  56865. * AKA Glossiness in other nomenclature.
  56866. */
  56867. protected _microSurface: number;
  56868. /**
  56869. * Specifies that the material will use the light map as a show map.
  56870. */
  56871. protected _useLightmapAsShadowmap: boolean;
  56872. /**
  56873. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56874. * makes the reflect vector face the model (under horizon).
  56875. */
  56876. protected _useHorizonOcclusion: boolean;
  56877. /**
  56878. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56879. * too much the area relying on ambient texture to define their ambient occlusion.
  56880. */
  56881. protected _useRadianceOcclusion: boolean;
  56882. /**
  56883. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56884. */
  56885. protected _useAlphaFromAlbedoTexture: boolean;
  56886. /**
  56887. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  56888. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56889. */
  56890. protected _useSpecularOverAlpha: boolean;
  56891. /**
  56892. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56893. */
  56894. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56895. /**
  56896. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56897. */
  56898. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  56899. /**
  56900. * Specifies if the metallic texture contains the roughness information in its green channel.
  56901. */
  56902. protected _useRoughnessFromMetallicTextureGreen: boolean;
  56903. /**
  56904. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56905. */
  56906. protected _useMetallnessFromMetallicTextureBlue: boolean;
  56907. /**
  56908. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56909. */
  56910. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  56911. /**
  56912. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56913. */
  56914. protected _useAmbientInGrayScale: boolean;
  56915. /**
  56916. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56917. * The material will try to infer what glossiness each pixel should be.
  56918. */
  56919. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  56920. /**
  56921. * Defines the falloff type used in this material.
  56922. * It by default is Physical.
  56923. */
  56924. protected _lightFalloff: number;
  56925. /**
  56926. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56927. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56928. */
  56929. protected _useRadianceOverAlpha: boolean;
  56930. /**
  56931. * Allows using an object space normal map (instead of tangent space).
  56932. */
  56933. protected _useObjectSpaceNormalMap: boolean;
  56934. /**
  56935. * Allows using the bump map in parallax mode.
  56936. */
  56937. protected _useParallax: boolean;
  56938. /**
  56939. * Allows using the bump map in parallax occlusion mode.
  56940. */
  56941. protected _useParallaxOcclusion: boolean;
  56942. /**
  56943. * Controls the scale bias of the parallax mode.
  56944. */
  56945. protected _parallaxScaleBias: number;
  56946. /**
  56947. * If sets to true, disables all the lights affecting the material.
  56948. */
  56949. protected _disableLighting: boolean;
  56950. /**
  56951. * Number of Simultaneous lights allowed on the material.
  56952. */
  56953. protected _maxSimultaneousLights: number;
  56954. /**
  56955. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56956. */
  56957. protected _invertNormalMapX: boolean;
  56958. /**
  56959. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56960. */
  56961. protected _invertNormalMapY: boolean;
  56962. /**
  56963. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56964. */
  56965. protected _twoSidedLighting: boolean;
  56966. /**
  56967. * Defines the alpha limits in alpha test mode.
  56968. */
  56969. protected _alphaCutOff: number;
  56970. /**
  56971. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56972. */
  56973. protected _forceAlphaTest: boolean;
  56974. /**
  56975. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56976. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56977. */
  56978. protected _useAlphaFresnel: boolean;
  56979. /**
  56980. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56981. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56982. */
  56983. protected _useLinearAlphaFresnel: boolean;
  56984. /**
  56985. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  56986. * from cos thetav and roughness:
  56987. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  56988. */
  56989. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  56990. /**
  56991. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56992. */
  56993. protected _forceIrradianceInFragment: boolean;
  56994. private _realTimeFiltering;
  56995. /**
  56996. * Enables realtime filtering on the texture.
  56997. */
  56998. get realTimeFiltering(): boolean;
  56999. set realTimeFiltering(b: boolean);
  57000. private _realTimeFilteringQuality;
  57001. /**
  57002. * Quality switch for realtime filtering
  57003. */
  57004. get realTimeFilteringQuality(): number;
  57005. set realTimeFilteringQuality(n: number);
  57006. /**
  57007. * Can this material render to several textures at once
  57008. */
  57009. get canRenderToMRT(): boolean;
  57010. /**
  57011. * Force normal to face away from face.
  57012. */
  57013. protected _forceNormalForward: boolean;
  57014. /**
  57015. * Enables specular anti aliasing in the PBR shader.
  57016. * It will both interacts on the Geometry for analytical and IBL lighting.
  57017. * It also prefilter the roughness map based on the bump values.
  57018. */
  57019. protected _enableSpecularAntiAliasing: boolean;
  57020. /**
  57021. * Default configuration related to image processing available in the PBR Material.
  57022. */
  57023. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57024. /**
  57025. * Keep track of the image processing observer to allow dispose and replace.
  57026. */
  57027. private _imageProcessingObserver;
  57028. /**
  57029. * Attaches a new image processing configuration to the PBR Material.
  57030. * @param configuration
  57031. */
  57032. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57033. /**
  57034. * Stores the available render targets.
  57035. */
  57036. private _renderTargets;
  57037. /**
  57038. * Sets the global ambient color for the material used in lighting calculations.
  57039. */
  57040. private _globalAmbientColor;
  57041. /**
  57042. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  57043. */
  57044. private _useLogarithmicDepth;
  57045. /**
  57046. * If set to true, no lighting calculations will be applied.
  57047. */
  57048. private _unlit;
  57049. private _debugMode;
  57050. /**
  57051. * @hidden
  57052. * This is reserved for the inspector.
  57053. * Defines the material debug mode.
  57054. * It helps seeing only some components of the material while troubleshooting.
  57055. */
  57056. debugMode: number;
  57057. /**
  57058. * @hidden
  57059. * This is reserved for the inspector.
  57060. * Specify from where on screen the debug mode should start.
  57061. * The value goes from -1 (full screen) to 1 (not visible)
  57062. * It helps with side by side comparison against the final render
  57063. * This defaults to -1
  57064. */
  57065. private debugLimit;
  57066. /**
  57067. * @hidden
  57068. * This is reserved for the inspector.
  57069. * As the default viewing range might not be enough (if the ambient is really small for instance)
  57070. * You can use the factor to better multiply the final value.
  57071. */
  57072. private debugFactor;
  57073. /**
  57074. * Defines the clear coat layer parameters for the material.
  57075. */
  57076. readonly clearCoat: PBRClearCoatConfiguration;
  57077. /**
  57078. * Defines the anisotropic parameters for the material.
  57079. */
  57080. readonly anisotropy: PBRAnisotropicConfiguration;
  57081. /**
  57082. * Defines the BRDF parameters for the material.
  57083. */
  57084. readonly brdf: PBRBRDFConfiguration;
  57085. /**
  57086. * Defines the Sheen parameters for the material.
  57087. */
  57088. readonly sheen: PBRSheenConfiguration;
  57089. /**
  57090. * Defines the SubSurface parameters for the material.
  57091. */
  57092. readonly subSurface: PBRSubSurfaceConfiguration;
  57093. /**
  57094. * Defines the detail map parameters for the material.
  57095. */
  57096. readonly detailMap: DetailMapConfiguration;
  57097. protected _rebuildInParallel: boolean;
  57098. /**
  57099. * Instantiates a new PBRMaterial instance.
  57100. *
  57101. * @param name The material name
  57102. * @param scene The scene the material will be use in.
  57103. */
  57104. constructor(name: string, scene: Scene);
  57105. /**
  57106. * Gets a boolean indicating that current material needs to register RTT
  57107. */
  57108. get hasRenderTargetTextures(): boolean;
  57109. /**
  57110. * Gets the name of the material class.
  57111. */
  57112. getClassName(): string;
  57113. /**
  57114. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57115. */
  57116. get useLogarithmicDepth(): boolean;
  57117. /**
  57118. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57119. */
  57120. set useLogarithmicDepth(value: boolean);
  57121. /**
  57122. * Returns true if alpha blending should be disabled.
  57123. */
  57124. protected get _disableAlphaBlending(): boolean;
  57125. /**
  57126. * Specifies whether or not this material should be rendered in alpha blend mode.
  57127. */
  57128. needAlphaBlending(): boolean;
  57129. /**
  57130. * Specifies whether or not this material should be rendered in alpha test mode.
  57131. */
  57132. needAlphaTesting(): boolean;
  57133. /**
  57134. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  57135. */
  57136. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  57137. /**
  57138. * Gets the texture used for the alpha test.
  57139. */
  57140. getAlphaTestTexture(): Nullable<BaseTexture>;
  57141. /**
  57142. * Specifies that the submesh is ready to be used.
  57143. * @param mesh - BJS mesh.
  57144. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  57145. * @param useInstances - Specifies that instances should be used.
  57146. * @returns - boolean indicating that the submesh is ready or not.
  57147. */
  57148. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57149. /**
  57150. * Specifies if the material uses metallic roughness workflow.
  57151. * @returns boolean specifiying if the material uses metallic roughness workflow.
  57152. */
  57153. isMetallicWorkflow(): boolean;
  57154. private _prepareEffect;
  57155. private _prepareDefines;
  57156. /**
  57157. * Force shader compilation
  57158. */
  57159. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  57160. /**
  57161. * Initializes the uniform buffer layout for the shader.
  57162. */
  57163. buildUniformLayout(): void;
  57164. /**
  57165. * Unbinds the material from the mesh
  57166. */
  57167. unbind(): void;
  57168. /**
  57169. * Binds the submesh data.
  57170. * @param world - The world matrix.
  57171. * @param mesh - The BJS mesh.
  57172. * @param subMesh - A submesh of the BJS mesh.
  57173. */
  57174. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57175. /**
  57176. * Returns the animatable textures.
  57177. * @returns - Array of animatable textures.
  57178. */
  57179. getAnimatables(): IAnimatable[];
  57180. /**
  57181. * Returns the texture used for reflections.
  57182. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  57183. */
  57184. private _getReflectionTexture;
  57185. /**
  57186. * Returns an array of the actively used textures.
  57187. * @returns - Array of BaseTextures
  57188. */
  57189. getActiveTextures(): BaseTexture[];
  57190. /**
  57191. * Checks to see if a texture is used in the material.
  57192. * @param texture - Base texture to use.
  57193. * @returns - Boolean specifying if a texture is used in the material.
  57194. */
  57195. hasTexture(texture: BaseTexture): boolean;
  57196. /**
  57197. * Sets the required values to the prepass renderer.
  57198. * @param prePassRenderer defines the prepass renderer to setup
  57199. */
  57200. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  57201. /**
  57202. * Disposes the resources of the material.
  57203. * @param forceDisposeEffect - Forces the disposal of effects.
  57204. * @param forceDisposeTextures - Forces the disposal of all textures.
  57205. */
  57206. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57207. }
  57208. }
  57209. declare module BABYLON {
  57210. /**
  57211. * The Physically based material of BJS.
  57212. *
  57213. * This offers the main features of a standard PBR material.
  57214. * For more information, please refer to the documentation :
  57215. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57216. */
  57217. export class PBRMaterial extends PBRBaseMaterial {
  57218. /**
  57219. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57220. */
  57221. static readonly PBRMATERIAL_OPAQUE: number;
  57222. /**
  57223. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57224. */
  57225. static readonly PBRMATERIAL_ALPHATEST: number;
  57226. /**
  57227. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57228. */
  57229. static readonly PBRMATERIAL_ALPHABLEND: number;
  57230. /**
  57231. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57232. * They are also discarded below the alpha cutoff threshold to improve performances.
  57233. */
  57234. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57235. /**
  57236. * Defines the default value of how much AO map is occluding the analytical lights
  57237. * (point spot...).
  57238. */
  57239. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57240. /**
  57241. * Intensity of the direct lights e.g. the four lights available in your scene.
  57242. * This impacts both the direct diffuse and specular highlights.
  57243. */
  57244. directIntensity: number;
  57245. /**
  57246. * Intensity of the emissive part of the material.
  57247. * This helps controlling the emissive effect without modifying the emissive color.
  57248. */
  57249. emissiveIntensity: number;
  57250. /**
  57251. * Intensity of the environment e.g. how much the environment will light the object
  57252. * either through harmonics for rough material or through the refelction for shiny ones.
  57253. */
  57254. environmentIntensity: number;
  57255. /**
  57256. * This is a special control allowing the reduction of the specular highlights coming from the
  57257. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57258. */
  57259. specularIntensity: number;
  57260. /**
  57261. * Debug Control allowing disabling the bump map on this material.
  57262. */
  57263. disableBumpMap: boolean;
  57264. /**
  57265. * AKA Diffuse Texture in standard nomenclature.
  57266. */
  57267. albedoTexture: BaseTexture;
  57268. /**
  57269. * AKA Occlusion Texture in other nomenclature.
  57270. */
  57271. ambientTexture: BaseTexture;
  57272. /**
  57273. * AKA Occlusion Texture Intensity in other nomenclature.
  57274. */
  57275. ambientTextureStrength: number;
  57276. /**
  57277. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57278. * 1 means it completely occludes it
  57279. * 0 mean it has no impact
  57280. */
  57281. ambientTextureImpactOnAnalyticalLights: number;
  57282. /**
  57283. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  57284. */
  57285. opacityTexture: BaseTexture;
  57286. /**
  57287. * Stores the reflection values in a texture.
  57288. */
  57289. reflectionTexture: Nullable<BaseTexture>;
  57290. /**
  57291. * Stores the emissive values in a texture.
  57292. */
  57293. emissiveTexture: BaseTexture;
  57294. /**
  57295. * AKA Specular texture in other nomenclature.
  57296. */
  57297. reflectivityTexture: BaseTexture;
  57298. /**
  57299. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57300. */
  57301. metallicTexture: BaseTexture;
  57302. /**
  57303. * Specifies the metallic scalar of the metallic/roughness workflow.
  57304. * Can also be used to scale the metalness values of the metallic texture.
  57305. */
  57306. metallic: Nullable<number>;
  57307. /**
  57308. * Specifies the roughness scalar of the metallic/roughness workflow.
  57309. * Can also be used to scale the roughness values of the metallic texture.
  57310. */
  57311. roughness: Nullable<number>;
  57312. /**
  57313. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57314. * By default the indexOfrefraction is used to compute F0;
  57315. *
  57316. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57317. *
  57318. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57319. * F90 = metallicReflectanceColor;
  57320. */
  57321. metallicF0Factor: number;
  57322. /**
  57323. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57324. * By default the F90 is always 1;
  57325. *
  57326. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57327. *
  57328. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57329. * F90 = metallicReflectanceColor;
  57330. */
  57331. metallicReflectanceColor: Color3;
  57332. /**
  57333. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57334. * This is multiply against the scalar values defined in the material.
  57335. */
  57336. metallicReflectanceTexture: Nullable<BaseTexture>;
  57337. /**
  57338. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57339. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57340. */
  57341. microSurfaceTexture: BaseTexture;
  57342. /**
  57343. * Stores surface normal data used to displace a mesh in a texture.
  57344. */
  57345. bumpTexture: BaseTexture;
  57346. /**
  57347. * Stores the pre-calculated light information of a mesh in a texture.
  57348. */
  57349. lightmapTexture: BaseTexture;
  57350. /**
  57351. * Stores the refracted light information in a texture.
  57352. */
  57353. get refractionTexture(): Nullable<BaseTexture>;
  57354. set refractionTexture(value: Nullable<BaseTexture>);
  57355. /**
  57356. * The color of a material in ambient lighting.
  57357. */
  57358. ambientColor: Color3;
  57359. /**
  57360. * AKA Diffuse Color in other nomenclature.
  57361. */
  57362. albedoColor: Color3;
  57363. /**
  57364. * AKA Specular Color in other nomenclature.
  57365. */
  57366. reflectivityColor: Color3;
  57367. /**
  57368. * The color reflected from the material.
  57369. */
  57370. reflectionColor: Color3;
  57371. /**
  57372. * The color emitted from the material.
  57373. */
  57374. emissiveColor: Color3;
  57375. /**
  57376. * AKA Glossiness in other nomenclature.
  57377. */
  57378. microSurface: number;
  57379. /**
  57380. * Index of refraction of the material base layer.
  57381. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57382. *
  57383. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57384. *
  57385. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57386. */
  57387. get indexOfRefraction(): number;
  57388. set indexOfRefraction(value: number);
  57389. /**
  57390. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57391. */
  57392. get invertRefractionY(): boolean;
  57393. set invertRefractionY(value: boolean);
  57394. /**
  57395. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57396. * Materials half opaque for instance using refraction could benefit from this control.
  57397. */
  57398. get linkRefractionWithTransparency(): boolean;
  57399. set linkRefractionWithTransparency(value: boolean);
  57400. /**
  57401. * If true, the light map contains occlusion information instead of lighting info.
  57402. */
  57403. useLightmapAsShadowmap: boolean;
  57404. /**
  57405. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57406. */
  57407. useAlphaFromAlbedoTexture: boolean;
  57408. /**
  57409. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57410. */
  57411. forceAlphaTest: boolean;
  57412. /**
  57413. * Defines the alpha limits in alpha test mode.
  57414. */
  57415. alphaCutOff: number;
  57416. /**
  57417. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  57418. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57419. */
  57420. useSpecularOverAlpha: boolean;
  57421. /**
  57422. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57423. */
  57424. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57425. /**
  57426. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57427. */
  57428. useRoughnessFromMetallicTextureAlpha: boolean;
  57429. /**
  57430. * Specifies if the metallic texture contains the roughness information in its green channel.
  57431. */
  57432. useRoughnessFromMetallicTextureGreen: boolean;
  57433. /**
  57434. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57435. */
  57436. useMetallnessFromMetallicTextureBlue: boolean;
  57437. /**
  57438. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57439. */
  57440. useAmbientOcclusionFromMetallicTextureRed: boolean;
  57441. /**
  57442. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57443. */
  57444. useAmbientInGrayScale: boolean;
  57445. /**
  57446. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57447. * The material will try to infer what glossiness each pixel should be.
  57448. */
  57449. useAutoMicroSurfaceFromReflectivityMap: boolean;
  57450. /**
  57451. * BJS is using an harcoded light falloff based on a manually sets up range.
  57452. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57453. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57454. */
  57455. get usePhysicalLightFalloff(): boolean;
  57456. /**
  57457. * BJS is using an harcoded light falloff based on a manually sets up range.
  57458. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57459. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57460. */
  57461. set usePhysicalLightFalloff(value: boolean);
  57462. /**
  57463. * In order to support the falloff compatibility with gltf, a special mode has been added
  57464. * to reproduce the gltf light falloff.
  57465. */
  57466. get useGLTFLightFalloff(): boolean;
  57467. /**
  57468. * In order to support the falloff compatibility with gltf, a special mode has been added
  57469. * to reproduce the gltf light falloff.
  57470. */
  57471. set useGLTFLightFalloff(value: boolean);
  57472. /**
  57473. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57474. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57475. */
  57476. useRadianceOverAlpha: boolean;
  57477. /**
  57478. * Allows using an object space normal map (instead of tangent space).
  57479. */
  57480. useObjectSpaceNormalMap: boolean;
  57481. /**
  57482. * Allows using the bump map in parallax mode.
  57483. */
  57484. useParallax: boolean;
  57485. /**
  57486. * Allows using the bump map in parallax occlusion mode.
  57487. */
  57488. useParallaxOcclusion: boolean;
  57489. /**
  57490. * Controls the scale bias of the parallax mode.
  57491. */
  57492. parallaxScaleBias: number;
  57493. /**
  57494. * If sets to true, disables all the lights affecting the material.
  57495. */
  57496. disableLighting: boolean;
  57497. /**
  57498. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57499. */
  57500. forceIrradianceInFragment: boolean;
  57501. /**
  57502. * Number of Simultaneous lights allowed on the material.
  57503. */
  57504. maxSimultaneousLights: number;
  57505. /**
  57506. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57507. */
  57508. invertNormalMapX: boolean;
  57509. /**
  57510. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57511. */
  57512. invertNormalMapY: boolean;
  57513. /**
  57514. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57515. */
  57516. twoSidedLighting: boolean;
  57517. /**
  57518. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57519. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57520. */
  57521. useAlphaFresnel: boolean;
  57522. /**
  57523. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57524. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57525. */
  57526. useLinearAlphaFresnel: boolean;
  57527. /**
  57528. * Let user defines the brdf lookup texture used for IBL.
  57529. * A default 8bit version is embedded but you could point at :
  57530. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  57531. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  57532. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  57533. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  57534. */
  57535. environmentBRDFTexture: Nullable<BaseTexture>;
  57536. /**
  57537. * Force normal to face away from face.
  57538. */
  57539. forceNormalForward: boolean;
  57540. /**
  57541. * Enables specular anti aliasing in the PBR shader.
  57542. * It will both interacts on the Geometry for analytical and IBL lighting.
  57543. * It also prefilter the roughness map based on the bump values.
  57544. */
  57545. enableSpecularAntiAliasing: boolean;
  57546. /**
  57547. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57548. * makes the reflect vector face the model (under horizon).
  57549. */
  57550. useHorizonOcclusion: boolean;
  57551. /**
  57552. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57553. * too much the area relying on ambient texture to define their ambient occlusion.
  57554. */
  57555. useRadianceOcclusion: boolean;
  57556. /**
  57557. * If set to true, no lighting calculations will be applied.
  57558. */
  57559. unlit: boolean;
  57560. /**
  57561. * Gets the image processing configuration used either in this material.
  57562. */
  57563. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57564. /**
  57565. * Sets the Default image processing configuration used either in the this material.
  57566. *
  57567. * If sets to null, the scene one is in use.
  57568. */
  57569. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57570. /**
  57571. * Gets wether the color curves effect is enabled.
  57572. */
  57573. get cameraColorCurvesEnabled(): boolean;
  57574. /**
  57575. * Sets wether the color curves effect is enabled.
  57576. */
  57577. set cameraColorCurvesEnabled(value: boolean);
  57578. /**
  57579. * Gets wether the color grading effect is enabled.
  57580. */
  57581. get cameraColorGradingEnabled(): boolean;
  57582. /**
  57583. * Gets wether the color grading effect is enabled.
  57584. */
  57585. set cameraColorGradingEnabled(value: boolean);
  57586. /**
  57587. * Gets wether tonemapping is enabled or not.
  57588. */
  57589. get cameraToneMappingEnabled(): boolean;
  57590. /**
  57591. * Sets wether tonemapping is enabled or not
  57592. */
  57593. set cameraToneMappingEnabled(value: boolean);
  57594. /**
  57595. * The camera exposure used on this material.
  57596. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57597. * This corresponds to a photographic exposure.
  57598. */
  57599. get cameraExposure(): number;
  57600. /**
  57601. * The camera exposure used on this material.
  57602. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57603. * This corresponds to a photographic exposure.
  57604. */
  57605. set cameraExposure(value: number);
  57606. /**
  57607. * Gets The camera contrast used on this material.
  57608. */
  57609. get cameraContrast(): number;
  57610. /**
  57611. * Sets The camera contrast used on this material.
  57612. */
  57613. set cameraContrast(value: number);
  57614. /**
  57615. * Gets the Color Grading 2D Lookup Texture.
  57616. */
  57617. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57618. /**
  57619. * Sets the Color Grading 2D Lookup Texture.
  57620. */
  57621. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57622. /**
  57623. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57624. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57625. * 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;
  57626. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57627. */
  57628. get cameraColorCurves(): Nullable<ColorCurves>;
  57629. /**
  57630. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57631. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57632. * 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;
  57633. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57634. */
  57635. set cameraColorCurves(value: Nullable<ColorCurves>);
  57636. /**
  57637. * Instantiates a new PBRMaterial instance.
  57638. *
  57639. * @param name The material name
  57640. * @param scene The scene the material will be use in.
  57641. */
  57642. constructor(name: string, scene: Scene);
  57643. /**
  57644. * Returns the name of this material class.
  57645. */
  57646. getClassName(): string;
  57647. /**
  57648. * Makes a duplicate of the current material.
  57649. * @param name - name to use for the new material.
  57650. */
  57651. clone(name: string): PBRMaterial;
  57652. /**
  57653. * Serializes this PBR Material.
  57654. * @returns - An object with the serialized material.
  57655. */
  57656. serialize(): any;
  57657. /**
  57658. * Parses a PBR Material from a serialized object.
  57659. * @param source - Serialized object.
  57660. * @param scene - BJS scene instance.
  57661. * @param rootUrl - url for the scene object
  57662. * @returns - PBRMaterial
  57663. */
  57664. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  57665. }
  57666. }
  57667. declare module BABYLON {
  57668. /**
  57669. * Direct draw surface info
  57670. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  57671. */
  57672. export interface DDSInfo {
  57673. /**
  57674. * Width of the texture
  57675. */
  57676. width: number;
  57677. /**
  57678. * Width of the texture
  57679. */
  57680. height: number;
  57681. /**
  57682. * Number of Mipmaps for the texture
  57683. * @see https://en.wikipedia.org/wiki/Mipmap
  57684. */
  57685. mipmapCount: number;
  57686. /**
  57687. * If the textures format is a known fourCC format
  57688. * @see https://www.fourcc.org/
  57689. */
  57690. isFourCC: boolean;
  57691. /**
  57692. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  57693. */
  57694. isRGB: boolean;
  57695. /**
  57696. * If the texture is a lumincance format
  57697. */
  57698. isLuminance: boolean;
  57699. /**
  57700. * If this is a cube texture
  57701. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  57702. */
  57703. isCube: boolean;
  57704. /**
  57705. * If the texture is a compressed format eg. FOURCC_DXT1
  57706. */
  57707. isCompressed: boolean;
  57708. /**
  57709. * The dxgiFormat of the texture
  57710. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  57711. */
  57712. dxgiFormat: number;
  57713. /**
  57714. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  57715. */
  57716. textureType: number;
  57717. /**
  57718. * Sphericle polynomial created for the dds texture
  57719. */
  57720. sphericalPolynomial?: SphericalPolynomial;
  57721. }
  57722. /**
  57723. * Class used to provide DDS decompression tools
  57724. */
  57725. export class DDSTools {
  57726. /**
  57727. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  57728. */
  57729. static StoreLODInAlphaChannel: boolean;
  57730. /**
  57731. * Gets DDS information from an array buffer
  57732. * @param data defines the array buffer view to read data from
  57733. * @returns the DDS information
  57734. */
  57735. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  57736. private static _FloatView;
  57737. private static _Int32View;
  57738. private static _ToHalfFloat;
  57739. private static _FromHalfFloat;
  57740. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  57741. private static _GetHalfFloatRGBAArrayBuffer;
  57742. private static _GetFloatRGBAArrayBuffer;
  57743. private static _GetFloatAsUIntRGBAArrayBuffer;
  57744. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  57745. private static _GetRGBAArrayBuffer;
  57746. private static _ExtractLongWordOrder;
  57747. private static _GetRGBArrayBuffer;
  57748. private static _GetLuminanceArrayBuffer;
  57749. /**
  57750. * Uploads DDS Levels to a Babylon Texture
  57751. * @hidden
  57752. */
  57753. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  57754. }
  57755. interface ThinEngine {
  57756. /**
  57757. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  57758. * @param rootUrl defines the url where the file to load is located
  57759. * @param scene defines the current scene
  57760. * @param lodScale defines scale to apply to the mip map selection
  57761. * @param lodOffset defines offset to apply to the mip map selection
  57762. * @param onLoad defines an optional callback raised when the texture is loaded
  57763. * @param onError defines an optional callback raised if there is an issue to load the texture
  57764. * @param format defines the format of the data
  57765. * @param forcedExtension defines the extension to use to pick the right loader
  57766. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  57767. * @returns the cube texture as an InternalTexture
  57768. */
  57769. 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;
  57770. }
  57771. }
  57772. declare module BABYLON {
  57773. /**
  57774. * Implementation of the DDS Texture Loader.
  57775. * @hidden
  57776. */
  57777. export class _DDSTextureLoader implements IInternalTextureLoader {
  57778. /**
  57779. * Defines wether the loader supports cascade loading the different faces.
  57780. */
  57781. readonly supportCascades: boolean;
  57782. /**
  57783. * This returns if the loader support the current file information.
  57784. * @param extension defines the file extension of the file being loaded
  57785. * @returns true if the loader can load the specified file
  57786. */
  57787. canLoad(extension: string): boolean;
  57788. /**
  57789. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57790. * @param data contains the texture data
  57791. * @param texture defines the BabylonJS internal texture
  57792. * @param createPolynomials will be true if polynomials have been requested
  57793. * @param onLoad defines the callback to trigger once the texture is ready
  57794. * @param onError defines the callback to trigger in case of error
  57795. */
  57796. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57797. /**
  57798. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57799. * @param data contains the texture data
  57800. * @param texture defines the BabylonJS internal texture
  57801. * @param callback defines the method to call once ready to upload
  57802. */
  57803. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57804. }
  57805. }
  57806. declare module BABYLON {
  57807. /**
  57808. * Implementation of the ENV Texture Loader.
  57809. * @hidden
  57810. */
  57811. export class _ENVTextureLoader implements IInternalTextureLoader {
  57812. /**
  57813. * Defines wether the loader supports cascade loading the different faces.
  57814. */
  57815. readonly supportCascades: boolean;
  57816. /**
  57817. * This returns if the loader support the current file information.
  57818. * @param extension defines the file extension of the file being loaded
  57819. * @returns true if the loader can load the specified file
  57820. */
  57821. canLoad(extension: string): boolean;
  57822. /**
  57823. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57824. * @param data contains the texture data
  57825. * @param texture defines the BabylonJS internal texture
  57826. * @param createPolynomials will be true if polynomials have been requested
  57827. * @param onLoad defines the callback to trigger once the texture is ready
  57828. * @param onError defines the callback to trigger in case of error
  57829. */
  57830. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57831. /**
  57832. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57833. * @param data contains the texture data
  57834. * @param texture defines the BabylonJS internal texture
  57835. * @param callback defines the method to call once ready to upload
  57836. */
  57837. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57838. }
  57839. }
  57840. declare module BABYLON {
  57841. /**
  57842. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57843. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57844. */
  57845. export class KhronosTextureContainer {
  57846. /** contents of the KTX container file */
  57847. data: ArrayBufferView;
  57848. private static HEADER_LEN;
  57849. private static COMPRESSED_2D;
  57850. private static COMPRESSED_3D;
  57851. private static TEX_2D;
  57852. private static TEX_3D;
  57853. /**
  57854. * Gets the openGL type
  57855. */
  57856. glType: number;
  57857. /**
  57858. * Gets the openGL type size
  57859. */
  57860. glTypeSize: number;
  57861. /**
  57862. * Gets the openGL format
  57863. */
  57864. glFormat: number;
  57865. /**
  57866. * Gets the openGL internal format
  57867. */
  57868. glInternalFormat: number;
  57869. /**
  57870. * Gets the base internal format
  57871. */
  57872. glBaseInternalFormat: number;
  57873. /**
  57874. * Gets image width in pixel
  57875. */
  57876. pixelWidth: number;
  57877. /**
  57878. * Gets image height in pixel
  57879. */
  57880. pixelHeight: number;
  57881. /**
  57882. * Gets image depth in pixels
  57883. */
  57884. pixelDepth: number;
  57885. /**
  57886. * Gets the number of array elements
  57887. */
  57888. numberOfArrayElements: number;
  57889. /**
  57890. * Gets the number of faces
  57891. */
  57892. numberOfFaces: number;
  57893. /**
  57894. * Gets the number of mipmap levels
  57895. */
  57896. numberOfMipmapLevels: number;
  57897. /**
  57898. * Gets the bytes of key value data
  57899. */
  57900. bytesOfKeyValueData: number;
  57901. /**
  57902. * Gets the load type
  57903. */
  57904. loadType: number;
  57905. /**
  57906. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  57907. */
  57908. isInvalid: boolean;
  57909. /**
  57910. * Creates a new KhronosTextureContainer
  57911. * @param data contents of the KTX container file
  57912. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  57913. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  57914. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  57915. */
  57916. constructor(
  57917. /** contents of the KTX container file */
  57918. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  57919. /**
  57920. * Uploads KTX content to a Babylon Texture.
  57921. * It is assumed that the texture has already been created & is currently bound
  57922. * @hidden
  57923. */
  57924. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  57925. private _upload2DCompressedLevels;
  57926. /**
  57927. * Checks if the given data starts with a KTX file identifier.
  57928. * @param data the data to check
  57929. * @returns true if the data is a KTX file or false otherwise
  57930. */
  57931. static IsValid(data: ArrayBufferView): boolean;
  57932. }
  57933. }
  57934. declare module BABYLON {
  57935. /**
  57936. * Helper class to push actions to a pool of workers.
  57937. */
  57938. export class WorkerPool implements IDisposable {
  57939. private _workerInfos;
  57940. private _pendingActions;
  57941. /**
  57942. * Constructor
  57943. * @param workers Array of workers to use for actions
  57944. */
  57945. constructor(workers: Array<Worker>);
  57946. /**
  57947. * Terminates all workers and clears any pending actions.
  57948. */
  57949. dispose(): void;
  57950. /**
  57951. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57952. * pended until a worker has completed its action.
  57953. * @param action The action to perform. Call onComplete when the action is complete.
  57954. */
  57955. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57956. private _execute;
  57957. }
  57958. }
  57959. declare module BABYLON {
  57960. /**
  57961. * Class for loading KTX2 files
  57962. * @hidden
  57963. */
  57964. export class KhronosTextureContainer2 {
  57965. private static _WorkerPoolPromise?;
  57966. private static _Initialized;
  57967. private static _Ktx2Decoder;
  57968. /**
  57969. * URL to use when loading the KTX2 decoder module
  57970. */
  57971. static JSModuleURL: string;
  57972. /**
  57973. * Default number of workers used to handle data decoding
  57974. */
  57975. static DefaultNumWorkers: number;
  57976. private static GetDefaultNumWorkers;
  57977. private _engine;
  57978. private static _CreateWorkerPool;
  57979. /**
  57980. * Constructor
  57981. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  57982. */
  57983. constructor(engine: ThinEngine, numWorkers?: number);
  57984. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  57985. /**
  57986. * Stop all async operations and release resources.
  57987. */
  57988. dispose(): void;
  57989. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  57990. /**
  57991. * Checks if the given data starts with a KTX2 file identifier.
  57992. * @param data the data to check
  57993. * @returns true if the data is a KTX2 file or false otherwise
  57994. */
  57995. static IsValid(data: ArrayBufferView): boolean;
  57996. }
  57997. export function workerFunc(): void;
  57998. }
  57999. declare module BABYLON {
  58000. /**
  58001. * Implementation of the KTX Texture Loader.
  58002. * @hidden
  58003. */
  58004. export class _KTXTextureLoader implements IInternalTextureLoader {
  58005. /**
  58006. * Defines wether the loader supports cascade loading the different faces.
  58007. */
  58008. readonly supportCascades: boolean;
  58009. /**
  58010. * This returns if the loader support the current file information.
  58011. * @param extension defines the file extension of the file being loaded
  58012. * @param mimeType defines the optional mime type of the file being loaded
  58013. * @returns true if the loader can load the specified file
  58014. */
  58015. canLoad(extension: string, mimeType?: string): boolean;
  58016. /**
  58017. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58018. * @param data contains the texture data
  58019. * @param texture defines the BabylonJS internal texture
  58020. * @param createPolynomials will be true if polynomials have been requested
  58021. * @param onLoad defines the callback to trigger once the texture is ready
  58022. * @param onError defines the callback to trigger in case of error
  58023. */
  58024. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58025. /**
  58026. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58027. * @param data contains the texture data
  58028. * @param texture defines the BabylonJS internal texture
  58029. * @param callback defines the method to call once ready to upload
  58030. */
  58031. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  58032. }
  58033. }
  58034. declare module BABYLON {
  58035. /** @hidden */
  58036. export var _forceSceneHelpersToBundle: boolean;
  58037. interface Scene {
  58038. /**
  58039. * Creates a default light for the scene.
  58040. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58041. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58042. */
  58043. createDefaultLight(replace?: boolean): void;
  58044. /**
  58045. * Creates a default camera for the scene.
  58046. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58047. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58048. * @param replace has default false, when true replaces the active camera in the scene
  58049. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58050. */
  58051. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58052. /**
  58053. * Creates a default camera and a default light.
  58054. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58055. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58056. * @param replace has the default false, when true replaces the active camera/light in the scene
  58057. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58058. */
  58059. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58060. /**
  58061. * Creates a new sky box
  58062. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58063. * @param environmentTexture defines the texture to use as environment texture
  58064. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58065. * @param scale defines the overall scale of the skybox
  58066. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58067. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58068. * @returns a new mesh holding the sky box
  58069. */
  58070. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58071. /**
  58072. * Creates a new environment
  58073. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58074. * @param options defines the options you can use to configure the environment
  58075. * @returns the new EnvironmentHelper
  58076. */
  58077. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58078. /**
  58079. * Creates a new VREXperienceHelper
  58080. * @see https://doc.babylonjs.com/how_to/webvr_helper
  58081. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58082. * @returns a new VREXperienceHelper
  58083. */
  58084. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58085. /**
  58086. * Creates a new WebXRDefaultExperience
  58087. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  58088. * @param options experience options
  58089. * @returns a promise for a new WebXRDefaultExperience
  58090. */
  58091. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58092. }
  58093. }
  58094. declare module BABYLON {
  58095. /**
  58096. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  58097. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  58098. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  58099. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58100. */
  58101. export class VideoDome extends TextureDome<VideoTexture> {
  58102. /**
  58103. * Define the video source as a Monoscopic panoramic 360 video.
  58104. */
  58105. static readonly MODE_MONOSCOPIC: number;
  58106. /**
  58107. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58108. */
  58109. static readonly MODE_TOPBOTTOM: number;
  58110. /**
  58111. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58112. */
  58113. static readonly MODE_SIDEBYSIDE: number;
  58114. /**
  58115. * Get the video texture associated with this video dome
  58116. */
  58117. get videoTexture(): VideoTexture;
  58118. /**
  58119. * Get the video mode of this dome
  58120. */
  58121. get videoMode(): number;
  58122. /**
  58123. * Set the video mode of this dome.
  58124. * @see textureMode
  58125. */
  58126. set videoMode(value: number);
  58127. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  58128. }
  58129. }
  58130. declare module BABYLON {
  58131. /**
  58132. * This class can be used to get instrumentation data from a Babylon engine
  58133. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58134. */
  58135. export class EngineInstrumentation implements IDisposable {
  58136. /**
  58137. * Define the instrumented engine.
  58138. */
  58139. engine: Engine;
  58140. private _captureGPUFrameTime;
  58141. private _gpuFrameTimeToken;
  58142. private _gpuFrameTime;
  58143. private _captureShaderCompilationTime;
  58144. private _shaderCompilationTime;
  58145. private _onBeginFrameObserver;
  58146. private _onEndFrameObserver;
  58147. private _onBeforeShaderCompilationObserver;
  58148. private _onAfterShaderCompilationObserver;
  58149. /**
  58150. * Gets the perf counter used for GPU frame time
  58151. */
  58152. get gpuFrameTimeCounter(): PerfCounter;
  58153. /**
  58154. * Gets the GPU frame time capture status
  58155. */
  58156. get captureGPUFrameTime(): boolean;
  58157. /**
  58158. * Enable or disable the GPU frame time capture
  58159. */
  58160. set captureGPUFrameTime(value: boolean);
  58161. /**
  58162. * Gets the perf counter used for shader compilation time
  58163. */
  58164. get shaderCompilationTimeCounter(): PerfCounter;
  58165. /**
  58166. * Gets the shader compilation time capture status
  58167. */
  58168. get captureShaderCompilationTime(): boolean;
  58169. /**
  58170. * Enable or disable the shader compilation time capture
  58171. */
  58172. set captureShaderCompilationTime(value: boolean);
  58173. /**
  58174. * Instantiates a new engine instrumentation.
  58175. * This class can be used to get instrumentation data from a Babylon engine
  58176. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58177. * @param engine Defines the engine to instrument
  58178. */
  58179. constructor(
  58180. /**
  58181. * Define the instrumented engine.
  58182. */
  58183. engine: Engine);
  58184. /**
  58185. * Dispose and release associated resources.
  58186. */
  58187. dispose(): void;
  58188. }
  58189. }
  58190. declare module BABYLON {
  58191. /**
  58192. * This class can be used to get instrumentation data from a Babylon engine
  58193. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58194. */
  58195. export class SceneInstrumentation implements IDisposable {
  58196. /**
  58197. * Defines the scene to instrument
  58198. */
  58199. scene: Scene;
  58200. private _captureActiveMeshesEvaluationTime;
  58201. private _activeMeshesEvaluationTime;
  58202. private _captureRenderTargetsRenderTime;
  58203. private _renderTargetsRenderTime;
  58204. private _captureFrameTime;
  58205. private _frameTime;
  58206. private _captureRenderTime;
  58207. private _renderTime;
  58208. private _captureInterFrameTime;
  58209. private _interFrameTime;
  58210. private _captureParticlesRenderTime;
  58211. private _particlesRenderTime;
  58212. private _captureSpritesRenderTime;
  58213. private _spritesRenderTime;
  58214. private _capturePhysicsTime;
  58215. private _physicsTime;
  58216. private _captureAnimationsTime;
  58217. private _animationsTime;
  58218. private _captureCameraRenderTime;
  58219. private _cameraRenderTime;
  58220. private _onBeforeActiveMeshesEvaluationObserver;
  58221. private _onAfterActiveMeshesEvaluationObserver;
  58222. private _onBeforeRenderTargetsRenderObserver;
  58223. private _onAfterRenderTargetsRenderObserver;
  58224. private _onAfterRenderObserver;
  58225. private _onBeforeDrawPhaseObserver;
  58226. private _onAfterDrawPhaseObserver;
  58227. private _onBeforeAnimationsObserver;
  58228. private _onBeforeParticlesRenderingObserver;
  58229. private _onAfterParticlesRenderingObserver;
  58230. private _onBeforeSpritesRenderingObserver;
  58231. private _onAfterSpritesRenderingObserver;
  58232. private _onBeforePhysicsObserver;
  58233. private _onAfterPhysicsObserver;
  58234. private _onAfterAnimationsObserver;
  58235. private _onBeforeCameraRenderObserver;
  58236. private _onAfterCameraRenderObserver;
  58237. /**
  58238. * Gets the perf counter used for active meshes evaluation time
  58239. */
  58240. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  58241. /**
  58242. * Gets the active meshes evaluation time capture status
  58243. */
  58244. get captureActiveMeshesEvaluationTime(): boolean;
  58245. /**
  58246. * Enable or disable the active meshes evaluation time capture
  58247. */
  58248. set captureActiveMeshesEvaluationTime(value: boolean);
  58249. /**
  58250. * Gets the perf counter used for render targets render time
  58251. */
  58252. get renderTargetsRenderTimeCounter(): PerfCounter;
  58253. /**
  58254. * Gets the render targets render time capture status
  58255. */
  58256. get captureRenderTargetsRenderTime(): boolean;
  58257. /**
  58258. * Enable or disable the render targets render time capture
  58259. */
  58260. set captureRenderTargetsRenderTime(value: boolean);
  58261. /**
  58262. * Gets the perf counter used for particles render time
  58263. */
  58264. get particlesRenderTimeCounter(): PerfCounter;
  58265. /**
  58266. * Gets the particles render time capture status
  58267. */
  58268. get captureParticlesRenderTime(): boolean;
  58269. /**
  58270. * Enable or disable the particles render time capture
  58271. */
  58272. set captureParticlesRenderTime(value: boolean);
  58273. /**
  58274. * Gets the perf counter used for sprites render time
  58275. */
  58276. get spritesRenderTimeCounter(): PerfCounter;
  58277. /**
  58278. * Gets the sprites render time capture status
  58279. */
  58280. get captureSpritesRenderTime(): boolean;
  58281. /**
  58282. * Enable or disable the sprites render time capture
  58283. */
  58284. set captureSpritesRenderTime(value: boolean);
  58285. /**
  58286. * Gets the perf counter used for physics time
  58287. */
  58288. get physicsTimeCounter(): PerfCounter;
  58289. /**
  58290. * Gets the physics time capture status
  58291. */
  58292. get capturePhysicsTime(): boolean;
  58293. /**
  58294. * Enable or disable the physics time capture
  58295. */
  58296. set capturePhysicsTime(value: boolean);
  58297. /**
  58298. * Gets the perf counter used for animations time
  58299. */
  58300. get animationsTimeCounter(): PerfCounter;
  58301. /**
  58302. * Gets the animations time capture status
  58303. */
  58304. get captureAnimationsTime(): boolean;
  58305. /**
  58306. * Enable or disable the animations time capture
  58307. */
  58308. set captureAnimationsTime(value: boolean);
  58309. /**
  58310. * Gets the perf counter used for frame time capture
  58311. */
  58312. get frameTimeCounter(): PerfCounter;
  58313. /**
  58314. * Gets the frame time capture status
  58315. */
  58316. get captureFrameTime(): boolean;
  58317. /**
  58318. * Enable or disable the frame time capture
  58319. */
  58320. set captureFrameTime(value: boolean);
  58321. /**
  58322. * Gets the perf counter used for inter-frames time capture
  58323. */
  58324. get interFrameTimeCounter(): PerfCounter;
  58325. /**
  58326. * Gets the inter-frames time capture status
  58327. */
  58328. get captureInterFrameTime(): boolean;
  58329. /**
  58330. * Enable or disable the inter-frames time capture
  58331. */
  58332. set captureInterFrameTime(value: boolean);
  58333. /**
  58334. * Gets the perf counter used for render time capture
  58335. */
  58336. get renderTimeCounter(): PerfCounter;
  58337. /**
  58338. * Gets the render time capture status
  58339. */
  58340. get captureRenderTime(): boolean;
  58341. /**
  58342. * Enable or disable the render time capture
  58343. */
  58344. set captureRenderTime(value: boolean);
  58345. /**
  58346. * Gets the perf counter used for camera render time capture
  58347. */
  58348. get cameraRenderTimeCounter(): PerfCounter;
  58349. /**
  58350. * Gets the camera render time capture status
  58351. */
  58352. get captureCameraRenderTime(): boolean;
  58353. /**
  58354. * Enable or disable the camera render time capture
  58355. */
  58356. set captureCameraRenderTime(value: boolean);
  58357. /**
  58358. * Gets the perf counter used for draw calls
  58359. */
  58360. get drawCallsCounter(): PerfCounter;
  58361. /**
  58362. * Instantiates a new scene instrumentation.
  58363. * This class can be used to get instrumentation data from a Babylon engine
  58364. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58365. * @param scene Defines the scene to instrument
  58366. */
  58367. constructor(
  58368. /**
  58369. * Defines the scene to instrument
  58370. */
  58371. scene: Scene);
  58372. /**
  58373. * Dispose and release associated resources.
  58374. */
  58375. dispose(): void;
  58376. }
  58377. }
  58378. declare module BABYLON {
  58379. /** @hidden */
  58380. export var glowMapGenerationPixelShader: {
  58381. name: string;
  58382. shader: string;
  58383. };
  58384. }
  58385. declare module BABYLON {
  58386. /** @hidden */
  58387. export var glowMapGenerationVertexShader: {
  58388. name: string;
  58389. shader: string;
  58390. };
  58391. }
  58392. declare module BABYLON {
  58393. /**
  58394. * Effect layer options. This helps customizing the behaviour
  58395. * of the effect layer.
  58396. */
  58397. export interface IEffectLayerOptions {
  58398. /**
  58399. * Multiplication factor apply to the canvas size to compute the render target size
  58400. * used to generated the objects (the smaller the faster).
  58401. */
  58402. mainTextureRatio: number;
  58403. /**
  58404. * Enforces a fixed size texture to ensure effect stability across devices.
  58405. */
  58406. mainTextureFixedSize?: number;
  58407. /**
  58408. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  58409. */
  58410. alphaBlendingMode: number;
  58411. /**
  58412. * The camera attached to the layer.
  58413. */
  58414. camera: Nullable<Camera>;
  58415. /**
  58416. * The rendering group to draw the layer in.
  58417. */
  58418. renderingGroupId: number;
  58419. }
  58420. /**
  58421. * The effect layer Helps adding post process effect blended with the main pass.
  58422. *
  58423. * This can be for instance use to generate glow or higlight effects on the scene.
  58424. *
  58425. * The effect layer class can not be used directly and is intented to inherited from to be
  58426. * customized per effects.
  58427. */
  58428. export abstract class EffectLayer {
  58429. private _vertexBuffers;
  58430. private _indexBuffer;
  58431. private _cachedDefines;
  58432. private _effectLayerMapGenerationEffect;
  58433. private _effectLayerOptions;
  58434. private _mergeEffect;
  58435. protected _scene: Scene;
  58436. protected _engine: Engine;
  58437. protected _maxSize: number;
  58438. protected _mainTextureDesiredSize: ISize;
  58439. protected _mainTexture: RenderTargetTexture;
  58440. protected _shouldRender: boolean;
  58441. protected _postProcesses: PostProcess[];
  58442. protected _textures: BaseTexture[];
  58443. protected _emissiveTextureAndColor: {
  58444. texture: Nullable<BaseTexture>;
  58445. color: Color4;
  58446. };
  58447. /**
  58448. * The name of the layer
  58449. */
  58450. name: string;
  58451. /**
  58452. * The clear color of the texture used to generate the glow map.
  58453. */
  58454. neutralColor: Color4;
  58455. /**
  58456. * Specifies whether the highlight layer is enabled or not.
  58457. */
  58458. isEnabled: boolean;
  58459. /**
  58460. * Gets the camera attached to the layer.
  58461. */
  58462. get camera(): Nullable<Camera>;
  58463. /**
  58464. * Gets the rendering group id the layer should render in.
  58465. */
  58466. get renderingGroupId(): number;
  58467. set renderingGroupId(renderingGroupId: number);
  58468. /**
  58469. * An event triggered when the effect layer has been disposed.
  58470. */
  58471. onDisposeObservable: Observable<EffectLayer>;
  58472. /**
  58473. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  58474. */
  58475. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  58476. /**
  58477. * An event triggered when the generated texture is being merged in the scene.
  58478. */
  58479. onBeforeComposeObservable: Observable<EffectLayer>;
  58480. /**
  58481. * An event triggered when the mesh is rendered into the effect render target.
  58482. */
  58483. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  58484. /**
  58485. * An event triggered after the mesh has been rendered into the effect render target.
  58486. */
  58487. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  58488. /**
  58489. * An event triggered when the generated texture has been merged in the scene.
  58490. */
  58491. onAfterComposeObservable: Observable<EffectLayer>;
  58492. /**
  58493. * An event triggered when the efffect layer changes its size.
  58494. */
  58495. onSizeChangedObservable: Observable<EffectLayer>;
  58496. /** @hidden */
  58497. static _SceneComponentInitialization: (scene: Scene) => void;
  58498. /**
  58499. * Instantiates a new effect Layer and references it in the scene.
  58500. * @param name The name of the layer
  58501. * @param scene The scene to use the layer in
  58502. */
  58503. constructor(
  58504. /** The Friendly of the effect in the scene */
  58505. name: string, scene: Scene);
  58506. /**
  58507. * Get the effect name of the layer.
  58508. * @return The effect name
  58509. */
  58510. abstract getEffectName(): string;
  58511. /**
  58512. * Checks for the readiness of the element composing the layer.
  58513. * @param subMesh the mesh to check for
  58514. * @param useInstances specify whether or not to use instances to render the mesh
  58515. * @return true if ready otherwise, false
  58516. */
  58517. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58518. /**
  58519. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58520. * @returns true if the effect requires stencil during the main canvas render pass.
  58521. */
  58522. abstract needStencil(): boolean;
  58523. /**
  58524. * Create the merge effect. This is the shader use to blit the information back
  58525. * to the main canvas at the end of the scene rendering.
  58526. * @returns The effect containing the shader used to merge the effect on the main canvas
  58527. */
  58528. protected abstract _createMergeEffect(): Effect;
  58529. /**
  58530. * Creates the render target textures and post processes used in the effect layer.
  58531. */
  58532. protected abstract _createTextureAndPostProcesses(): void;
  58533. /**
  58534. * Implementation specific of rendering the generating effect on the main canvas.
  58535. * @param effect The effect used to render through
  58536. */
  58537. protected abstract _internalRender(effect: Effect): void;
  58538. /**
  58539. * Sets the required values for both the emissive texture and and the main color.
  58540. */
  58541. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58542. /**
  58543. * Free any resources and references associated to a mesh.
  58544. * Internal use
  58545. * @param mesh The mesh to free.
  58546. */
  58547. abstract _disposeMesh(mesh: Mesh): void;
  58548. /**
  58549. * Serializes this layer (Glow or Highlight for example)
  58550. * @returns a serialized layer object
  58551. */
  58552. abstract serialize?(): any;
  58553. /**
  58554. * Initializes the effect layer with the required options.
  58555. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  58556. */
  58557. protected _init(options: Partial<IEffectLayerOptions>): void;
  58558. /**
  58559. * Generates the index buffer of the full screen quad blending to the main canvas.
  58560. */
  58561. private _generateIndexBuffer;
  58562. /**
  58563. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  58564. */
  58565. private _generateVertexBuffer;
  58566. /**
  58567. * Sets the main texture desired size which is the closest power of two
  58568. * of the engine canvas size.
  58569. */
  58570. private _setMainTextureSize;
  58571. /**
  58572. * Creates the main texture for the effect layer.
  58573. */
  58574. protected _createMainTexture(): void;
  58575. /**
  58576. * Adds specific effects defines.
  58577. * @param defines The defines to add specifics to.
  58578. */
  58579. protected _addCustomEffectDefines(defines: string[]): void;
  58580. /**
  58581. * Checks for the readiness of the element composing the layer.
  58582. * @param subMesh the mesh to check for
  58583. * @param useInstances specify whether or not to use instances to render the mesh
  58584. * @param emissiveTexture the associated emissive texture used to generate the glow
  58585. * @return true if ready otherwise, false
  58586. */
  58587. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  58588. /**
  58589. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  58590. */
  58591. render(): void;
  58592. /**
  58593. * Determine if a given mesh will be used in the current effect.
  58594. * @param mesh mesh to test
  58595. * @returns true if the mesh will be used
  58596. */
  58597. hasMesh(mesh: AbstractMesh): boolean;
  58598. /**
  58599. * Returns true if the layer contains information to display, otherwise false.
  58600. * @returns true if the glow layer should be rendered
  58601. */
  58602. shouldRender(): boolean;
  58603. /**
  58604. * Returns true if the mesh should render, otherwise false.
  58605. * @param mesh The mesh to render
  58606. * @returns true if it should render otherwise false
  58607. */
  58608. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  58609. /**
  58610. * Returns true if the mesh can be rendered, otherwise false.
  58611. * @param mesh The mesh to render
  58612. * @param material The material used on the mesh
  58613. * @returns true if it can be rendered otherwise false
  58614. */
  58615. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58616. /**
  58617. * Returns true if the mesh should render, otherwise false.
  58618. * @param mesh The mesh to render
  58619. * @returns true if it should render otherwise false
  58620. */
  58621. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  58622. /**
  58623. * Renders the submesh passed in parameter to the generation map.
  58624. */
  58625. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  58626. /**
  58627. * Defines whether the current material of the mesh should be use to render the effect.
  58628. * @param mesh defines the current mesh to render
  58629. */
  58630. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58631. /**
  58632. * Rebuild the required buffers.
  58633. * @hidden Internal use only.
  58634. */
  58635. _rebuild(): void;
  58636. /**
  58637. * Dispose only the render target textures and post process.
  58638. */
  58639. private _disposeTextureAndPostProcesses;
  58640. /**
  58641. * Dispose the highlight layer and free resources.
  58642. */
  58643. dispose(): void;
  58644. /**
  58645. * Gets the class name of the effect layer
  58646. * @returns the string with the class name of the effect layer
  58647. */
  58648. getClassName(): string;
  58649. /**
  58650. * Creates an effect layer from parsed effect layer data
  58651. * @param parsedEffectLayer defines effect layer data
  58652. * @param scene defines the current scene
  58653. * @param rootUrl defines the root URL containing the effect layer information
  58654. * @returns a parsed effect Layer
  58655. */
  58656. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  58657. }
  58658. }
  58659. declare module BABYLON {
  58660. interface AbstractScene {
  58661. /**
  58662. * The list of effect layers (highlights/glow) added to the scene
  58663. * @see https://doc.babylonjs.com/how_to/highlight_layer
  58664. * @see https://doc.babylonjs.com/how_to/glow_layer
  58665. */
  58666. effectLayers: Array<EffectLayer>;
  58667. /**
  58668. * Removes the given effect layer from this scene.
  58669. * @param toRemove defines the effect layer to remove
  58670. * @returns the index of the removed effect layer
  58671. */
  58672. removeEffectLayer(toRemove: EffectLayer): number;
  58673. /**
  58674. * Adds the given effect layer to this scene
  58675. * @param newEffectLayer defines the effect layer to add
  58676. */
  58677. addEffectLayer(newEffectLayer: EffectLayer): void;
  58678. }
  58679. /**
  58680. * Defines the layer scene component responsible to manage any effect layers
  58681. * in a given scene.
  58682. */
  58683. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  58684. /**
  58685. * The component name helpfull to identify the component in the list of scene components.
  58686. */
  58687. readonly name: string;
  58688. /**
  58689. * The scene the component belongs to.
  58690. */
  58691. scene: Scene;
  58692. private _engine;
  58693. private _renderEffects;
  58694. private _needStencil;
  58695. private _previousStencilState;
  58696. /**
  58697. * Creates a new instance of the component for the given scene
  58698. * @param scene Defines the scene to register the component in
  58699. */
  58700. constructor(scene: Scene);
  58701. /**
  58702. * Registers the component in a given scene
  58703. */
  58704. register(): void;
  58705. /**
  58706. * Rebuilds the elements related to this component in case of
  58707. * context lost for instance.
  58708. */
  58709. rebuild(): void;
  58710. /**
  58711. * Serializes the component data to the specified json object
  58712. * @param serializationObject The object to serialize to
  58713. */
  58714. serialize(serializationObject: any): void;
  58715. /**
  58716. * Adds all the elements from the container to the scene
  58717. * @param container the container holding the elements
  58718. */
  58719. addFromContainer(container: AbstractScene): void;
  58720. /**
  58721. * Removes all the elements in the container from the scene
  58722. * @param container contains the elements to remove
  58723. * @param dispose if the removed element should be disposed (default: false)
  58724. */
  58725. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58726. /**
  58727. * Disposes the component and the associated ressources.
  58728. */
  58729. dispose(): void;
  58730. private _isReadyForMesh;
  58731. private _renderMainTexture;
  58732. private _setStencil;
  58733. private _setStencilBack;
  58734. private _draw;
  58735. private _drawCamera;
  58736. private _drawRenderingGroup;
  58737. }
  58738. }
  58739. declare module BABYLON {
  58740. /** @hidden */
  58741. export var glowMapMergePixelShader: {
  58742. name: string;
  58743. shader: string;
  58744. };
  58745. }
  58746. declare module BABYLON {
  58747. /** @hidden */
  58748. export var glowMapMergeVertexShader: {
  58749. name: string;
  58750. shader: string;
  58751. };
  58752. }
  58753. declare module BABYLON {
  58754. interface AbstractScene {
  58755. /**
  58756. * Return a the first highlight layer of the scene with a given name.
  58757. * @param name The name of the highlight layer to look for.
  58758. * @return The highlight layer if found otherwise null.
  58759. */
  58760. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  58761. }
  58762. /**
  58763. * Glow layer options. This helps customizing the behaviour
  58764. * of the glow layer.
  58765. */
  58766. export interface IGlowLayerOptions {
  58767. /**
  58768. * Multiplication factor apply to the canvas size to compute the render target size
  58769. * used to generated the glowing objects (the smaller the faster).
  58770. */
  58771. mainTextureRatio: number;
  58772. /**
  58773. * Enforces a fixed size texture to ensure resize independant blur.
  58774. */
  58775. mainTextureFixedSize?: number;
  58776. /**
  58777. * How big is the kernel of the blur texture.
  58778. */
  58779. blurKernelSize: number;
  58780. /**
  58781. * The camera attached to the layer.
  58782. */
  58783. camera: Nullable<Camera>;
  58784. /**
  58785. * Enable MSAA by chosing the number of samples.
  58786. */
  58787. mainTextureSamples?: number;
  58788. /**
  58789. * The rendering group to draw the layer in.
  58790. */
  58791. renderingGroupId: number;
  58792. }
  58793. /**
  58794. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  58795. *
  58796. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  58797. *
  58798. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  58799. */
  58800. export class GlowLayer extends EffectLayer {
  58801. /**
  58802. * Effect Name of the layer.
  58803. */
  58804. static readonly EffectName: string;
  58805. /**
  58806. * The default blur kernel size used for the glow.
  58807. */
  58808. static DefaultBlurKernelSize: number;
  58809. /**
  58810. * The default texture size ratio used for the glow.
  58811. */
  58812. static DefaultTextureRatio: number;
  58813. /**
  58814. * Sets the kernel size of the blur.
  58815. */
  58816. set blurKernelSize(value: number);
  58817. /**
  58818. * Gets the kernel size of the blur.
  58819. */
  58820. get blurKernelSize(): number;
  58821. /**
  58822. * Sets the glow intensity.
  58823. */
  58824. set intensity(value: number);
  58825. /**
  58826. * Gets the glow intensity.
  58827. */
  58828. get intensity(): number;
  58829. private _options;
  58830. private _intensity;
  58831. private _horizontalBlurPostprocess1;
  58832. private _verticalBlurPostprocess1;
  58833. private _horizontalBlurPostprocess2;
  58834. private _verticalBlurPostprocess2;
  58835. private _blurTexture1;
  58836. private _blurTexture2;
  58837. private _postProcesses1;
  58838. private _postProcesses2;
  58839. private _includedOnlyMeshes;
  58840. private _excludedMeshes;
  58841. private _meshesUsingTheirOwnMaterials;
  58842. /**
  58843. * Callback used to let the user override the color selection on a per mesh basis
  58844. */
  58845. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  58846. /**
  58847. * Callback used to let the user override the texture selection on a per mesh basis
  58848. */
  58849. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  58850. /**
  58851. * Instantiates a new glow Layer and references it to the scene.
  58852. * @param name The name of the layer
  58853. * @param scene The scene to use the layer in
  58854. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  58855. */
  58856. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  58857. /**
  58858. * Get the effect name of the layer.
  58859. * @return The effect name
  58860. */
  58861. getEffectName(): string;
  58862. /**
  58863. * Create the merge effect. This is the shader use to blit the information back
  58864. * to the main canvas at the end of the scene rendering.
  58865. */
  58866. protected _createMergeEffect(): Effect;
  58867. /**
  58868. * Creates the render target textures and post processes used in the glow layer.
  58869. */
  58870. protected _createTextureAndPostProcesses(): void;
  58871. /**
  58872. * Checks for the readiness of the element composing the layer.
  58873. * @param subMesh the mesh to check for
  58874. * @param useInstances specify wether or not to use instances to render the mesh
  58875. * @param emissiveTexture the associated emissive texture used to generate the glow
  58876. * @return true if ready otherwise, false
  58877. */
  58878. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58879. /**
  58880. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58881. */
  58882. needStencil(): boolean;
  58883. /**
  58884. * Returns true if the mesh can be rendered, otherwise false.
  58885. * @param mesh The mesh to render
  58886. * @param material The material used on the mesh
  58887. * @returns true if it can be rendered otherwise false
  58888. */
  58889. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58890. /**
  58891. * Implementation specific of rendering the generating effect on the main canvas.
  58892. * @param effect The effect used to render through
  58893. */
  58894. protected _internalRender(effect: Effect): void;
  58895. /**
  58896. * Sets the required values for both the emissive texture and and the main color.
  58897. */
  58898. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58899. /**
  58900. * Returns true if the mesh should render, otherwise false.
  58901. * @param mesh The mesh to render
  58902. * @returns true if it should render otherwise false
  58903. */
  58904. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58905. /**
  58906. * Adds specific effects defines.
  58907. * @param defines The defines to add specifics to.
  58908. */
  58909. protected _addCustomEffectDefines(defines: string[]): void;
  58910. /**
  58911. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  58912. * @param mesh The mesh to exclude from the glow layer
  58913. */
  58914. addExcludedMesh(mesh: Mesh): void;
  58915. /**
  58916. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  58917. * @param mesh The mesh to remove
  58918. */
  58919. removeExcludedMesh(mesh: Mesh): void;
  58920. /**
  58921. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  58922. * @param mesh The mesh to include in the glow layer
  58923. */
  58924. addIncludedOnlyMesh(mesh: Mesh): void;
  58925. /**
  58926. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  58927. * @param mesh The mesh to remove
  58928. */
  58929. removeIncludedOnlyMesh(mesh: Mesh): void;
  58930. /**
  58931. * Determine if a given mesh will be used in the glow layer
  58932. * @param mesh The mesh to test
  58933. * @returns true if the mesh will be highlighted by the current glow layer
  58934. */
  58935. hasMesh(mesh: AbstractMesh): boolean;
  58936. /**
  58937. * Defines whether the current material of the mesh should be use to render the effect.
  58938. * @param mesh defines the current mesh to render
  58939. */
  58940. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58941. /**
  58942. * Add a mesh to be rendered through its own material and not with emissive only.
  58943. * @param mesh The mesh for which we need to use its material
  58944. */
  58945. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  58946. /**
  58947. * Remove a mesh from being rendered through its own material and not with emissive only.
  58948. * @param mesh The mesh for which we need to not use its material
  58949. */
  58950. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  58951. /**
  58952. * Free any resources and references associated to a mesh.
  58953. * Internal use
  58954. * @param mesh The mesh to free.
  58955. * @hidden
  58956. */
  58957. _disposeMesh(mesh: Mesh): void;
  58958. /**
  58959. * Gets the class name of the effect layer
  58960. * @returns the string with the class name of the effect layer
  58961. */
  58962. getClassName(): string;
  58963. /**
  58964. * Serializes this glow layer
  58965. * @returns a serialized glow layer object
  58966. */
  58967. serialize(): any;
  58968. /**
  58969. * Creates a Glow Layer from parsed glow layer data
  58970. * @param parsedGlowLayer defines glow layer data
  58971. * @param scene defines the current scene
  58972. * @param rootUrl defines the root URL containing the glow layer information
  58973. * @returns a parsed Glow Layer
  58974. */
  58975. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  58976. }
  58977. }
  58978. declare module BABYLON {
  58979. /** @hidden */
  58980. export var glowBlurPostProcessPixelShader: {
  58981. name: string;
  58982. shader: string;
  58983. };
  58984. }
  58985. declare module BABYLON {
  58986. interface AbstractScene {
  58987. /**
  58988. * Return a the first highlight layer of the scene with a given name.
  58989. * @param name The name of the highlight layer to look for.
  58990. * @return The highlight layer if found otherwise null.
  58991. */
  58992. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  58993. }
  58994. /**
  58995. * Highlight layer options. This helps customizing the behaviour
  58996. * of the highlight layer.
  58997. */
  58998. export interface IHighlightLayerOptions {
  58999. /**
  59000. * Multiplication factor apply to the canvas size to compute the render target size
  59001. * used to generated the glowing objects (the smaller the faster).
  59002. */
  59003. mainTextureRatio: number;
  59004. /**
  59005. * Enforces a fixed size texture to ensure resize independant blur.
  59006. */
  59007. mainTextureFixedSize?: number;
  59008. /**
  59009. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  59010. * of the picture to blur (the smaller the faster).
  59011. */
  59012. blurTextureSizeRatio: number;
  59013. /**
  59014. * How big in texel of the blur texture is the vertical blur.
  59015. */
  59016. blurVerticalSize: number;
  59017. /**
  59018. * How big in texel of the blur texture is the horizontal blur.
  59019. */
  59020. blurHorizontalSize: number;
  59021. /**
  59022. * Alpha blending mode used to apply the blur. Default is combine.
  59023. */
  59024. alphaBlendingMode: number;
  59025. /**
  59026. * The camera attached to the layer.
  59027. */
  59028. camera: Nullable<Camera>;
  59029. /**
  59030. * Should we display highlight as a solid stroke?
  59031. */
  59032. isStroke?: boolean;
  59033. /**
  59034. * The rendering group to draw the layer in.
  59035. */
  59036. renderingGroupId: number;
  59037. }
  59038. /**
  59039. * The highlight layer Helps adding a glow effect around a mesh.
  59040. *
  59041. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  59042. * glowy meshes to your scene.
  59043. *
  59044. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  59045. */
  59046. export class HighlightLayer extends EffectLayer {
  59047. name: string;
  59048. /**
  59049. * Effect Name of the highlight layer.
  59050. */
  59051. static readonly EffectName: string;
  59052. /**
  59053. * The neutral color used during the preparation of the glow effect.
  59054. * This is black by default as the blend operation is a blend operation.
  59055. */
  59056. static NeutralColor: Color4;
  59057. /**
  59058. * Stencil value used for glowing meshes.
  59059. */
  59060. static GlowingMeshStencilReference: number;
  59061. /**
  59062. * Stencil value used for the other meshes in the scene.
  59063. */
  59064. static NormalMeshStencilReference: number;
  59065. /**
  59066. * Specifies whether or not the inner glow is ACTIVE in the layer.
  59067. */
  59068. innerGlow: boolean;
  59069. /**
  59070. * Specifies whether or not the outer glow is ACTIVE in the layer.
  59071. */
  59072. outerGlow: boolean;
  59073. /**
  59074. * Specifies the horizontal size of the blur.
  59075. */
  59076. set blurHorizontalSize(value: number);
  59077. /**
  59078. * Specifies the vertical size of the blur.
  59079. */
  59080. set blurVerticalSize(value: number);
  59081. /**
  59082. * Gets the horizontal size of the blur.
  59083. */
  59084. get blurHorizontalSize(): number;
  59085. /**
  59086. * Gets the vertical size of the blur.
  59087. */
  59088. get blurVerticalSize(): number;
  59089. /**
  59090. * An event triggered when the highlight layer is being blurred.
  59091. */
  59092. onBeforeBlurObservable: Observable<HighlightLayer>;
  59093. /**
  59094. * An event triggered when the highlight layer has been blurred.
  59095. */
  59096. onAfterBlurObservable: Observable<HighlightLayer>;
  59097. private _instanceGlowingMeshStencilReference;
  59098. private _options;
  59099. private _downSamplePostprocess;
  59100. private _horizontalBlurPostprocess;
  59101. private _verticalBlurPostprocess;
  59102. private _blurTexture;
  59103. private _meshes;
  59104. private _excludedMeshes;
  59105. /**
  59106. * Instantiates a new highlight Layer and references it to the scene..
  59107. * @param name The name of the layer
  59108. * @param scene The scene to use the layer in
  59109. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  59110. */
  59111. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  59112. /**
  59113. * Get the effect name of the layer.
  59114. * @return The effect name
  59115. */
  59116. getEffectName(): string;
  59117. /**
  59118. * Create the merge effect. This is the shader use to blit the information back
  59119. * to the main canvas at the end of the scene rendering.
  59120. */
  59121. protected _createMergeEffect(): Effect;
  59122. /**
  59123. * Creates the render target textures and post processes used in the highlight layer.
  59124. */
  59125. protected _createTextureAndPostProcesses(): void;
  59126. /**
  59127. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  59128. */
  59129. needStencil(): boolean;
  59130. /**
  59131. * Checks for the readiness of the element composing the layer.
  59132. * @param subMesh the mesh to check for
  59133. * @param useInstances specify wether or not to use instances to render the mesh
  59134. * @param emissiveTexture the associated emissive texture used to generate the glow
  59135. * @return true if ready otherwise, false
  59136. */
  59137. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59138. /**
  59139. * Implementation specific of rendering the generating effect on the main canvas.
  59140. * @param effect The effect used to render through
  59141. */
  59142. protected _internalRender(effect: Effect): void;
  59143. /**
  59144. * Returns true if the layer contains information to display, otherwise false.
  59145. */
  59146. shouldRender(): boolean;
  59147. /**
  59148. * Returns true if the mesh should render, otherwise false.
  59149. * @param mesh The mesh to render
  59150. * @returns true if it should render otherwise false
  59151. */
  59152. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59153. /**
  59154. * Returns true if the mesh can be rendered, otherwise false.
  59155. * @param mesh The mesh to render
  59156. * @param material The material used on the mesh
  59157. * @returns true if it can be rendered otherwise false
  59158. */
  59159. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59160. /**
  59161. * Adds specific effects defines.
  59162. * @param defines The defines to add specifics to.
  59163. */
  59164. protected _addCustomEffectDefines(defines: string[]): void;
  59165. /**
  59166. * Sets the required values for both the emissive texture and and the main color.
  59167. */
  59168. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59169. /**
  59170. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  59171. * @param mesh The mesh to exclude from the highlight layer
  59172. */
  59173. addExcludedMesh(mesh: Mesh): void;
  59174. /**
  59175. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  59176. * @param mesh The mesh to highlight
  59177. */
  59178. removeExcludedMesh(mesh: Mesh): void;
  59179. /**
  59180. * Determine if a given mesh will be highlighted by the current HighlightLayer
  59181. * @param mesh mesh to test
  59182. * @returns true if the mesh will be highlighted by the current HighlightLayer
  59183. */
  59184. hasMesh(mesh: AbstractMesh): boolean;
  59185. /**
  59186. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  59187. * @param mesh The mesh to highlight
  59188. * @param color The color of the highlight
  59189. * @param glowEmissiveOnly Extract the glow from the emissive texture
  59190. */
  59191. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  59192. /**
  59193. * Remove a mesh from the highlight layer in order to make it stop glowing.
  59194. * @param mesh The mesh to highlight
  59195. */
  59196. removeMesh(mesh: Mesh): void;
  59197. /**
  59198. * Remove all the meshes currently referenced in the highlight layer
  59199. */
  59200. removeAllMeshes(): void;
  59201. /**
  59202. * Force the stencil to the normal expected value for none glowing parts
  59203. */
  59204. private _defaultStencilReference;
  59205. /**
  59206. * Free any resources and references associated to a mesh.
  59207. * Internal use
  59208. * @param mesh The mesh to free.
  59209. * @hidden
  59210. */
  59211. _disposeMesh(mesh: Mesh): void;
  59212. /**
  59213. * Dispose the highlight layer and free resources.
  59214. */
  59215. dispose(): void;
  59216. /**
  59217. * Gets the class name of the effect layer
  59218. * @returns the string with the class name of the effect layer
  59219. */
  59220. getClassName(): string;
  59221. /**
  59222. * Serializes this Highlight layer
  59223. * @returns a serialized Highlight layer object
  59224. */
  59225. serialize(): any;
  59226. /**
  59227. * Creates a Highlight layer from parsed Highlight layer data
  59228. * @param parsedHightlightLayer defines the Highlight layer data
  59229. * @param scene defines the current scene
  59230. * @param rootUrl defines the root URL containing the Highlight layer information
  59231. * @returns a parsed Highlight layer
  59232. */
  59233. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  59234. }
  59235. }
  59236. declare module BABYLON {
  59237. interface AbstractScene {
  59238. /**
  59239. * The list of layers (background and foreground) of the scene
  59240. */
  59241. layers: Array<Layer>;
  59242. }
  59243. /**
  59244. * Defines the layer scene component responsible to manage any layers
  59245. * in a given scene.
  59246. */
  59247. export class LayerSceneComponent implements ISceneComponent {
  59248. /**
  59249. * The component name helpfull to identify the component in the list of scene components.
  59250. */
  59251. readonly name: string;
  59252. /**
  59253. * The scene the component belongs to.
  59254. */
  59255. scene: Scene;
  59256. private _engine;
  59257. /**
  59258. * Creates a new instance of the component for the given scene
  59259. * @param scene Defines the scene to register the component in
  59260. */
  59261. constructor(scene: Scene);
  59262. /**
  59263. * Registers the component in a given scene
  59264. */
  59265. register(): void;
  59266. /**
  59267. * Rebuilds the elements related to this component in case of
  59268. * context lost for instance.
  59269. */
  59270. rebuild(): void;
  59271. /**
  59272. * Disposes the component and the associated ressources.
  59273. */
  59274. dispose(): void;
  59275. private _draw;
  59276. private _drawCameraPredicate;
  59277. private _drawCameraBackground;
  59278. private _drawCameraForeground;
  59279. private _drawRenderTargetPredicate;
  59280. private _drawRenderTargetBackground;
  59281. private _drawRenderTargetForeground;
  59282. /**
  59283. * Adds all the elements from the container to the scene
  59284. * @param container the container holding the elements
  59285. */
  59286. addFromContainer(container: AbstractScene): void;
  59287. /**
  59288. * Removes all the elements in the container from the scene
  59289. * @param container contains the elements to remove
  59290. * @param dispose if the removed element should be disposed (default: false)
  59291. */
  59292. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59293. }
  59294. }
  59295. declare module BABYLON {
  59296. /** @hidden */
  59297. export var layerPixelShader: {
  59298. name: string;
  59299. shader: string;
  59300. };
  59301. }
  59302. declare module BABYLON {
  59303. /** @hidden */
  59304. export var layerVertexShader: {
  59305. name: string;
  59306. shader: string;
  59307. };
  59308. }
  59309. declare module BABYLON {
  59310. /**
  59311. * This represents a full screen 2d layer.
  59312. * This can be useful to display a picture in the background of your scene for instance.
  59313. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59314. */
  59315. export class Layer {
  59316. /**
  59317. * Define the name of the layer.
  59318. */
  59319. name: string;
  59320. /**
  59321. * Define the texture the layer should display.
  59322. */
  59323. texture: Nullable<Texture>;
  59324. /**
  59325. * Is the layer in background or foreground.
  59326. */
  59327. isBackground: boolean;
  59328. /**
  59329. * Define the color of the layer (instead of texture).
  59330. */
  59331. color: Color4;
  59332. /**
  59333. * Define the scale of the layer in order to zoom in out of the texture.
  59334. */
  59335. scale: Vector2;
  59336. /**
  59337. * Define an offset for the layer in order to shift the texture.
  59338. */
  59339. offset: Vector2;
  59340. /**
  59341. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  59342. */
  59343. alphaBlendingMode: number;
  59344. /**
  59345. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  59346. * Alpha test will not mix with the background color in case of transparency.
  59347. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  59348. */
  59349. alphaTest: boolean;
  59350. /**
  59351. * Define a mask to restrict the layer to only some of the scene cameras.
  59352. */
  59353. layerMask: number;
  59354. /**
  59355. * Define the list of render target the layer is visible into.
  59356. */
  59357. renderTargetTextures: RenderTargetTexture[];
  59358. /**
  59359. * Define if the layer is only used in renderTarget or if it also
  59360. * renders in the main frame buffer of the canvas.
  59361. */
  59362. renderOnlyInRenderTargetTextures: boolean;
  59363. private _scene;
  59364. private _vertexBuffers;
  59365. private _indexBuffer;
  59366. private _effect;
  59367. private _previousDefines;
  59368. /**
  59369. * An event triggered when the layer is disposed.
  59370. */
  59371. onDisposeObservable: Observable<Layer>;
  59372. private _onDisposeObserver;
  59373. /**
  59374. * Back compatibility with callback before the onDisposeObservable existed.
  59375. * The set callback will be triggered when the layer has been disposed.
  59376. */
  59377. set onDispose(callback: () => void);
  59378. /**
  59379. * An event triggered before rendering the scene
  59380. */
  59381. onBeforeRenderObservable: Observable<Layer>;
  59382. private _onBeforeRenderObserver;
  59383. /**
  59384. * Back compatibility with callback before the onBeforeRenderObservable existed.
  59385. * The set callback will be triggered just before rendering the layer.
  59386. */
  59387. set onBeforeRender(callback: () => void);
  59388. /**
  59389. * An event triggered after rendering the scene
  59390. */
  59391. onAfterRenderObservable: Observable<Layer>;
  59392. private _onAfterRenderObserver;
  59393. /**
  59394. * Back compatibility with callback before the onAfterRenderObservable existed.
  59395. * The set callback will be triggered just after rendering the layer.
  59396. */
  59397. set onAfterRender(callback: () => void);
  59398. /**
  59399. * Instantiates a new layer.
  59400. * This represents a full screen 2d layer.
  59401. * This can be useful to display a picture in the background of your scene for instance.
  59402. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59403. * @param name Define the name of the layer in the scene
  59404. * @param imgUrl Define the url of the texture to display in the layer
  59405. * @param scene Define the scene the layer belongs to
  59406. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  59407. * @param color Defines a color for the layer
  59408. */
  59409. constructor(
  59410. /**
  59411. * Define the name of the layer.
  59412. */
  59413. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  59414. private _createIndexBuffer;
  59415. /** @hidden */
  59416. _rebuild(): void;
  59417. /**
  59418. * Renders the layer in the scene.
  59419. */
  59420. render(): void;
  59421. /**
  59422. * Disposes and releases the associated ressources.
  59423. */
  59424. dispose(): void;
  59425. }
  59426. }
  59427. declare module BABYLON {
  59428. /** @hidden */
  59429. export var lensFlarePixelShader: {
  59430. name: string;
  59431. shader: string;
  59432. };
  59433. }
  59434. declare module BABYLON {
  59435. /** @hidden */
  59436. export var lensFlareVertexShader: {
  59437. name: string;
  59438. shader: string;
  59439. };
  59440. }
  59441. declare module BABYLON {
  59442. /**
  59443. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59444. * It is usually composed of several `lensFlare`.
  59445. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59446. */
  59447. export class LensFlareSystem {
  59448. /**
  59449. * Define the name of the lens flare system
  59450. */
  59451. name: string;
  59452. /**
  59453. * List of lens flares used in this system.
  59454. */
  59455. lensFlares: LensFlare[];
  59456. /**
  59457. * Define a limit from the border the lens flare can be visible.
  59458. */
  59459. borderLimit: number;
  59460. /**
  59461. * Define a viewport border we do not want to see the lens flare in.
  59462. */
  59463. viewportBorder: number;
  59464. /**
  59465. * Define a predicate which could limit the list of meshes able to occlude the effect.
  59466. */
  59467. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  59468. /**
  59469. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  59470. */
  59471. layerMask: number;
  59472. /**
  59473. * Define the id of the lens flare system in the scene.
  59474. * (equal to name by default)
  59475. */
  59476. id: string;
  59477. private _scene;
  59478. private _emitter;
  59479. private _vertexBuffers;
  59480. private _indexBuffer;
  59481. private _effect;
  59482. private _positionX;
  59483. private _positionY;
  59484. private _isEnabled;
  59485. /** @hidden */
  59486. static _SceneComponentInitialization: (scene: Scene) => void;
  59487. /**
  59488. * Instantiates a lens flare system.
  59489. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59490. * It is usually composed of several `lensFlare`.
  59491. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59492. * @param name Define the name of the lens flare system in the scene
  59493. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  59494. * @param scene Define the scene the lens flare system belongs to
  59495. */
  59496. constructor(
  59497. /**
  59498. * Define the name of the lens flare system
  59499. */
  59500. name: string, emitter: any, scene: Scene);
  59501. /**
  59502. * Define if the lens flare system is enabled.
  59503. */
  59504. get isEnabled(): boolean;
  59505. set isEnabled(value: boolean);
  59506. /**
  59507. * Get the scene the effects belongs to.
  59508. * @returns the scene holding the lens flare system
  59509. */
  59510. getScene(): Scene;
  59511. /**
  59512. * Get the emitter of the lens flare system.
  59513. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59514. * @returns the emitter of the lens flare system
  59515. */
  59516. getEmitter(): any;
  59517. /**
  59518. * Set the emitter of the lens flare system.
  59519. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59520. * @param newEmitter Define the new emitter of the system
  59521. */
  59522. setEmitter(newEmitter: any): void;
  59523. /**
  59524. * Get the lens flare system emitter position.
  59525. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  59526. * @returns the position
  59527. */
  59528. getEmitterPosition(): Vector3;
  59529. /**
  59530. * @hidden
  59531. */
  59532. computeEffectivePosition(globalViewport: Viewport): boolean;
  59533. /** @hidden */
  59534. _isVisible(): boolean;
  59535. /**
  59536. * @hidden
  59537. */
  59538. render(): boolean;
  59539. /**
  59540. * Dispose and release the lens flare with its associated resources.
  59541. */
  59542. dispose(): void;
  59543. /**
  59544. * Parse a lens flare system from a JSON repressentation
  59545. * @param parsedLensFlareSystem Define the JSON to parse
  59546. * @param scene Define the scene the parsed system should be instantiated in
  59547. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  59548. * @returns the parsed system
  59549. */
  59550. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  59551. /**
  59552. * Serialize the current Lens Flare System into a JSON representation.
  59553. * @returns the serialized JSON
  59554. */
  59555. serialize(): any;
  59556. }
  59557. }
  59558. declare module BABYLON {
  59559. /**
  59560. * This represents one of the lens effect in a `lensFlareSystem`.
  59561. * It controls one of the indiviual texture used in the effect.
  59562. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59563. */
  59564. export class LensFlare {
  59565. /**
  59566. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59567. */
  59568. size: number;
  59569. /**
  59570. * 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.
  59571. */
  59572. position: number;
  59573. /**
  59574. * Define the lens color.
  59575. */
  59576. color: Color3;
  59577. /**
  59578. * Define the lens texture.
  59579. */
  59580. texture: Nullable<Texture>;
  59581. /**
  59582. * Define the alpha mode to render this particular lens.
  59583. */
  59584. alphaMode: number;
  59585. private _system;
  59586. /**
  59587. * Creates a new Lens Flare.
  59588. * This represents one of the lens effect in a `lensFlareSystem`.
  59589. * It controls one of the indiviual texture used in the effect.
  59590. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59591. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  59592. * @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.
  59593. * @param color Define the lens color
  59594. * @param imgUrl Define the lens texture url
  59595. * @param system Define the `lensFlareSystem` this flare is part of
  59596. * @returns The newly created Lens Flare
  59597. */
  59598. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  59599. /**
  59600. * Instantiates a new Lens Flare.
  59601. * This represents one of the lens effect in a `lensFlareSystem`.
  59602. * It controls one of the indiviual texture used in the effect.
  59603. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59604. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  59605. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  59606. * @param color Define the lens color
  59607. * @param imgUrl Define the lens texture url
  59608. * @param system Define the `lensFlareSystem` this flare is part of
  59609. */
  59610. constructor(
  59611. /**
  59612. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59613. */
  59614. size: number,
  59615. /**
  59616. * 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.
  59617. */
  59618. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  59619. /**
  59620. * Dispose and release the lens flare with its associated resources.
  59621. */
  59622. dispose(): void;
  59623. }
  59624. }
  59625. declare module BABYLON {
  59626. interface AbstractScene {
  59627. /**
  59628. * The list of lens flare system added to the scene
  59629. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59630. */
  59631. lensFlareSystems: Array<LensFlareSystem>;
  59632. /**
  59633. * Removes the given lens flare system from this scene.
  59634. * @param toRemove The lens flare system to remove
  59635. * @returns The index of the removed lens flare system
  59636. */
  59637. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  59638. /**
  59639. * Adds the given lens flare system to this scene
  59640. * @param newLensFlareSystem The lens flare system to add
  59641. */
  59642. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  59643. /**
  59644. * Gets a lens flare system using its name
  59645. * @param name defines the name to look for
  59646. * @returns the lens flare system or null if not found
  59647. */
  59648. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  59649. /**
  59650. * Gets a lens flare system using its id
  59651. * @param id defines the id to look for
  59652. * @returns the lens flare system or null if not found
  59653. */
  59654. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  59655. }
  59656. /**
  59657. * Defines the lens flare scene component responsible to manage any lens flares
  59658. * in a given scene.
  59659. */
  59660. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  59661. /**
  59662. * The component name helpfull to identify the component in the list of scene components.
  59663. */
  59664. readonly name: string;
  59665. /**
  59666. * The scene the component belongs to.
  59667. */
  59668. scene: Scene;
  59669. /**
  59670. * Creates a new instance of the component for the given scene
  59671. * @param scene Defines the scene to register the component in
  59672. */
  59673. constructor(scene: Scene);
  59674. /**
  59675. * Registers the component in a given scene
  59676. */
  59677. register(): void;
  59678. /**
  59679. * Rebuilds the elements related to this component in case of
  59680. * context lost for instance.
  59681. */
  59682. rebuild(): void;
  59683. /**
  59684. * Adds all the elements from the container to the scene
  59685. * @param container the container holding the elements
  59686. */
  59687. addFromContainer(container: AbstractScene): void;
  59688. /**
  59689. * Removes all the elements in the container from the scene
  59690. * @param container contains the elements to remove
  59691. * @param dispose if the removed element should be disposed (default: false)
  59692. */
  59693. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59694. /**
  59695. * Serializes the component data to the specified json object
  59696. * @param serializationObject The object to serialize to
  59697. */
  59698. serialize(serializationObject: any): void;
  59699. /**
  59700. * Disposes the component and the associated ressources.
  59701. */
  59702. dispose(): void;
  59703. private _draw;
  59704. }
  59705. }
  59706. declare module BABYLON {
  59707. /** @hidden */
  59708. export var depthPixelShader: {
  59709. name: string;
  59710. shader: string;
  59711. };
  59712. }
  59713. declare module BABYLON {
  59714. /** @hidden */
  59715. export var depthVertexShader: {
  59716. name: string;
  59717. shader: string;
  59718. };
  59719. }
  59720. declare module BABYLON {
  59721. /**
  59722. * This represents a depth renderer in Babylon.
  59723. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59724. */
  59725. export class DepthRenderer {
  59726. private _scene;
  59727. private _depthMap;
  59728. private _effect;
  59729. private readonly _storeNonLinearDepth;
  59730. private readonly _clearColor;
  59731. /** Get if the depth renderer is using packed depth or not */
  59732. readonly isPacked: boolean;
  59733. private _cachedDefines;
  59734. private _camera;
  59735. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  59736. enabled: boolean;
  59737. /**
  59738. * Specifiess that the depth renderer will only be used within
  59739. * the camera it is created for.
  59740. * This can help forcing its rendering during the camera processing.
  59741. */
  59742. useOnlyInActiveCamera: boolean;
  59743. /** @hidden */
  59744. static _SceneComponentInitialization: (scene: Scene) => void;
  59745. /**
  59746. * Instantiates a depth renderer
  59747. * @param scene The scene the renderer belongs to
  59748. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59749. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59750. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59751. */
  59752. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59753. /**
  59754. * Creates the depth rendering effect and checks if the effect is ready.
  59755. * @param subMesh The submesh to be used to render the depth map of
  59756. * @param useInstances If multiple world instances should be used
  59757. * @returns if the depth renderer is ready to render the depth map
  59758. */
  59759. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59760. /**
  59761. * Gets the texture which the depth map will be written to.
  59762. * @returns The depth map texture
  59763. */
  59764. getDepthMap(): RenderTargetTexture;
  59765. /**
  59766. * Disposes of the depth renderer.
  59767. */
  59768. dispose(): void;
  59769. }
  59770. }
  59771. declare module BABYLON {
  59772. /** @hidden */
  59773. export var minmaxReduxPixelShader: {
  59774. name: string;
  59775. shader: string;
  59776. };
  59777. }
  59778. declare module BABYLON {
  59779. /**
  59780. * This class computes a min/max reduction from a texture: it means it computes the minimum
  59781. * and maximum values from all values of the texture.
  59782. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  59783. * The source values are read from the red channel of the texture.
  59784. */
  59785. export class MinMaxReducer {
  59786. /**
  59787. * Observable triggered when the computation has been performed
  59788. */
  59789. onAfterReductionPerformed: Observable<{
  59790. min: number;
  59791. max: number;
  59792. }>;
  59793. protected _camera: Camera;
  59794. protected _sourceTexture: Nullable<RenderTargetTexture>;
  59795. protected _reductionSteps: Nullable<Array<PostProcess>>;
  59796. protected _postProcessManager: PostProcessManager;
  59797. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  59798. protected _forceFullscreenViewport: boolean;
  59799. /**
  59800. * Creates a min/max reducer
  59801. * @param camera The camera to use for the post processes
  59802. */
  59803. constructor(camera: Camera);
  59804. /**
  59805. * Gets the texture used to read the values from.
  59806. */
  59807. get sourceTexture(): Nullable<RenderTargetTexture>;
  59808. /**
  59809. * Sets the source texture to read the values from.
  59810. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  59811. * because in such textures '1' value must not be taken into account to compute the maximum
  59812. * as this value is used to clear the texture.
  59813. * Note that the computation is not activated by calling this function, you must call activate() for that!
  59814. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  59815. * @param depthRedux Indicates if the texture is a depth texture or not
  59816. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  59817. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59818. */
  59819. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59820. /**
  59821. * Defines the refresh rate of the computation.
  59822. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59823. */
  59824. get refreshRate(): number;
  59825. set refreshRate(value: number);
  59826. protected _activated: boolean;
  59827. /**
  59828. * Gets the activation status of the reducer
  59829. */
  59830. get activated(): boolean;
  59831. /**
  59832. * Activates the reduction computation.
  59833. * When activated, the observers registered in onAfterReductionPerformed are
  59834. * called after the compuation is performed
  59835. */
  59836. activate(): void;
  59837. /**
  59838. * Deactivates the reduction computation.
  59839. */
  59840. deactivate(): void;
  59841. /**
  59842. * Disposes the min/max reducer
  59843. * @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.
  59844. */
  59845. dispose(disposeAll?: boolean): void;
  59846. }
  59847. }
  59848. declare module BABYLON {
  59849. /**
  59850. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  59851. */
  59852. export class DepthReducer extends MinMaxReducer {
  59853. private _depthRenderer;
  59854. private _depthRendererId;
  59855. /**
  59856. * Gets the depth renderer used for the computation.
  59857. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  59858. */
  59859. get depthRenderer(): Nullable<DepthRenderer>;
  59860. /**
  59861. * Creates a depth reducer
  59862. * @param camera The camera used to render the depth texture
  59863. */
  59864. constructor(camera: Camera);
  59865. /**
  59866. * Sets the depth renderer to use to generate the depth map
  59867. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  59868. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  59869. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59870. */
  59871. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  59872. /** @hidden */
  59873. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59874. /**
  59875. * Activates the reduction computation.
  59876. * When activated, the observers registered in onAfterReductionPerformed are
  59877. * called after the compuation is performed
  59878. */
  59879. activate(): void;
  59880. /**
  59881. * Deactivates the reduction computation.
  59882. */
  59883. deactivate(): void;
  59884. /**
  59885. * Disposes the depth reducer
  59886. * @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.
  59887. */
  59888. dispose(disposeAll?: boolean): void;
  59889. }
  59890. }
  59891. declare module BABYLON {
  59892. /**
  59893. * A CSM implementation allowing casting shadows on large scenes.
  59894. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59895. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  59896. */
  59897. export class CascadedShadowGenerator extends ShadowGenerator {
  59898. private static readonly frustumCornersNDCSpace;
  59899. /**
  59900. * Name of the CSM class
  59901. */
  59902. static CLASSNAME: string;
  59903. /**
  59904. * Defines the default number of cascades used by the CSM.
  59905. */
  59906. static readonly DEFAULT_CASCADES_COUNT: number;
  59907. /**
  59908. * Defines the minimum number of cascades used by the CSM.
  59909. */
  59910. static readonly MIN_CASCADES_COUNT: number;
  59911. /**
  59912. * Defines the maximum number of cascades used by the CSM.
  59913. */
  59914. static readonly MAX_CASCADES_COUNT: number;
  59915. protected _validateFilter(filter: number): number;
  59916. /**
  59917. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  59918. */
  59919. penumbraDarkness: number;
  59920. private _numCascades;
  59921. /**
  59922. * Gets or set the number of cascades used by the CSM.
  59923. */
  59924. get numCascades(): number;
  59925. set numCascades(value: number);
  59926. /**
  59927. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  59928. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  59929. */
  59930. stabilizeCascades: boolean;
  59931. private _freezeShadowCastersBoundingInfo;
  59932. private _freezeShadowCastersBoundingInfoObservable;
  59933. /**
  59934. * Enables or disables the shadow casters bounding info computation.
  59935. * If your shadow casters don't move, you can disable this feature.
  59936. * If it is enabled, the bounding box computation is done every frame.
  59937. */
  59938. get freezeShadowCastersBoundingInfo(): boolean;
  59939. set freezeShadowCastersBoundingInfo(freeze: boolean);
  59940. private _scbiMin;
  59941. private _scbiMax;
  59942. protected _computeShadowCastersBoundingInfo(): void;
  59943. protected _shadowCastersBoundingInfo: BoundingInfo;
  59944. /**
  59945. * Gets or sets the shadow casters bounding info.
  59946. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  59947. * so that the system won't overwrite the bounds you provide
  59948. */
  59949. get shadowCastersBoundingInfo(): BoundingInfo;
  59950. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  59951. protected _breaksAreDirty: boolean;
  59952. protected _minDistance: number;
  59953. protected _maxDistance: number;
  59954. /**
  59955. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  59956. *
  59957. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  59958. * If you don't know these values, simply leave them to their defaults and don't call this function.
  59959. * @param min minimal distance for the breaks (default to 0.)
  59960. * @param max maximal distance for the breaks (default to 1.)
  59961. */
  59962. setMinMaxDistance(min: number, max: number): void;
  59963. /** Gets the minimal distance used in the cascade break computation */
  59964. get minDistance(): number;
  59965. /** Gets the maximal distance used in the cascade break computation */
  59966. get maxDistance(): number;
  59967. /**
  59968. * Gets the class name of that object
  59969. * @returns "CascadedShadowGenerator"
  59970. */
  59971. getClassName(): string;
  59972. private _cascadeMinExtents;
  59973. private _cascadeMaxExtents;
  59974. /**
  59975. * Gets a cascade minimum extents
  59976. * @param cascadeIndex index of the cascade
  59977. * @returns the minimum cascade extents
  59978. */
  59979. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  59980. /**
  59981. * Gets a cascade maximum extents
  59982. * @param cascadeIndex index of the cascade
  59983. * @returns the maximum cascade extents
  59984. */
  59985. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  59986. private _cascades;
  59987. private _currentLayer;
  59988. private _viewSpaceFrustumsZ;
  59989. private _viewMatrices;
  59990. private _projectionMatrices;
  59991. private _transformMatrices;
  59992. private _transformMatricesAsArray;
  59993. private _frustumLengths;
  59994. private _lightSizeUVCorrection;
  59995. private _depthCorrection;
  59996. private _frustumCornersWorldSpace;
  59997. private _frustumCenter;
  59998. private _shadowCameraPos;
  59999. private _shadowMaxZ;
  60000. /**
  60001. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  60002. * It defaults to camera.maxZ
  60003. */
  60004. get shadowMaxZ(): number;
  60005. /**
  60006. * Sets the shadow max z distance.
  60007. */
  60008. set shadowMaxZ(value: number);
  60009. protected _debug: boolean;
  60010. /**
  60011. * Gets or sets the debug flag.
  60012. * When enabled, the cascades are materialized by different colors on the screen.
  60013. */
  60014. get debug(): boolean;
  60015. set debug(dbg: boolean);
  60016. private _depthClamp;
  60017. /**
  60018. * Gets or sets the depth clamping value.
  60019. *
  60020. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  60021. * to account for the shadow casters far away.
  60022. *
  60023. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  60024. */
  60025. get depthClamp(): boolean;
  60026. set depthClamp(value: boolean);
  60027. private _cascadeBlendPercentage;
  60028. /**
  60029. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60030. * It defaults to 0.1 (10% blending).
  60031. */
  60032. get cascadeBlendPercentage(): number;
  60033. set cascadeBlendPercentage(value: number);
  60034. private _lambda;
  60035. /**
  60036. * Gets or set the lambda parameter.
  60037. * This parameter is used to split the camera frustum and create the cascades.
  60038. * 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.
  60039. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  60040. */
  60041. get lambda(): number;
  60042. set lambda(value: number);
  60043. /**
  60044. * Gets the view matrix corresponding to a given cascade
  60045. * @param cascadeNum cascade to retrieve the view matrix from
  60046. * @returns the cascade view matrix
  60047. */
  60048. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  60049. /**
  60050. * Gets the projection matrix corresponding to a given cascade
  60051. * @param cascadeNum cascade to retrieve the projection matrix from
  60052. * @returns the cascade projection matrix
  60053. */
  60054. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  60055. /**
  60056. * Gets the transformation matrix corresponding to a given cascade
  60057. * @param cascadeNum cascade to retrieve the transformation matrix from
  60058. * @returns the cascade transformation matrix
  60059. */
  60060. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  60061. private _depthRenderer;
  60062. /**
  60063. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  60064. *
  60065. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  60066. *
  60067. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  60068. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  60069. * @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
  60070. */
  60071. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  60072. private _depthReducer;
  60073. private _autoCalcDepthBounds;
  60074. /**
  60075. * Gets or sets the autoCalcDepthBounds property.
  60076. *
  60077. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  60078. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  60079. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  60080. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  60081. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  60082. */
  60083. get autoCalcDepthBounds(): boolean;
  60084. set autoCalcDepthBounds(value: boolean);
  60085. /**
  60086. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  60087. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60088. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  60089. * for setting the refresh rate on the renderer yourself!
  60090. */
  60091. get autoCalcDepthBoundsRefreshRate(): number;
  60092. set autoCalcDepthBoundsRefreshRate(value: number);
  60093. /**
  60094. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  60095. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  60096. * you change the camera near/far planes!
  60097. */
  60098. splitFrustum(): void;
  60099. private _splitFrustum;
  60100. private _computeMatrices;
  60101. private _computeFrustumInWorldSpace;
  60102. private _computeCascadeFrustum;
  60103. /**
  60104. * Support test.
  60105. */
  60106. static get IsSupported(): boolean;
  60107. /** @hidden */
  60108. static _SceneComponentInitialization: (scene: Scene) => void;
  60109. /**
  60110. * Creates a Cascaded Shadow Generator object.
  60111. * A ShadowGenerator is the required tool to use the shadows.
  60112. * Each directional light casting shadows needs to use its own ShadowGenerator.
  60113. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60114. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  60115. * @param light The directional light object generating the shadows.
  60116. * @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.
  60117. */
  60118. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  60119. protected _initializeGenerator(): void;
  60120. protected _createTargetRenderTexture(): void;
  60121. protected _initializeShadowMap(): void;
  60122. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  60123. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  60124. /**
  60125. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  60126. * @param defines Defines of the material we want to update
  60127. * @param lightIndex Index of the light in the enabled light list of the material
  60128. */
  60129. prepareDefines(defines: any, lightIndex: number): void;
  60130. /**
  60131. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  60132. * defined in the generator but impacting the effect).
  60133. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  60134. * @param effect The effect we are binfing the information for
  60135. */
  60136. bindShadowLight(lightIndex: string, effect: Effect): void;
  60137. /**
  60138. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  60139. * (eq to view projection * shadow projection matrices)
  60140. * @returns The transform matrix used to create the shadow map
  60141. */
  60142. getTransformMatrix(): Matrix;
  60143. /**
  60144. * Disposes the ShadowGenerator.
  60145. * Returns nothing.
  60146. */
  60147. dispose(): void;
  60148. /**
  60149. * Serializes the shadow generator setup to a json object.
  60150. * @returns The serialized JSON object
  60151. */
  60152. serialize(): any;
  60153. /**
  60154. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  60155. * @param parsedShadowGenerator The JSON object to parse
  60156. * @param scene The scene to create the shadow map for
  60157. * @returns The parsed shadow generator
  60158. */
  60159. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  60160. }
  60161. }
  60162. declare module BABYLON {
  60163. /**
  60164. * Defines the shadow generator component responsible to manage any shadow generators
  60165. * in a given scene.
  60166. */
  60167. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  60168. /**
  60169. * The component name helpfull to identify the component in the list of scene components.
  60170. */
  60171. readonly name: string;
  60172. /**
  60173. * The scene the component belongs to.
  60174. */
  60175. scene: Scene;
  60176. /**
  60177. * Creates a new instance of the component for the given scene
  60178. * @param scene Defines the scene to register the component in
  60179. */
  60180. constructor(scene: Scene);
  60181. /**
  60182. * Registers the component in a given scene
  60183. */
  60184. register(): void;
  60185. /**
  60186. * Rebuilds the elements related to this component in case of
  60187. * context lost for instance.
  60188. */
  60189. rebuild(): void;
  60190. /**
  60191. * Serializes the component data to the specified json object
  60192. * @param serializationObject The object to serialize to
  60193. */
  60194. serialize(serializationObject: any): void;
  60195. /**
  60196. * Adds all the elements from the container to the scene
  60197. * @param container the container holding the elements
  60198. */
  60199. addFromContainer(container: AbstractScene): void;
  60200. /**
  60201. * Removes all the elements in the container from the scene
  60202. * @param container contains the elements to remove
  60203. * @param dispose if the removed element should be disposed (default: false)
  60204. */
  60205. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60206. /**
  60207. * Rebuilds the elements related to this component in case of
  60208. * context lost for instance.
  60209. */
  60210. dispose(): void;
  60211. private _gatherRenderTargets;
  60212. }
  60213. }
  60214. declare module BABYLON {
  60215. /**
  60216. * A point light is a light defined by an unique point in world space.
  60217. * The light is emitted in every direction from this point.
  60218. * A good example of a point light is a standard light bulb.
  60219. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60220. */
  60221. export class PointLight extends ShadowLight {
  60222. private _shadowAngle;
  60223. /**
  60224. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60225. * This specifies what angle the shadow will use to be created.
  60226. *
  60227. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60228. */
  60229. get shadowAngle(): number;
  60230. /**
  60231. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60232. * This specifies what angle the shadow will use to be created.
  60233. *
  60234. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60235. */
  60236. set shadowAngle(value: number);
  60237. /**
  60238. * Gets the direction if it has been set.
  60239. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60240. */
  60241. get direction(): Vector3;
  60242. /**
  60243. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60244. */
  60245. set direction(value: Vector3);
  60246. /**
  60247. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  60248. * A PointLight emits the light in every direction.
  60249. * It can cast shadows.
  60250. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  60251. * ```javascript
  60252. * var pointLight = new PointLight("pl", camera.position, scene);
  60253. * ```
  60254. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60255. * @param name The light friendly name
  60256. * @param position The position of the point light in the scene
  60257. * @param scene The scene the lights belongs to
  60258. */
  60259. constructor(name: string, position: Vector3, scene: Scene);
  60260. /**
  60261. * Returns the string "PointLight"
  60262. * @returns the class name
  60263. */
  60264. getClassName(): string;
  60265. /**
  60266. * Returns the integer 0.
  60267. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60268. */
  60269. getTypeID(): number;
  60270. /**
  60271. * Specifies wether or not the shadowmap should be a cube texture.
  60272. * @returns true if the shadowmap needs to be a cube texture.
  60273. */
  60274. needCube(): boolean;
  60275. /**
  60276. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  60277. * @param faceIndex The index of the face we are computed the direction to generate shadow
  60278. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  60279. */
  60280. getShadowDirection(faceIndex?: number): Vector3;
  60281. /**
  60282. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  60283. * - fov = PI / 2
  60284. * - aspect ratio : 1.0
  60285. * - z-near and far equal to the active camera minZ and maxZ.
  60286. * Returns the PointLight.
  60287. */
  60288. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60289. protected _buildUniformLayout(): void;
  60290. /**
  60291. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  60292. * @param effect The effect to update
  60293. * @param lightIndex The index of the light in the effect to update
  60294. * @returns The point light
  60295. */
  60296. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  60297. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60298. /**
  60299. * Prepares the list of defines specific to the light type.
  60300. * @param defines the list of defines
  60301. * @param lightIndex defines the index of the light for the effect
  60302. */
  60303. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60304. }
  60305. }
  60306. declare module BABYLON {
  60307. /**
  60308. * Header information of HDR texture files.
  60309. */
  60310. export interface HDRInfo {
  60311. /**
  60312. * The height of the texture in pixels.
  60313. */
  60314. height: number;
  60315. /**
  60316. * The width of the texture in pixels.
  60317. */
  60318. width: number;
  60319. /**
  60320. * The index of the beginning of the data in the binary file.
  60321. */
  60322. dataPosition: number;
  60323. }
  60324. /**
  60325. * This groups tools to convert HDR texture to native colors array.
  60326. */
  60327. export class HDRTools {
  60328. private static Ldexp;
  60329. private static Rgbe2float;
  60330. private static readStringLine;
  60331. /**
  60332. * Reads header information from an RGBE texture stored in a native array.
  60333. * More information on this format are available here:
  60334. * https://en.wikipedia.org/wiki/RGBE_image_format
  60335. *
  60336. * @param uint8array The binary file stored in native array.
  60337. * @return The header information.
  60338. */
  60339. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  60340. /**
  60341. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  60342. * This RGBE texture needs to store the information as a panorama.
  60343. *
  60344. * More information on this format are available here:
  60345. * https://en.wikipedia.org/wiki/RGBE_image_format
  60346. *
  60347. * @param buffer The binary file stored in an array buffer.
  60348. * @param size The expected size of the extracted cubemap.
  60349. * @return The Cube Map information.
  60350. */
  60351. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  60352. /**
  60353. * Returns the pixels data extracted from an RGBE texture.
  60354. * This pixels will be stored left to right up to down in the R G B order in one array.
  60355. *
  60356. * More information on this format are available here:
  60357. * https://en.wikipedia.org/wiki/RGBE_image_format
  60358. *
  60359. * @param uint8array The binary file stored in an array buffer.
  60360. * @param hdrInfo The header information of the file.
  60361. * @return The pixels data in RGB right to left up to down order.
  60362. */
  60363. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  60364. private static RGBE_ReadPixels_RLE;
  60365. private static RGBE_ReadPixels_NOT_RLE;
  60366. }
  60367. }
  60368. declare module BABYLON {
  60369. /**
  60370. * Effect Render Options
  60371. */
  60372. export interface IEffectRendererOptions {
  60373. /**
  60374. * Defines the vertices positions.
  60375. */
  60376. positions?: number[];
  60377. /**
  60378. * Defines the indices.
  60379. */
  60380. indices?: number[];
  60381. }
  60382. /**
  60383. * Helper class to render one or more effects.
  60384. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60385. */
  60386. export class EffectRenderer {
  60387. private engine;
  60388. private static _DefaultOptions;
  60389. private _vertexBuffers;
  60390. private _indexBuffer;
  60391. private _fullscreenViewport;
  60392. /**
  60393. * Creates an effect renderer
  60394. * @param engine the engine to use for rendering
  60395. * @param options defines the options of the effect renderer
  60396. */
  60397. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60398. /**
  60399. * Sets the current viewport in normalized coordinates 0-1
  60400. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60401. */
  60402. setViewport(viewport?: Viewport): void;
  60403. /**
  60404. * Binds the embedded attributes buffer to the effect.
  60405. * @param effect Defines the effect to bind the attributes for
  60406. */
  60407. bindBuffers(effect: Effect): void;
  60408. /**
  60409. * Sets the current effect wrapper to use during draw.
  60410. * The effect needs to be ready before calling this api.
  60411. * This also sets the default full screen position attribute.
  60412. * @param effectWrapper Defines the effect to draw with
  60413. */
  60414. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60415. /**
  60416. * Restores engine states
  60417. */
  60418. restoreStates(): void;
  60419. /**
  60420. * Draws a full screen quad.
  60421. */
  60422. draw(): void;
  60423. private isRenderTargetTexture;
  60424. /**
  60425. * renders one or more effects to a specified texture
  60426. * @param effectWrapper the effect to renderer
  60427. * @param outputTexture texture to draw to, if null it will render to the screen.
  60428. */
  60429. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60430. /**
  60431. * Disposes of the effect renderer
  60432. */
  60433. dispose(): void;
  60434. }
  60435. /**
  60436. * Options to create an EffectWrapper
  60437. */
  60438. interface EffectWrapperCreationOptions {
  60439. /**
  60440. * Engine to use to create the effect
  60441. */
  60442. engine: ThinEngine;
  60443. /**
  60444. * Fragment shader for the effect
  60445. */
  60446. fragmentShader: string;
  60447. /**
  60448. * Use the shader store instead of direct source code
  60449. */
  60450. useShaderStore?: boolean;
  60451. /**
  60452. * Vertex shader for the effect
  60453. */
  60454. vertexShader?: string;
  60455. /**
  60456. * Attributes to use in the shader
  60457. */
  60458. attributeNames?: Array<string>;
  60459. /**
  60460. * Uniforms to use in the shader
  60461. */
  60462. uniformNames?: Array<string>;
  60463. /**
  60464. * Texture sampler names to use in the shader
  60465. */
  60466. samplerNames?: Array<string>;
  60467. /**
  60468. * Defines to use in the shader
  60469. */
  60470. defines?: Array<string>;
  60471. /**
  60472. * Callback when effect is compiled
  60473. */
  60474. onCompiled?: Nullable<(effect: Effect) => void>;
  60475. /**
  60476. * The friendly name of the effect displayed in Spector.
  60477. */
  60478. name?: string;
  60479. }
  60480. /**
  60481. * Wraps an effect to be used for rendering
  60482. */
  60483. export class EffectWrapper {
  60484. /**
  60485. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60486. */
  60487. onApplyObservable: Observable<{}>;
  60488. /**
  60489. * The underlying effect
  60490. */
  60491. effect: Effect;
  60492. /**
  60493. * Creates an effect to be renderer
  60494. * @param creationOptions options to create the effect
  60495. */
  60496. constructor(creationOptions: EffectWrapperCreationOptions);
  60497. /**
  60498. * Disposes of the effect wrapper
  60499. */
  60500. dispose(): void;
  60501. }
  60502. }
  60503. declare module BABYLON {
  60504. /** @hidden */
  60505. export var hdrFilteringVertexShader: {
  60506. name: string;
  60507. shader: string;
  60508. };
  60509. }
  60510. declare module BABYLON {
  60511. /** @hidden */
  60512. export var hdrFilteringPixelShader: {
  60513. name: string;
  60514. shader: string;
  60515. };
  60516. }
  60517. declare module BABYLON {
  60518. /**
  60519. * Options for texture filtering
  60520. */
  60521. interface IHDRFilteringOptions {
  60522. /**
  60523. * Scales pixel intensity for the input HDR map.
  60524. */
  60525. hdrScale?: number;
  60526. /**
  60527. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  60528. */
  60529. quality?: number;
  60530. }
  60531. /**
  60532. * Filters HDR maps to get correct renderings of PBR reflections
  60533. */
  60534. export class HDRFiltering {
  60535. private _engine;
  60536. private _effectRenderer;
  60537. private _effectWrapper;
  60538. private _lodGenerationOffset;
  60539. private _lodGenerationScale;
  60540. /**
  60541. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  60542. * you care about baking speed.
  60543. */
  60544. quality: number;
  60545. /**
  60546. * Scales pixel intensity for the input HDR map.
  60547. */
  60548. hdrScale: number;
  60549. /**
  60550. * Instantiates HDR filter for reflection maps
  60551. *
  60552. * @param engine Thin engine
  60553. * @param options Options
  60554. */
  60555. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  60556. private _createRenderTarget;
  60557. private _prefilterInternal;
  60558. private _createEffect;
  60559. /**
  60560. * Get a value indicating if the filter is ready to be used
  60561. * @param texture Texture to filter
  60562. * @returns true if the filter is ready
  60563. */
  60564. isReady(texture: BaseTexture): boolean;
  60565. /**
  60566. * Prefilters a cube texture to have mipmap levels representing roughness values.
  60567. * Prefiltering will be invoked at the end of next rendering pass.
  60568. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  60569. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  60570. * @param texture Texture to filter
  60571. * @param onFinished Callback when filtering is done
  60572. * @return Promise called when prefiltering is done
  60573. */
  60574. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  60575. }
  60576. }
  60577. declare module BABYLON {
  60578. /**
  60579. * This represents a texture coming from an HDR input.
  60580. *
  60581. * The only supported format is currently panorama picture stored in RGBE format.
  60582. * Example of such files can be found on HDRLib: http://hdrlib.com/
  60583. */
  60584. export class HDRCubeTexture extends BaseTexture {
  60585. private static _facesMapping;
  60586. private _generateHarmonics;
  60587. private _noMipmap;
  60588. private _prefilterOnLoad;
  60589. private _textureMatrix;
  60590. private _size;
  60591. private _onLoad;
  60592. private _onError;
  60593. /**
  60594. * The texture URL.
  60595. */
  60596. url: string;
  60597. protected _isBlocking: boolean;
  60598. /**
  60599. * Sets wether or not the texture is blocking during loading.
  60600. */
  60601. set isBlocking(value: boolean);
  60602. /**
  60603. * Gets wether or not the texture is blocking during loading.
  60604. */
  60605. get isBlocking(): boolean;
  60606. protected _rotationY: number;
  60607. /**
  60608. * Sets texture matrix rotation angle around Y axis in radians.
  60609. */
  60610. set rotationY(value: number);
  60611. /**
  60612. * Gets texture matrix rotation angle around Y axis radians.
  60613. */
  60614. get rotationY(): number;
  60615. /**
  60616. * Gets or sets the center of the bounding box associated with the cube texture
  60617. * It must define where the camera used to render the texture was set
  60618. */
  60619. boundingBoxPosition: Vector3;
  60620. private _boundingBoxSize;
  60621. /**
  60622. * Gets or sets the size of the bounding box associated with the cube texture
  60623. * When defined, the cubemap will switch to local mode
  60624. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  60625. * @example https://www.babylonjs-playground.com/#RNASML
  60626. */
  60627. set boundingBoxSize(value: Vector3);
  60628. get boundingBoxSize(): Vector3;
  60629. /**
  60630. * Instantiates an HDRTexture from the following parameters.
  60631. *
  60632. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  60633. * @param sceneOrEngine The scene or engine the texture will be used in
  60634. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60635. * @param noMipmap Forces to not generate the mipmap if true
  60636. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  60637. * @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)
  60638. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  60639. */
  60640. 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>);
  60641. /**
  60642. * Get the current class name of the texture useful for serialization or dynamic coding.
  60643. * @returns "HDRCubeTexture"
  60644. */
  60645. getClassName(): string;
  60646. /**
  60647. * Occurs when the file is raw .hdr file.
  60648. */
  60649. private loadTexture;
  60650. clone(): HDRCubeTexture;
  60651. delayLoad(): void;
  60652. /**
  60653. * Get the texture reflection matrix used to rotate/transform the reflection.
  60654. * @returns the reflection matrix
  60655. */
  60656. getReflectionTextureMatrix(): Matrix;
  60657. /**
  60658. * Set the texture reflection matrix used to rotate/transform the reflection.
  60659. * @param value Define the reflection matrix to set
  60660. */
  60661. setReflectionTextureMatrix(value: Matrix): void;
  60662. /**
  60663. * Parses a JSON representation of an HDR Texture in order to create the texture
  60664. * @param parsedTexture Define the JSON representation
  60665. * @param scene Define the scene the texture should be created in
  60666. * @param rootUrl Define the root url in case we need to load relative dependencies
  60667. * @returns the newly created texture after parsing
  60668. */
  60669. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  60670. serialize(): any;
  60671. }
  60672. }
  60673. declare module BABYLON {
  60674. /**
  60675. * Class used to control physics engine
  60676. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60677. */
  60678. export class PhysicsEngine implements IPhysicsEngine {
  60679. private _physicsPlugin;
  60680. /**
  60681. * Global value used to control the smallest number supported by the simulation
  60682. */
  60683. static Epsilon: number;
  60684. private _impostors;
  60685. private _joints;
  60686. private _subTimeStep;
  60687. /**
  60688. * Gets the gravity vector used by the simulation
  60689. */
  60690. gravity: Vector3;
  60691. /**
  60692. * Factory used to create the default physics plugin.
  60693. * @returns The default physics plugin
  60694. */
  60695. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  60696. /**
  60697. * Creates a new Physics Engine
  60698. * @param gravity defines the gravity vector used by the simulation
  60699. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  60700. */
  60701. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  60702. /**
  60703. * Sets the gravity vector used by the simulation
  60704. * @param gravity defines the gravity vector to use
  60705. */
  60706. setGravity(gravity: Vector3): void;
  60707. /**
  60708. * Set the time step of the physics engine.
  60709. * Default is 1/60.
  60710. * To slow it down, enter 1/600 for example.
  60711. * To speed it up, 1/30
  60712. * @param newTimeStep defines the new timestep to apply to this world.
  60713. */
  60714. setTimeStep(newTimeStep?: number): void;
  60715. /**
  60716. * Get the time step of the physics engine.
  60717. * @returns the current time step
  60718. */
  60719. getTimeStep(): number;
  60720. /**
  60721. * Set the sub time step of the physics engine.
  60722. * Default is 0 meaning there is no sub steps
  60723. * To increase physics resolution precision, set a small value (like 1 ms)
  60724. * @param subTimeStep defines the new sub timestep used for physics resolution.
  60725. */
  60726. setSubTimeStep(subTimeStep?: number): void;
  60727. /**
  60728. * Get the sub time step of the physics engine.
  60729. * @returns the current sub time step
  60730. */
  60731. getSubTimeStep(): number;
  60732. /**
  60733. * Release all resources
  60734. */
  60735. dispose(): void;
  60736. /**
  60737. * Gets the name of the current physics plugin
  60738. * @returns the name of the plugin
  60739. */
  60740. getPhysicsPluginName(): string;
  60741. /**
  60742. * Adding a new impostor for the impostor tracking.
  60743. * This will be done by the impostor itself.
  60744. * @param impostor the impostor to add
  60745. */
  60746. addImpostor(impostor: PhysicsImpostor): void;
  60747. /**
  60748. * Remove an impostor from the engine.
  60749. * This impostor and its mesh will not longer be updated by the physics engine.
  60750. * @param impostor the impostor to remove
  60751. */
  60752. removeImpostor(impostor: PhysicsImpostor): void;
  60753. /**
  60754. * Add a joint to the physics engine
  60755. * @param mainImpostor defines the main impostor to which the joint is added.
  60756. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  60757. * @param joint defines the joint that will connect both impostors.
  60758. */
  60759. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60760. /**
  60761. * Removes a joint from the simulation
  60762. * @param mainImpostor defines the impostor used with the joint
  60763. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  60764. * @param joint defines the joint to remove
  60765. */
  60766. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60767. /**
  60768. * Called by the scene. No need to call it.
  60769. * @param delta defines the timespam between frames
  60770. */
  60771. _step(delta: number): void;
  60772. /**
  60773. * Gets the current plugin used to run the simulation
  60774. * @returns current plugin
  60775. */
  60776. getPhysicsPlugin(): IPhysicsEnginePlugin;
  60777. /**
  60778. * Gets the list of physic impostors
  60779. * @returns an array of PhysicsImpostor
  60780. */
  60781. getImpostors(): Array<PhysicsImpostor>;
  60782. /**
  60783. * Gets the impostor for a physics enabled object
  60784. * @param object defines the object impersonated by the impostor
  60785. * @returns the PhysicsImpostor or null if not found
  60786. */
  60787. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  60788. /**
  60789. * Gets the impostor for a physics body object
  60790. * @param body defines physics body used by the impostor
  60791. * @returns the PhysicsImpostor or null if not found
  60792. */
  60793. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  60794. /**
  60795. * Does a raycast in the physics world
  60796. * @param from when should the ray start?
  60797. * @param to when should the ray end?
  60798. * @returns PhysicsRaycastResult
  60799. */
  60800. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60801. }
  60802. }
  60803. declare module BABYLON {
  60804. /** @hidden */
  60805. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  60806. private _useDeltaForWorldStep;
  60807. world: any;
  60808. name: string;
  60809. private _physicsMaterials;
  60810. private _fixedTimeStep;
  60811. private _cannonRaycastResult;
  60812. private _raycastResult;
  60813. private _physicsBodysToRemoveAfterStep;
  60814. private _firstFrame;
  60815. BJSCANNON: any;
  60816. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  60817. setGravity(gravity: Vector3): void;
  60818. setTimeStep(timeStep: number): void;
  60819. getTimeStep(): number;
  60820. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60821. private _removeMarkedPhysicsBodiesFromWorld;
  60822. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60823. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60824. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60825. private _processChildMeshes;
  60826. removePhysicsBody(impostor: PhysicsImpostor): void;
  60827. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60828. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60829. private _addMaterial;
  60830. private _checkWithEpsilon;
  60831. private _createShape;
  60832. private _createHeightmap;
  60833. private _minus90X;
  60834. private _plus90X;
  60835. private _tmpPosition;
  60836. private _tmpDeltaPosition;
  60837. private _tmpUnityRotation;
  60838. private _updatePhysicsBodyTransformation;
  60839. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60840. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60841. isSupported(): boolean;
  60842. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60843. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60844. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60845. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60846. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60847. getBodyMass(impostor: PhysicsImpostor): number;
  60848. getBodyFriction(impostor: PhysicsImpostor): number;
  60849. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60850. getBodyRestitution(impostor: PhysicsImpostor): number;
  60851. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60852. sleepBody(impostor: PhysicsImpostor): void;
  60853. wakeUpBody(impostor: PhysicsImpostor): void;
  60854. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  60855. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60856. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60857. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60858. getRadius(impostor: PhysicsImpostor): number;
  60859. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60860. dispose(): void;
  60861. private _extendNamespace;
  60862. /**
  60863. * Does a raycast in the physics world
  60864. * @param from when should the ray start?
  60865. * @param to when should the ray end?
  60866. * @returns PhysicsRaycastResult
  60867. */
  60868. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60869. }
  60870. }
  60871. declare module BABYLON {
  60872. /** @hidden */
  60873. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  60874. private _useDeltaForWorldStep;
  60875. world: any;
  60876. name: string;
  60877. BJSOIMO: any;
  60878. private _raycastResult;
  60879. private _fixedTimeStep;
  60880. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  60881. setGravity(gravity: Vector3): void;
  60882. setTimeStep(timeStep: number): void;
  60883. getTimeStep(): number;
  60884. private _tmpImpostorsArray;
  60885. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60886. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60887. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60888. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60889. private _tmpPositionVector;
  60890. removePhysicsBody(impostor: PhysicsImpostor): void;
  60891. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60892. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60893. isSupported(): boolean;
  60894. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60895. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60896. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60897. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60898. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60899. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60900. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60901. getBodyMass(impostor: PhysicsImpostor): number;
  60902. getBodyFriction(impostor: PhysicsImpostor): number;
  60903. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60904. getBodyRestitution(impostor: PhysicsImpostor): number;
  60905. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60906. sleepBody(impostor: PhysicsImpostor): void;
  60907. wakeUpBody(impostor: PhysicsImpostor): void;
  60908. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60909. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  60910. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  60911. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60912. getRadius(impostor: PhysicsImpostor): number;
  60913. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60914. dispose(): void;
  60915. /**
  60916. * Does a raycast in the physics world
  60917. * @param from when should the ray start?
  60918. * @param to when should the ray end?
  60919. * @returns PhysicsRaycastResult
  60920. */
  60921. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60922. }
  60923. }
  60924. declare module BABYLON {
  60925. /**
  60926. * AmmoJS Physics plugin
  60927. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60928. * @see https://github.com/kripken/ammo.js/
  60929. */
  60930. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  60931. private _useDeltaForWorldStep;
  60932. /**
  60933. * Reference to the Ammo library
  60934. */
  60935. bjsAMMO: any;
  60936. /**
  60937. * Created ammoJS world which physics bodies are added to
  60938. */
  60939. world: any;
  60940. /**
  60941. * Name of the plugin
  60942. */
  60943. name: string;
  60944. private _timeStep;
  60945. private _fixedTimeStep;
  60946. private _maxSteps;
  60947. private _tmpQuaternion;
  60948. private _tmpAmmoTransform;
  60949. private _tmpAmmoQuaternion;
  60950. private _tmpAmmoConcreteContactResultCallback;
  60951. private _collisionConfiguration;
  60952. private _dispatcher;
  60953. private _overlappingPairCache;
  60954. private _solver;
  60955. private _softBodySolver;
  60956. private _tmpAmmoVectorA;
  60957. private _tmpAmmoVectorB;
  60958. private _tmpAmmoVectorC;
  60959. private _tmpAmmoVectorD;
  60960. private _tmpContactCallbackResult;
  60961. private _tmpAmmoVectorRCA;
  60962. private _tmpAmmoVectorRCB;
  60963. private _raycastResult;
  60964. private static readonly DISABLE_COLLISION_FLAG;
  60965. private static readonly KINEMATIC_FLAG;
  60966. private static readonly DISABLE_DEACTIVATION_FLAG;
  60967. /**
  60968. * Initializes the ammoJS plugin
  60969. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  60970. * @param ammoInjection can be used to inject your own ammo reference
  60971. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  60972. */
  60973. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  60974. /**
  60975. * Sets the gravity of the physics world (m/(s^2))
  60976. * @param gravity Gravity to set
  60977. */
  60978. setGravity(gravity: Vector3): void;
  60979. /**
  60980. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  60981. * @param timeStep timestep to use in seconds
  60982. */
  60983. setTimeStep(timeStep: number): void;
  60984. /**
  60985. * 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)
  60986. * @param fixedTimeStep fixedTimeStep to use in seconds
  60987. */
  60988. setFixedTimeStep(fixedTimeStep: number): void;
  60989. /**
  60990. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  60991. * @param maxSteps the maximum number of steps by the physics engine per frame
  60992. */
  60993. setMaxSteps(maxSteps: number): void;
  60994. /**
  60995. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  60996. * @returns the current timestep in seconds
  60997. */
  60998. getTimeStep(): number;
  60999. /**
  61000. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  61001. */
  61002. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  61003. private _isImpostorInContact;
  61004. private _isImpostorPairInContact;
  61005. private _stepSimulation;
  61006. /**
  61007. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  61008. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  61009. * After the step the babylon meshes are set to the position of the physics imposters
  61010. * @param delta amount of time to step forward
  61011. * @param impostors array of imposters to update before/after the step
  61012. */
  61013. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61014. /**
  61015. * Update babylon mesh to match physics world object
  61016. * @param impostor imposter to match
  61017. */
  61018. private _afterSoftStep;
  61019. /**
  61020. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61021. * @param impostor imposter to match
  61022. */
  61023. private _ropeStep;
  61024. /**
  61025. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61026. * @param impostor imposter to match
  61027. */
  61028. private _softbodyOrClothStep;
  61029. private _tmpMatrix;
  61030. /**
  61031. * Applies an impulse on the imposter
  61032. * @param impostor imposter to apply impulse to
  61033. * @param force amount of force to be applied to the imposter
  61034. * @param contactPoint the location to apply the impulse on the imposter
  61035. */
  61036. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61037. /**
  61038. * Applies a force on the imposter
  61039. * @param impostor imposter to apply force
  61040. * @param force amount of force to be applied to the imposter
  61041. * @param contactPoint the location to apply the force on the imposter
  61042. */
  61043. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61044. /**
  61045. * Creates a physics body using the plugin
  61046. * @param impostor the imposter to create the physics body on
  61047. */
  61048. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61049. /**
  61050. * Removes the physics body from the imposter and disposes of the body's memory
  61051. * @param impostor imposter to remove the physics body from
  61052. */
  61053. removePhysicsBody(impostor: PhysicsImpostor): void;
  61054. /**
  61055. * Generates a joint
  61056. * @param impostorJoint the imposter joint to create the joint with
  61057. */
  61058. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61059. /**
  61060. * Removes a joint
  61061. * @param impostorJoint the imposter joint to remove the joint from
  61062. */
  61063. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61064. private _addMeshVerts;
  61065. /**
  61066. * Initialise the soft body vertices to match its object's (mesh) vertices
  61067. * Softbody vertices (nodes) are in world space and to match this
  61068. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  61069. * @param impostor to create the softbody for
  61070. */
  61071. private _softVertexData;
  61072. /**
  61073. * Create an impostor's soft body
  61074. * @param impostor to create the softbody for
  61075. */
  61076. private _createSoftbody;
  61077. /**
  61078. * Create cloth for an impostor
  61079. * @param impostor to create the softbody for
  61080. */
  61081. private _createCloth;
  61082. /**
  61083. * Create rope for an impostor
  61084. * @param impostor to create the softbody for
  61085. */
  61086. private _createRope;
  61087. /**
  61088. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  61089. * @param impostor to create the custom physics shape for
  61090. */
  61091. private _createCustom;
  61092. private _addHullVerts;
  61093. private _createShape;
  61094. /**
  61095. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  61096. * @param impostor imposter containing the physics body and babylon object
  61097. */
  61098. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61099. /**
  61100. * Sets the babylon object's position/rotation from the physics body's position/rotation
  61101. * @param impostor imposter containing the physics body and babylon object
  61102. * @param newPosition new position
  61103. * @param newRotation new rotation
  61104. */
  61105. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61106. /**
  61107. * If this plugin is supported
  61108. * @returns true if its supported
  61109. */
  61110. isSupported(): boolean;
  61111. /**
  61112. * Sets the linear velocity of the physics body
  61113. * @param impostor imposter to set the velocity on
  61114. * @param velocity velocity to set
  61115. */
  61116. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61117. /**
  61118. * Sets the angular velocity of the physics body
  61119. * @param impostor imposter to set the velocity on
  61120. * @param velocity velocity to set
  61121. */
  61122. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61123. /**
  61124. * gets the linear velocity
  61125. * @param impostor imposter to get linear velocity from
  61126. * @returns linear velocity
  61127. */
  61128. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61129. /**
  61130. * gets the angular velocity
  61131. * @param impostor imposter to get angular velocity from
  61132. * @returns angular velocity
  61133. */
  61134. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61135. /**
  61136. * Sets the mass of physics body
  61137. * @param impostor imposter to set the mass on
  61138. * @param mass mass to set
  61139. */
  61140. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61141. /**
  61142. * Gets the mass of the physics body
  61143. * @param impostor imposter to get the mass from
  61144. * @returns mass
  61145. */
  61146. getBodyMass(impostor: PhysicsImpostor): number;
  61147. /**
  61148. * Gets friction of the impostor
  61149. * @param impostor impostor to get friction from
  61150. * @returns friction value
  61151. */
  61152. getBodyFriction(impostor: PhysicsImpostor): number;
  61153. /**
  61154. * Sets friction of the impostor
  61155. * @param impostor impostor to set friction on
  61156. * @param friction friction value
  61157. */
  61158. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61159. /**
  61160. * Gets restitution of the impostor
  61161. * @param impostor impostor to get restitution from
  61162. * @returns restitution value
  61163. */
  61164. getBodyRestitution(impostor: PhysicsImpostor): number;
  61165. /**
  61166. * Sets resitution of the impostor
  61167. * @param impostor impostor to set resitution on
  61168. * @param restitution resitution value
  61169. */
  61170. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61171. /**
  61172. * Gets pressure inside the impostor
  61173. * @param impostor impostor to get pressure from
  61174. * @returns pressure value
  61175. */
  61176. getBodyPressure(impostor: PhysicsImpostor): number;
  61177. /**
  61178. * Sets pressure inside a soft body impostor
  61179. * Cloth and rope must remain 0 pressure
  61180. * @param impostor impostor to set pressure on
  61181. * @param pressure pressure value
  61182. */
  61183. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  61184. /**
  61185. * Gets stiffness of the impostor
  61186. * @param impostor impostor to get stiffness from
  61187. * @returns pressure value
  61188. */
  61189. getBodyStiffness(impostor: PhysicsImpostor): number;
  61190. /**
  61191. * Sets stiffness of the impostor
  61192. * @param impostor impostor to set stiffness on
  61193. * @param stiffness stiffness value from 0 to 1
  61194. */
  61195. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  61196. /**
  61197. * Gets velocityIterations of the impostor
  61198. * @param impostor impostor to get velocity iterations from
  61199. * @returns velocityIterations value
  61200. */
  61201. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  61202. /**
  61203. * Sets velocityIterations of the impostor
  61204. * @param impostor impostor to set velocity iterations on
  61205. * @param velocityIterations velocityIterations value
  61206. */
  61207. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  61208. /**
  61209. * Gets positionIterations of the impostor
  61210. * @param impostor impostor to get position iterations from
  61211. * @returns positionIterations value
  61212. */
  61213. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  61214. /**
  61215. * Sets positionIterations of the impostor
  61216. * @param impostor impostor to set position on
  61217. * @param positionIterations positionIterations value
  61218. */
  61219. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  61220. /**
  61221. * Append an anchor to a cloth object
  61222. * @param impostor is the cloth impostor to add anchor to
  61223. * @param otherImpostor is the rigid impostor to anchor to
  61224. * @param width ratio across width from 0 to 1
  61225. * @param height ratio up height from 0 to 1
  61226. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  61227. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61228. */
  61229. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61230. /**
  61231. * Append an hook to a rope object
  61232. * @param impostor is the rope impostor to add hook to
  61233. * @param otherImpostor is the rigid impostor to hook to
  61234. * @param length ratio along the rope from 0 to 1
  61235. * @param influence the elasticity between soft 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. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61239. /**
  61240. * Sleeps the physics body and stops it from being active
  61241. * @param impostor impostor to sleep
  61242. */
  61243. sleepBody(impostor: PhysicsImpostor): void;
  61244. /**
  61245. * Activates the physics body
  61246. * @param impostor impostor to activate
  61247. */
  61248. wakeUpBody(impostor: PhysicsImpostor): void;
  61249. /**
  61250. * Updates the distance parameters of the joint
  61251. * @param joint joint to update
  61252. * @param maxDistance maximum distance of the joint
  61253. * @param minDistance minimum distance of the joint
  61254. */
  61255. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61256. /**
  61257. * Sets a motor on the joint
  61258. * @param joint joint to set motor on
  61259. * @param speed speed of the motor
  61260. * @param maxForce maximum force of the motor
  61261. * @param motorIndex index of the motor
  61262. */
  61263. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61264. /**
  61265. * Sets the motors limit
  61266. * @param joint joint to set limit on
  61267. * @param upperLimit upper limit
  61268. * @param lowerLimit lower limit
  61269. */
  61270. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61271. /**
  61272. * Syncs the position and rotation of a mesh with the impostor
  61273. * @param mesh mesh to sync
  61274. * @param impostor impostor to update the mesh with
  61275. */
  61276. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61277. /**
  61278. * Gets the radius of the impostor
  61279. * @param impostor impostor to get radius from
  61280. * @returns the radius
  61281. */
  61282. getRadius(impostor: PhysicsImpostor): number;
  61283. /**
  61284. * Gets the box size of the impostor
  61285. * @param impostor impostor to get box size from
  61286. * @param result the resulting box size
  61287. */
  61288. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61289. /**
  61290. * Disposes of the impostor
  61291. */
  61292. dispose(): void;
  61293. /**
  61294. * Does a raycast in the physics world
  61295. * @param from when should the ray start?
  61296. * @param to when should the ray end?
  61297. * @returns PhysicsRaycastResult
  61298. */
  61299. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61300. }
  61301. }
  61302. declare module BABYLON {
  61303. interface AbstractScene {
  61304. /**
  61305. * The list of reflection probes added to the scene
  61306. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61307. */
  61308. reflectionProbes: Array<ReflectionProbe>;
  61309. /**
  61310. * Removes the given reflection probe from this scene.
  61311. * @param toRemove The reflection probe to remove
  61312. * @returns The index of the removed reflection probe
  61313. */
  61314. removeReflectionProbe(toRemove: ReflectionProbe): number;
  61315. /**
  61316. * Adds the given reflection probe to this scene.
  61317. * @param newReflectionProbe The reflection probe to add
  61318. */
  61319. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  61320. }
  61321. /**
  61322. * Class used to generate realtime reflection / refraction cube textures
  61323. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61324. */
  61325. export class ReflectionProbe {
  61326. /** defines the name of the probe */
  61327. name: string;
  61328. private _scene;
  61329. private _renderTargetTexture;
  61330. private _projectionMatrix;
  61331. private _viewMatrix;
  61332. private _target;
  61333. private _add;
  61334. private _attachedMesh;
  61335. private _invertYAxis;
  61336. /** Gets or sets probe position (center of the cube map) */
  61337. position: Vector3;
  61338. /**
  61339. * Creates a new reflection probe
  61340. * @param name defines the name of the probe
  61341. * @param size defines the texture resolution (for each face)
  61342. * @param scene defines the hosting scene
  61343. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  61344. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  61345. */
  61346. constructor(
  61347. /** defines the name of the probe */
  61348. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  61349. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  61350. get samples(): number;
  61351. set samples(value: number);
  61352. /** Gets or sets the refresh rate to use (on every frame by default) */
  61353. get refreshRate(): number;
  61354. set refreshRate(value: number);
  61355. /**
  61356. * Gets the hosting scene
  61357. * @returns a Scene
  61358. */
  61359. getScene(): Scene;
  61360. /** Gets the internal CubeTexture used to render to */
  61361. get cubeTexture(): RenderTargetTexture;
  61362. /** Gets the list of meshes to render */
  61363. get renderList(): Nullable<AbstractMesh[]>;
  61364. /**
  61365. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  61366. * @param mesh defines the mesh to attach to
  61367. */
  61368. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  61369. /**
  61370. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  61371. * @param renderingGroupId The rendering group id corresponding to its index
  61372. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  61373. */
  61374. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  61375. /**
  61376. * Clean all associated resources
  61377. */
  61378. dispose(): void;
  61379. /**
  61380. * Converts the reflection probe information to a readable string for debug purpose.
  61381. * @param fullDetails Supports for multiple levels of logging within scene loading
  61382. * @returns the human readable reflection probe info
  61383. */
  61384. toString(fullDetails?: boolean): string;
  61385. /**
  61386. * Get the class name of the relfection probe.
  61387. * @returns "ReflectionProbe"
  61388. */
  61389. getClassName(): string;
  61390. /**
  61391. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  61392. * @returns The JSON representation of the texture
  61393. */
  61394. serialize(): any;
  61395. /**
  61396. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  61397. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  61398. * @param scene Define the scene the parsed reflection probe should be instantiated in
  61399. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  61400. * @returns The parsed reflection probe if successful
  61401. */
  61402. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  61403. }
  61404. }
  61405. declare module BABYLON {
  61406. /** @hidden */
  61407. export var _BabylonLoaderRegistered: boolean;
  61408. /**
  61409. * Helps setting up some configuration for the babylon file loader.
  61410. */
  61411. export class BabylonFileLoaderConfiguration {
  61412. /**
  61413. * The loader does not allow injecting custom physix engine into the plugins.
  61414. * Unfortunately in ES6, we need to manually inject them into the plugin.
  61415. * So you could set this variable to your engine import to make it work.
  61416. */
  61417. static LoaderInjectedPhysicsEngine: any;
  61418. }
  61419. }
  61420. declare module BABYLON {
  61421. /**
  61422. * The Physically based simple base material of BJS.
  61423. *
  61424. * This enables better naming and convention enforcements on top of the pbrMaterial.
  61425. * It is used as the base class for both the specGloss and metalRough conventions.
  61426. */
  61427. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  61428. /**
  61429. * Number of Simultaneous lights allowed on the material.
  61430. */
  61431. maxSimultaneousLights: number;
  61432. /**
  61433. * If sets to true, disables all the lights affecting the material.
  61434. */
  61435. disableLighting: boolean;
  61436. /**
  61437. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  61438. */
  61439. environmentTexture: BaseTexture;
  61440. /**
  61441. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  61442. */
  61443. invertNormalMapX: boolean;
  61444. /**
  61445. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  61446. */
  61447. invertNormalMapY: boolean;
  61448. /**
  61449. * Normal map used in the model.
  61450. */
  61451. normalTexture: BaseTexture;
  61452. /**
  61453. * Emissivie color used to self-illuminate the model.
  61454. */
  61455. emissiveColor: Color3;
  61456. /**
  61457. * Emissivie texture used to self-illuminate the model.
  61458. */
  61459. emissiveTexture: BaseTexture;
  61460. /**
  61461. * Occlusion Channel Strenght.
  61462. */
  61463. occlusionStrength: number;
  61464. /**
  61465. * Occlusion Texture of the material (adding extra occlusion effects).
  61466. */
  61467. occlusionTexture: BaseTexture;
  61468. /**
  61469. * Defines the alpha limits in alpha test mode.
  61470. */
  61471. alphaCutOff: number;
  61472. /**
  61473. * Gets the current double sided mode.
  61474. */
  61475. get doubleSided(): boolean;
  61476. /**
  61477. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  61478. */
  61479. set doubleSided(value: boolean);
  61480. /**
  61481. * Stores the pre-calculated light information of a mesh in a texture.
  61482. */
  61483. lightmapTexture: BaseTexture;
  61484. /**
  61485. * If true, the light map contains occlusion information instead of lighting info.
  61486. */
  61487. useLightmapAsShadowmap: boolean;
  61488. /**
  61489. * Instantiates a new PBRMaterial instance.
  61490. *
  61491. * @param name The material name
  61492. * @param scene The scene the material will be use in.
  61493. */
  61494. constructor(name: string, scene: Scene);
  61495. getClassName(): string;
  61496. }
  61497. }
  61498. declare module BABYLON {
  61499. /**
  61500. * The PBR material of BJS following the metal roughness convention.
  61501. *
  61502. * This fits to the PBR convention in the GLTF definition:
  61503. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  61504. */
  61505. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  61506. /**
  61507. * The base color has two different interpretations depending on the value of metalness.
  61508. * When the material is a metal, the base color is the specific measured reflectance value
  61509. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  61510. * of the material.
  61511. */
  61512. baseColor: Color3;
  61513. /**
  61514. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  61515. * well as opacity information in the alpha channel.
  61516. */
  61517. baseTexture: BaseTexture;
  61518. /**
  61519. * Specifies the metallic scalar value of the material.
  61520. * Can also be used to scale the metalness values of the metallic texture.
  61521. */
  61522. metallic: number;
  61523. /**
  61524. * Specifies the roughness scalar value of the material.
  61525. * Can also be used to scale the roughness values of the metallic texture.
  61526. */
  61527. roughness: number;
  61528. /**
  61529. * Texture containing both the metallic value in the B channel and the
  61530. * roughness value in the G channel to keep better precision.
  61531. */
  61532. metallicRoughnessTexture: BaseTexture;
  61533. /**
  61534. * Instantiates a new PBRMetalRoughnessMaterial instance.
  61535. *
  61536. * @param name The material name
  61537. * @param scene The scene the material will be use in.
  61538. */
  61539. constructor(name: string, scene: Scene);
  61540. /**
  61541. * Return the currrent class name of the material.
  61542. */
  61543. getClassName(): string;
  61544. /**
  61545. * Makes a duplicate of the current material.
  61546. * @param name - name to use for the new material.
  61547. */
  61548. clone(name: string): PBRMetallicRoughnessMaterial;
  61549. /**
  61550. * Serialize the material to a parsable JSON object.
  61551. */
  61552. serialize(): any;
  61553. /**
  61554. * Parses a JSON object correponding to the serialize function.
  61555. */
  61556. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  61557. }
  61558. }
  61559. declare module BABYLON {
  61560. /**
  61561. * The PBR material of BJS following the specular glossiness convention.
  61562. *
  61563. * This fits to the PBR convention in the GLTF definition:
  61564. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  61565. */
  61566. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  61567. /**
  61568. * Specifies the diffuse color of the material.
  61569. */
  61570. diffuseColor: Color3;
  61571. /**
  61572. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  61573. * channel.
  61574. */
  61575. diffuseTexture: BaseTexture;
  61576. /**
  61577. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  61578. */
  61579. specularColor: Color3;
  61580. /**
  61581. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  61582. */
  61583. glossiness: number;
  61584. /**
  61585. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  61586. */
  61587. specularGlossinessTexture: BaseTexture;
  61588. /**
  61589. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  61590. *
  61591. * @param name The material name
  61592. * @param scene The scene the material will be use in.
  61593. */
  61594. constructor(name: string, scene: Scene);
  61595. /**
  61596. * Return the currrent class name of the material.
  61597. */
  61598. getClassName(): string;
  61599. /**
  61600. * Makes a duplicate of the current material.
  61601. * @param name - name to use for the new material.
  61602. */
  61603. clone(name: string): PBRSpecularGlossinessMaterial;
  61604. /**
  61605. * Serialize the material to a parsable JSON object.
  61606. */
  61607. serialize(): any;
  61608. /**
  61609. * Parses a JSON object correponding to the serialize function.
  61610. */
  61611. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  61612. }
  61613. }
  61614. declare module BABYLON {
  61615. /**
  61616. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  61617. * It can help converting any input color in a desired output one. This can then be used to create effects
  61618. * from sepia, black and white to sixties or futuristic rendering...
  61619. *
  61620. * The only supported format is currently 3dl.
  61621. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  61622. */
  61623. export class ColorGradingTexture extends BaseTexture {
  61624. /**
  61625. * The texture URL.
  61626. */
  61627. url: string;
  61628. /**
  61629. * Empty line regex stored for GC.
  61630. */
  61631. private static _noneEmptyLineRegex;
  61632. private _textureMatrix;
  61633. private _onLoad;
  61634. /**
  61635. * Instantiates a ColorGradingTexture from the following parameters.
  61636. *
  61637. * @param url The location of the color gradind data (currently only supporting 3dl)
  61638. * @param sceneOrEngine The scene or engine the texture will be used in
  61639. * @param onLoad defines a callback triggered when the texture has been loaded
  61640. */
  61641. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  61642. /**
  61643. * Fires the onload event from the constructor if requested.
  61644. */
  61645. private _triggerOnLoad;
  61646. /**
  61647. * Returns the texture matrix used in most of the material.
  61648. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  61649. */
  61650. getTextureMatrix(): Matrix;
  61651. /**
  61652. * Occurs when the file being loaded is a .3dl LUT file.
  61653. */
  61654. private load3dlTexture;
  61655. /**
  61656. * Starts the loading process of the texture.
  61657. */
  61658. private loadTexture;
  61659. /**
  61660. * Clones the color gradind texture.
  61661. */
  61662. clone(): ColorGradingTexture;
  61663. /**
  61664. * Called during delayed load for textures.
  61665. */
  61666. delayLoad(): void;
  61667. /**
  61668. * Parses a color grading texture serialized by Babylon.
  61669. * @param parsedTexture The texture information being parsedTexture
  61670. * @param scene The scene to load the texture in
  61671. * @param rootUrl The root url of the data assets to load
  61672. * @return A color gradind texture
  61673. */
  61674. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  61675. /**
  61676. * Serializes the LUT texture to json format.
  61677. */
  61678. serialize(): any;
  61679. }
  61680. }
  61681. declare module BABYLON {
  61682. /**
  61683. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  61684. */
  61685. export class EquiRectangularCubeTexture extends BaseTexture {
  61686. /** The six faces of the cube. */
  61687. private static _FacesMapping;
  61688. private _noMipmap;
  61689. private _onLoad;
  61690. private _onError;
  61691. /** The size of the cubemap. */
  61692. private _size;
  61693. /** The buffer of the image. */
  61694. private _buffer;
  61695. /** The width of the input image. */
  61696. private _width;
  61697. /** The height of the input image. */
  61698. private _height;
  61699. /** The URL to the image. */
  61700. url: string;
  61701. /**
  61702. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  61703. * @param url The location of the image
  61704. * @param scene The scene the texture will be used in
  61705. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61706. * @param noMipmap Forces to not generate the mipmap if true
  61707. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61708. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61709. * @param onLoad — defines a callback called when texture is loaded
  61710. * @param onError — defines a callback called if there is an error
  61711. */
  61712. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  61713. /**
  61714. * Load the image data, by putting the image on a canvas and extracting its buffer.
  61715. */
  61716. private loadImage;
  61717. /**
  61718. * Convert the image buffer into a cubemap and create a CubeTexture.
  61719. */
  61720. private loadTexture;
  61721. /**
  61722. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  61723. * @param buffer The ArrayBuffer that should be converted.
  61724. * @returns The buffer as Float32Array.
  61725. */
  61726. private getFloat32ArrayFromArrayBuffer;
  61727. /**
  61728. * Get the current class name of the texture useful for serialization or dynamic coding.
  61729. * @returns "EquiRectangularCubeTexture"
  61730. */
  61731. getClassName(): string;
  61732. /**
  61733. * Create a clone of the current EquiRectangularCubeTexture and return it.
  61734. * @returns A clone of the current EquiRectangularCubeTexture.
  61735. */
  61736. clone(): EquiRectangularCubeTexture;
  61737. }
  61738. }
  61739. declare module BABYLON {
  61740. /**
  61741. * Defines the options related to the creation of an HtmlElementTexture
  61742. */
  61743. export interface IHtmlElementTextureOptions {
  61744. /**
  61745. * Defines wether mip maps should be created or not.
  61746. */
  61747. generateMipMaps?: boolean;
  61748. /**
  61749. * Defines the sampling mode of the texture.
  61750. */
  61751. samplingMode?: number;
  61752. /**
  61753. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  61754. */
  61755. engine: Nullable<ThinEngine>;
  61756. /**
  61757. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  61758. */
  61759. scene: Nullable<Scene>;
  61760. }
  61761. /**
  61762. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  61763. * To be as efficient as possible depending on your constraints nothing aside the first upload
  61764. * is automatically managed.
  61765. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  61766. * in your application.
  61767. *
  61768. * As the update is not automatic, you need to call them manually.
  61769. */
  61770. export class HtmlElementTexture extends BaseTexture {
  61771. /**
  61772. * The texture URL.
  61773. */
  61774. element: HTMLVideoElement | HTMLCanvasElement;
  61775. private static readonly DefaultOptions;
  61776. private _textureMatrix;
  61777. private _isVideo;
  61778. private _generateMipMaps;
  61779. private _samplingMode;
  61780. /**
  61781. * Instantiates a HtmlElementTexture from the following parameters.
  61782. *
  61783. * @param name Defines the name of the texture
  61784. * @param element Defines the video or canvas the texture is filled with
  61785. * @param options Defines the other none mandatory texture creation options
  61786. */
  61787. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  61788. private _createInternalTexture;
  61789. /**
  61790. * Returns the texture matrix used in most of the material.
  61791. */
  61792. getTextureMatrix(): Matrix;
  61793. /**
  61794. * Updates the content of the texture.
  61795. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  61796. */
  61797. update(invertY?: Nullable<boolean>): void;
  61798. }
  61799. }
  61800. declare module BABYLON {
  61801. /**
  61802. * Based on jsTGALoader - Javascript loader for TGA file
  61803. * By Vincent Thibault
  61804. * @see http://blog.robrowser.com/javascript-tga-loader.html
  61805. */
  61806. export class TGATools {
  61807. private static _TYPE_INDEXED;
  61808. private static _TYPE_RGB;
  61809. private static _TYPE_GREY;
  61810. private static _TYPE_RLE_INDEXED;
  61811. private static _TYPE_RLE_RGB;
  61812. private static _TYPE_RLE_GREY;
  61813. private static _ORIGIN_MASK;
  61814. private static _ORIGIN_SHIFT;
  61815. private static _ORIGIN_BL;
  61816. private static _ORIGIN_BR;
  61817. private static _ORIGIN_UL;
  61818. private static _ORIGIN_UR;
  61819. /**
  61820. * Gets the header of a TGA file
  61821. * @param data defines the TGA data
  61822. * @returns the header
  61823. */
  61824. static GetTGAHeader(data: Uint8Array): any;
  61825. /**
  61826. * Uploads TGA content to a Babylon Texture
  61827. * @hidden
  61828. */
  61829. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  61830. /** @hidden */
  61831. 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;
  61832. /** @hidden */
  61833. 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;
  61834. /** @hidden */
  61835. 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;
  61836. /** @hidden */
  61837. 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;
  61838. /** @hidden */
  61839. 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;
  61840. /** @hidden */
  61841. 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;
  61842. }
  61843. }
  61844. declare module BABYLON {
  61845. /**
  61846. * Implementation of the TGA Texture Loader.
  61847. * @hidden
  61848. */
  61849. export class _TGATextureLoader implements IInternalTextureLoader {
  61850. /**
  61851. * Defines wether the loader supports cascade loading the different faces.
  61852. */
  61853. readonly supportCascades: boolean;
  61854. /**
  61855. * This returns if the loader support the current file information.
  61856. * @param extension defines the file extension of the file being loaded
  61857. * @returns true if the loader can load the specified file
  61858. */
  61859. canLoad(extension: string): boolean;
  61860. /**
  61861. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61862. * @param data contains the texture data
  61863. * @param texture defines the BabylonJS internal texture
  61864. * @param createPolynomials will be true if polynomials have been requested
  61865. * @param onLoad defines the callback to trigger once the texture is ready
  61866. * @param onError defines the callback to trigger in case of error
  61867. */
  61868. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61869. /**
  61870. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61871. * @param data contains the texture data
  61872. * @param texture defines the BabylonJS internal texture
  61873. * @param callback defines the method to call once ready to upload
  61874. */
  61875. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61876. }
  61877. }
  61878. declare module BABYLON {
  61879. /**
  61880. * Info about the .basis files
  61881. */
  61882. class BasisFileInfo {
  61883. /**
  61884. * If the file has alpha
  61885. */
  61886. hasAlpha: boolean;
  61887. /**
  61888. * Info about each image of the basis file
  61889. */
  61890. images: Array<{
  61891. levels: Array<{
  61892. width: number;
  61893. height: number;
  61894. transcodedPixels: ArrayBufferView;
  61895. }>;
  61896. }>;
  61897. }
  61898. /**
  61899. * Result of transcoding a basis file
  61900. */
  61901. class TranscodeResult {
  61902. /**
  61903. * Info about the .basis file
  61904. */
  61905. fileInfo: BasisFileInfo;
  61906. /**
  61907. * Format to use when loading the file
  61908. */
  61909. format: number;
  61910. }
  61911. /**
  61912. * Configuration options for the Basis transcoder
  61913. */
  61914. export class BasisTranscodeConfiguration {
  61915. /**
  61916. * Supported compression formats used to determine the supported output format of the transcoder
  61917. */
  61918. supportedCompressionFormats?: {
  61919. /**
  61920. * etc1 compression format
  61921. */
  61922. etc1?: boolean;
  61923. /**
  61924. * s3tc compression format
  61925. */
  61926. s3tc?: boolean;
  61927. /**
  61928. * pvrtc compression format
  61929. */
  61930. pvrtc?: boolean;
  61931. /**
  61932. * etc2 compression format
  61933. */
  61934. etc2?: boolean;
  61935. };
  61936. /**
  61937. * If mipmap levels should be loaded for transcoded images (Default: true)
  61938. */
  61939. loadMipmapLevels?: boolean;
  61940. /**
  61941. * Index of a single image to load (Default: all images)
  61942. */
  61943. loadSingleImage?: number;
  61944. }
  61945. /**
  61946. * Used to load .Basis files
  61947. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  61948. */
  61949. export class BasisTools {
  61950. private static _IgnoreSupportedFormats;
  61951. /**
  61952. * URL to use when loading the basis transcoder
  61953. */
  61954. static JSModuleURL: string;
  61955. /**
  61956. * URL to use when loading the wasm module for the transcoder
  61957. */
  61958. static WasmModuleURL: string;
  61959. /**
  61960. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  61961. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  61962. * @returns internal format corresponding to the Basis format
  61963. */
  61964. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  61965. private static _WorkerPromise;
  61966. private static _Worker;
  61967. private static _actionId;
  61968. private static _CreateWorkerAsync;
  61969. /**
  61970. * Transcodes a loaded image file to compressed pixel data
  61971. * @param data image data to transcode
  61972. * @param config configuration options for the transcoding
  61973. * @returns a promise resulting in the transcoded image
  61974. */
  61975. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  61976. /**
  61977. * Loads a texture from the transcode result
  61978. * @param texture texture load to
  61979. * @param transcodeResult the result of transcoding the basis file to load from
  61980. */
  61981. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  61982. }
  61983. }
  61984. declare module BABYLON {
  61985. /**
  61986. * Loader for .basis file format
  61987. */
  61988. export class _BasisTextureLoader implements IInternalTextureLoader {
  61989. /**
  61990. * Defines whether the loader supports cascade loading the different faces.
  61991. */
  61992. readonly supportCascades: boolean;
  61993. /**
  61994. * This returns if the loader support the current file information.
  61995. * @param extension defines the file extension of the file being loaded
  61996. * @returns true if the loader can load the specified file
  61997. */
  61998. canLoad(extension: string): boolean;
  61999. /**
  62000. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62001. * @param data contains the texture data
  62002. * @param texture defines the BabylonJS internal texture
  62003. * @param createPolynomials will be true if polynomials have been requested
  62004. * @param onLoad defines the callback to trigger once the texture is ready
  62005. * @param onError defines the callback to trigger in case of error
  62006. */
  62007. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62008. /**
  62009. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62010. * @param data contains the texture data
  62011. * @param texture defines the BabylonJS internal texture
  62012. * @param callback defines the method to call once ready to upload
  62013. */
  62014. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62015. }
  62016. }
  62017. declare module BABYLON {
  62018. /**
  62019. * Defines the basic options interface of a TexturePacker Frame
  62020. */
  62021. export interface ITexturePackerFrame {
  62022. /**
  62023. * The frame ID
  62024. */
  62025. id: number;
  62026. /**
  62027. * The frames Scale
  62028. */
  62029. scale: Vector2;
  62030. /**
  62031. * The Frames offset
  62032. */
  62033. offset: Vector2;
  62034. }
  62035. /**
  62036. * This is a support class for frame Data on texture packer sets.
  62037. */
  62038. export class TexturePackerFrame implements ITexturePackerFrame {
  62039. /**
  62040. * The frame ID
  62041. */
  62042. id: number;
  62043. /**
  62044. * The frames Scale
  62045. */
  62046. scale: Vector2;
  62047. /**
  62048. * The Frames offset
  62049. */
  62050. offset: Vector2;
  62051. /**
  62052. * Initializes a texture package frame.
  62053. * @param id The numerical frame identifier
  62054. * @param scale Scalar Vector2 for UV frame
  62055. * @param offset Vector2 for the frame position in UV units.
  62056. * @returns TexturePackerFrame
  62057. */
  62058. constructor(id: number, scale: Vector2, offset: Vector2);
  62059. }
  62060. }
  62061. declare module BABYLON {
  62062. /**
  62063. * Defines the basic options interface of a TexturePacker
  62064. */
  62065. export interface ITexturePackerOptions {
  62066. /**
  62067. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  62068. */
  62069. map?: string[];
  62070. /**
  62071. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62072. */
  62073. uvsIn?: string;
  62074. /**
  62075. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62076. */
  62077. uvsOut?: string;
  62078. /**
  62079. * number representing the layout style. Defaults to LAYOUT_STRIP
  62080. */
  62081. layout?: number;
  62082. /**
  62083. * number of columns if using custom column count layout(2). This defaults to 4.
  62084. */
  62085. colnum?: number;
  62086. /**
  62087. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  62088. */
  62089. updateInputMeshes?: boolean;
  62090. /**
  62091. * boolean flag to dispose all the source textures. Defaults to true.
  62092. */
  62093. disposeSources?: boolean;
  62094. /**
  62095. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  62096. */
  62097. fillBlanks?: boolean;
  62098. /**
  62099. * string value representing the context fill style color. Defaults to 'black'.
  62100. */
  62101. customFillColor?: string;
  62102. /**
  62103. * Width and Height Value of each Frame in the TexturePacker Sets
  62104. */
  62105. frameSize?: number;
  62106. /**
  62107. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  62108. */
  62109. paddingRatio?: number;
  62110. /**
  62111. * Number that declares the fill method for the padding gutter.
  62112. */
  62113. paddingMode?: number;
  62114. /**
  62115. * If in SUBUV_COLOR padding mode what color to use.
  62116. */
  62117. paddingColor?: Color3 | Color4;
  62118. }
  62119. /**
  62120. * Defines the basic interface of a TexturePacker JSON File
  62121. */
  62122. export interface ITexturePackerJSON {
  62123. /**
  62124. * The frame ID
  62125. */
  62126. name: string;
  62127. /**
  62128. * The base64 channel data
  62129. */
  62130. sets: any;
  62131. /**
  62132. * The options of the Packer
  62133. */
  62134. options: ITexturePackerOptions;
  62135. /**
  62136. * The frame data of the Packer
  62137. */
  62138. frames: Array<number>;
  62139. }
  62140. /**
  62141. * This is a support class that generates a series of packed texture sets.
  62142. * @see https://doc.babylonjs.com/babylon101/materials
  62143. */
  62144. export class TexturePacker {
  62145. /** Packer Layout Constant 0 */
  62146. static readonly LAYOUT_STRIP: number;
  62147. /** Packer Layout Constant 1 */
  62148. static readonly LAYOUT_POWER2: number;
  62149. /** Packer Layout Constant 2 */
  62150. static readonly LAYOUT_COLNUM: number;
  62151. /** Packer Layout Constant 0 */
  62152. static readonly SUBUV_WRAP: number;
  62153. /** Packer Layout Constant 1 */
  62154. static readonly SUBUV_EXTEND: number;
  62155. /** Packer Layout Constant 2 */
  62156. static readonly SUBUV_COLOR: number;
  62157. /** The Name of the Texture Package */
  62158. name: string;
  62159. /** The scene scope of the TexturePacker */
  62160. scene: Scene;
  62161. /** The Meshes to target */
  62162. meshes: AbstractMesh[];
  62163. /** Arguments passed with the Constructor */
  62164. options: ITexturePackerOptions;
  62165. /** The promise that is started upon initialization */
  62166. promise: Nullable<Promise<TexturePacker | string>>;
  62167. /** The Container object for the channel sets that are generated */
  62168. sets: object;
  62169. /** The Container array for the frames that are generated */
  62170. frames: TexturePackerFrame[];
  62171. /** The expected number of textures the system is parsing. */
  62172. private _expecting;
  62173. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  62174. private _paddingValue;
  62175. /**
  62176. * Initializes a texture package series from an array of meshes or a single mesh.
  62177. * @param name The name of the package
  62178. * @param meshes The target meshes to compose the package from
  62179. * @param options The arguments that texture packer should follow while building.
  62180. * @param scene The scene which the textures are scoped to.
  62181. * @returns TexturePacker
  62182. */
  62183. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  62184. /**
  62185. * Starts the package process
  62186. * @param resolve The promises resolution function
  62187. * @returns TexturePacker
  62188. */
  62189. private _createFrames;
  62190. /**
  62191. * Calculates the Size of the Channel Sets
  62192. * @returns Vector2
  62193. */
  62194. private _calculateSize;
  62195. /**
  62196. * Calculates the UV data for the frames.
  62197. * @param baseSize the base frameSize
  62198. * @param padding the base frame padding
  62199. * @param dtSize size of the Dynamic Texture for that channel
  62200. * @param dtUnits is 1/dtSize
  62201. * @param update flag to update the input meshes
  62202. */
  62203. private _calculateMeshUVFrames;
  62204. /**
  62205. * Calculates the frames Offset.
  62206. * @param index of the frame
  62207. * @returns Vector2
  62208. */
  62209. private _getFrameOffset;
  62210. /**
  62211. * Updates a Mesh to the frame data
  62212. * @param mesh that is the target
  62213. * @param frameID or the frame index
  62214. */
  62215. private _updateMeshUV;
  62216. /**
  62217. * Updates a Meshes materials to use the texture packer channels
  62218. * @param m is the mesh to target
  62219. * @param force all channels on the packer to be set.
  62220. */
  62221. private _updateTextureReferences;
  62222. /**
  62223. * Public method to set a Mesh to a frame
  62224. * @param m that is the target
  62225. * @param frameID or the frame index
  62226. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  62227. */
  62228. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  62229. /**
  62230. * Starts the async promise to compile the texture packer.
  62231. * @returns Promise<void>
  62232. */
  62233. processAsync(): Promise<void>;
  62234. /**
  62235. * Disposes all textures associated with this packer
  62236. */
  62237. dispose(): void;
  62238. /**
  62239. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  62240. * @param imageType is the image type to use.
  62241. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  62242. */
  62243. download(imageType?: string, quality?: number): void;
  62244. /**
  62245. * Public method to load a texturePacker JSON file.
  62246. * @param data of the JSON file in string format.
  62247. */
  62248. updateFromJSON(data: string): void;
  62249. }
  62250. }
  62251. declare module BABYLON {
  62252. /**
  62253. * 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.
  62254. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62255. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62256. */
  62257. export class CustomProceduralTexture extends ProceduralTexture {
  62258. private _animate;
  62259. private _time;
  62260. private _config;
  62261. private _texturePath;
  62262. /**
  62263. * Instantiates a new Custom Procedural Texture.
  62264. * 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.
  62265. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62266. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62267. * @param name Define the name of the texture
  62268. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  62269. * @param size Define the size of the texture to create
  62270. * @param scene Define the scene the texture belongs to
  62271. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  62272. * @param generateMipMaps Define if the texture should creates mip maps or not
  62273. */
  62274. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62275. private _loadJson;
  62276. /**
  62277. * Is the texture ready to be used ? (rendered at least once)
  62278. * @returns true if ready, otherwise, false.
  62279. */
  62280. isReady(): boolean;
  62281. /**
  62282. * Render the texture to its associated render target.
  62283. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  62284. */
  62285. render(useCameraPostProcess?: boolean): void;
  62286. /**
  62287. * Update the list of dependant textures samplers in the shader.
  62288. */
  62289. updateTextures(): void;
  62290. /**
  62291. * Update the uniform values of the procedural texture in the shader.
  62292. */
  62293. updateShaderUniforms(): void;
  62294. /**
  62295. * Define if the texture animates or not.
  62296. */
  62297. get animate(): boolean;
  62298. set animate(value: boolean);
  62299. }
  62300. }
  62301. declare module BABYLON {
  62302. /** @hidden */
  62303. export var noisePixelShader: {
  62304. name: string;
  62305. shader: string;
  62306. };
  62307. }
  62308. declare module BABYLON {
  62309. /**
  62310. * Class used to generate noise procedural textures
  62311. */
  62312. export class NoiseProceduralTexture extends ProceduralTexture {
  62313. /** Gets or sets the start time (default is 0) */
  62314. time: number;
  62315. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  62316. brightness: number;
  62317. /** Defines the number of octaves to process */
  62318. octaves: number;
  62319. /** Defines the level of persistence (0.8 by default) */
  62320. persistence: number;
  62321. /** Gets or sets animation speed factor (default is 1) */
  62322. animationSpeedFactor: number;
  62323. /**
  62324. * Creates a new NoiseProceduralTexture
  62325. * @param name defines the name fo the texture
  62326. * @param size defines the size of the texture (default is 256)
  62327. * @param scene defines the hosting scene
  62328. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  62329. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  62330. */
  62331. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62332. private _updateShaderUniforms;
  62333. protected _getDefines(): string;
  62334. /** Generate the current state of the procedural texture */
  62335. render(useCameraPostProcess?: boolean): void;
  62336. /**
  62337. * Serializes this noise procedural texture
  62338. * @returns a serialized noise procedural texture object
  62339. */
  62340. serialize(): any;
  62341. /**
  62342. * Clone the texture.
  62343. * @returns the cloned texture
  62344. */
  62345. clone(): NoiseProceduralTexture;
  62346. /**
  62347. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  62348. * @param parsedTexture defines parsed texture data
  62349. * @param scene defines the current scene
  62350. * @param rootUrl defines the root URL containing noise procedural texture information
  62351. * @returns a parsed NoiseProceduralTexture
  62352. */
  62353. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  62354. }
  62355. }
  62356. declare module BABYLON {
  62357. /**
  62358. * Raw cube texture where the raw buffers are passed in
  62359. */
  62360. export class RawCubeTexture extends CubeTexture {
  62361. /**
  62362. * Creates a cube texture where the raw buffers are passed in.
  62363. * @param scene defines the scene the texture is attached to
  62364. * @param data defines the array of data to use to create each face
  62365. * @param size defines the size of the textures
  62366. * @param format defines the format of the data
  62367. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  62368. * @param generateMipMaps defines if the engine should generate the mip levels
  62369. * @param invertY defines if data must be stored with Y axis inverted
  62370. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  62371. * @param compression defines the compression used (null by default)
  62372. */
  62373. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  62374. /**
  62375. * Updates the raw cube texture.
  62376. * @param data defines the data to store
  62377. * @param format defines the data format
  62378. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62379. * @param invertY defines if data must be stored with Y axis inverted
  62380. * @param compression defines the compression used (null by default)
  62381. * @param level defines which level of the texture to update
  62382. */
  62383. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  62384. /**
  62385. * Updates a raw cube texture with RGBD encoded data.
  62386. * @param data defines the array of data [mipmap][face] to use to create each face
  62387. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  62388. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  62389. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  62390. * @returns a promsie that resolves when the operation is complete
  62391. */
  62392. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  62393. /**
  62394. * Clones the raw cube texture.
  62395. * @return a new cube texture
  62396. */
  62397. clone(): CubeTexture;
  62398. /** @hidden */
  62399. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  62400. }
  62401. }
  62402. declare module BABYLON {
  62403. /**
  62404. * Class used to store 2D array textures containing user data
  62405. */
  62406. export class RawTexture2DArray extends Texture {
  62407. /** Gets or sets the texture format to use */
  62408. format: number;
  62409. /**
  62410. * Create a new RawTexture2DArray
  62411. * @param data defines the data of the texture
  62412. * @param width defines the width of the texture
  62413. * @param height defines the height of the texture
  62414. * @param depth defines the number of layers of the texture
  62415. * @param format defines the texture format to use
  62416. * @param scene defines the hosting scene
  62417. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62418. * @param invertY defines if texture must be stored with Y axis inverted
  62419. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62420. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62421. */
  62422. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62423. /** Gets or sets the texture format to use */
  62424. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62425. /**
  62426. * Update the texture with new data
  62427. * @param data defines the data to store in the texture
  62428. */
  62429. update(data: ArrayBufferView): void;
  62430. }
  62431. }
  62432. declare module BABYLON {
  62433. /**
  62434. * Class used to store 3D textures containing user data
  62435. */
  62436. export class RawTexture3D extends Texture {
  62437. /** Gets or sets the texture format to use */
  62438. format: number;
  62439. /**
  62440. * Create a new RawTexture3D
  62441. * @param data defines the data of the texture
  62442. * @param width defines the width of the texture
  62443. * @param height defines the height of the texture
  62444. * @param depth defines the depth of the texture
  62445. * @param format defines the texture format to use
  62446. * @param scene defines the hosting scene
  62447. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62448. * @param invertY defines if texture must be stored with Y axis inverted
  62449. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62450. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62451. */
  62452. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62453. /** Gets or sets the texture format to use */
  62454. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62455. /**
  62456. * Update the texture with new data
  62457. * @param data defines the data to store in the texture
  62458. */
  62459. update(data: ArrayBufferView): void;
  62460. }
  62461. }
  62462. declare module BABYLON {
  62463. /**
  62464. * Creates a refraction texture used by refraction channel of the standard material.
  62465. * It is like a mirror but to see through a material.
  62466. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62467. */
  62468. export class RefractionTexture extends RenderTargetTexture {
  62469. /**
  62470. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  62471. * 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.
  62472. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62473. */
  62474. refractionPlane: Plane;
  62475. /**
  62476. * Define how deep under the surface we should see.
  62477. */
  62478. depth: number;
  62479. /**
  62480. * Creates a refraction texture used by refraction channel of the standard material.
  62481. * It is like a mirror but to see through a material.
  62482. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62483. * @param name Define the texture name
  62484. * @param size Define the size of the underlying texture
  62485. * @param scene Define the scene the refraction belongs to
  62486. * @param generateMipMaps Define if we need to generate mips level for the refraction
  62487. */
  62488. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  62489. /**
  62490. * Clone the refraction texture.
  62491. * @returns the cloned texture
  62492. */
  62493. clone(): RefractionTexture;
  62494. /**
  62495. * Serialize the texture to a JSON representation you could use in Parse later on
  62496. * @returns the serialized JSON representation
  62497. */
  62498. serialize(): any;
  62499. }
  62500. }
  62501. declare module BABYLON {
  62502. /**
  62503. * Block used to add support for vertex skinning (bones)
  62504. */
  62505. export class BonesBlock extends NodeMaterialBlock {
  62506. /**
  62507. * Creates a new BonesBlock
  62508. * @param name defines the block name
  62509. */
  62510. constructor(name: string);
  62511. /**
  62512. * Initialize the block and prepare the context for build
  62513. * @param state defines the state that will be used for the build
  62514. */
  62515. initialize(state: NodeMaterialBuildState): void;
  62516. /**
  62517. * Gets the current class name
  62518. * @returns the class name
  62519. */
  62520. getClassName(): string;
  62521. /**
  62522. * Gets the matrix indices input component
  62523. */
  62524. get matricesIndices(): NodeMaterialConnectionPoint;
  62525. /**
  62526. * Gets the matrix weights input component
  62527. */
  62528. get matricesWeights(): NodeMaterialConnectionPoint;
  62529. /**
  62530. * Gets the extra matrix indices input component
  62531. */
  62532. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  62533. /**
  62534. * Gets the extra matrix weights input component
  62535. */
  62536. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  62537. /**
  62538. * Gets the world input component
  62539. */
  62540. get world(): NodeMaterialConnectionPoint;
  62541. /**
  62542. * Gets the output component
  62543. */
  62544. get output(): NodeMaterialConnectionPoint;
  62545. autoConfigure(material: NodeMaterial): void;
  62546. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  62547. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62548. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62549. protected _buildBlock(state: NodeMaterialBuildState): this;
  62550. }
  62551. }
  62552. declare module BABYLON {
  62553. /**
  62554. * Block used to add support for instances
  62555. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  62556. */
  62557. export class InstancesBlock extends NodeMaterialBlock {
  62558. /**
  62559. * Creates a new InstancesBlock
  62560. * @param name defines the block name
  62561. */
  62562. constructor(name: string);
  62563. /**
  62564. * Gets the current class name
  62565. * @returns the class name
  62566. */
  62567. getClassName(): string;
  62568. /**
  62569. * Gets the first world row input component
  62570. */
  62571. get world0(): NodeMaterialConnectionPoint;
  62572. /**
  62573. * Gets the second world row input component
  62574. */
  62575. get world1(): NodeMaterialConnectionPoint;
  62576. /**
  62577. * Gets the third world row input component
  62578. */
  62579. get world2(): NodeMaterialConnectionPoint;
  62580. /**
  62581. * Gets the forth world row input component
  62582. */
  62583. get world3(): NodeMaterialConnectionPoint;
  62584. /**
  62585. * Gets the world input component
  62586. */
  62587. get world(): NodeMaterialConnectionPoint;
  62588. /**
  62589. * Gets the output component
  62590. */
  62591. get output(): NodeMaterialConnectionPoint;
  62592. /**
  62593. * Gets the isntanceID component
  62594. */
  62595. get instanceID(): NodeMaterialConnectionPoint;
  62596. autoConfigure(material: NodeMaterial): void;
  62597. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  62598. protected _buildBlock(state: NodeMaterialBuildState): this;
  62599. }
  62600. }
  62601. declare module BABYLON {
  62602. /**
  62603. * Block used to add morph targets support to vertex shader
  62604. */
  62605. export class MorphTargetsBlock extends NodeMaterialBlock {
  62606. private _repeatableContentAnchor;
  62607. /**
  62608. * Create a new MorphTargetsBlock
  62609. * @param name defines the block name
  62610. */
  62611. constructor(name: string);
  62612. /**
  62613. * Gets the current class name
  62614. * @returns the class name
  62615. */
  62616. getClassName(): string;
  62617. /**
  62618. * Gets the position input component
  62619. */
  62620. get position(): NodeMaterialConnectionPoint;
  62621. /**
  62622. * Gets the normal input component
  62623. */
  62624. get normal(): NodeMaterialConnectionPoint;
  62625. /**
  62626. * Gets the tangent input component
  62627. */
  62628. get tangent(): NodeMaterialConnectionPoint;
  62629. /**
  62630. * Gets the tangent input component
  62631. */
  62632. get uv(): NodeMaterialConnectionPoint;
  62633. /**
  62634. * Gets the position output component
  62635. */
  62636. get positionOutput(): NodeMaterialConnectionPoint;
  62637. /**
  62638. * Gets the normal output component
  62639. */
  62640. get normalOutput(): NodeMaterialConnectionPoint;
  62641. /**
  62642. * Gets the tangent output component
  62643. */
  62644. get tangentOutput(): NodeMaterialConnectionPoint;
  62645. /**
  62646. * Gets the tangent output component
  62647. */
  62648. get uvOutput(): NodeMaterialConnectionPoint;
  62649. initialize(state: NodeMaterialBuildState): void;
  62650. autoConfigure(material: NodeMaterial): void;
  62651. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62652. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62653. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  62654. protected _buildBlock(state: NodeMaterialBuildState): this;
  62655. }
  62656. }
  62657. declare module BABYLON {
  62658. /**
  62659. * Block used to get data information from a light
  62660. */
  62661. export class LightInformationBlock extends NodeMaterialBlock {
  62662. private _lightDataUniformName;
  62663. private _lightColorUniformName;
  62664. private _lightTypeDefineName;
  62665. /**
  62666. * Gets or sets the light associated with this block
  62667. */
  62668. light: Nullable<Light>;
  62669. /**
  62670. * Creates a new LightInformationBlock
  62671. * @param name defines the block name
  62672. */
  62673. constructor(name: string);
  62674. /**
  62675. * Gets the current class name
  62676. * @returns the class name
  62677. */
  62678. getClassName(): string;
  62679. /**
  62680. * Gets the world position input component
  62681. */
  62682. get worldPosition(): NodeMaterialConnectionPoint;
  62683. /**
  62684. * Gets the direction output component
  62685. */
  62686. get direction(): NodeMaterialConnectionPoint;
  62687. /**
  62688. * Gets the direction output component
  62689. */
  62690. get color(): NodeMaterialConnectionPoint;
  62691. /**
  62692. * Gets the direction output component
  62693. */
  62694. get intensity(): NodeMaterialConnectionPoint;
  62695. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62696. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62697. protected _buildBlock(state: NodeMaterialBuildState): this;
  62698. serialize(): any;
  62699. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62700. }
  62701. }
  62702. declare module BABYLON {
  62703. /**
  62704. * Block used to add image processing support to fragment shader
  62705. */
  62706. export class ImageProcessingBlock extends NodeMaterialBlock {
  62707. /**
  62708. * Create a new ImageProcessingBlock
  62709. * @param name defines the block name
  62710. */
  62711. constructor(name: string);
  62712. /**
  62713. * Gets the current class name
  62714. * @returns the class name
  62715. */
  62716. getClassName(): string;
  62717. /**
  62718. * Gets the color input component
  62719. */
  62720. get color(): NodeMaterialConnectionPoint;
  62721. /**
  62722. * Gets the output component
  62723. */
  62724. get output(): NodeMaterialConnectionPoint;
  62725. /**
  62726. * Initialize the block and prepare the context for build
  62727. * @param state defines the state that will be used for the build
  62728. */
  62729. initialize(state: NodeMaterialBuildState): void;
  62730. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62731. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62732. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62733. protected _buildBlock(state: NodeMaterialBuildState): this;
  62734. }
  62735. }
  62736. declare module BABYLON {
  62737. /**
  62738. * Block used to pertub normals based on a normal map
  62739. */
  62740. export class PerturbNormalBlock extends NodeMaterialBlock {
  62741. private _tangentSpaceParameterName;
  62742. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62743. invertX: boolean;
  62744. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62745. invertY: boolean;
  62746. /**
  62747. * Create a new PerturbNormalBlock
  62748. * @param name defines the block name
  62749. */
  62750. constructor(name: string);
  62751. /**
  62752. * Gets the current class name
  62753. * @returns the class name
  62754. */
  62755. getClassName(): string;
  62756. /**
  62757. * Gets the world position input component
  62758. */
  62759. get worldPosition(): NodeMaterialConnectionPoint;
  62760. /**
  62761. * Gets the world normal input component
  62762. */
  62763. get worldNormal(): NodeMaterialConnectionPoint;
  62764. /**
  62765. * Gets the world tangent input component
  62766. */
  62767. get worldTangent(): NodeMaterialConnectionPoint;
  62768. /**
  62769. * Gets the uv input component
  62770. */
  62771. get uv(): NodeMaterialConnectionPoint;
  62772. /**
  62773. * Gets the normal map color input component
  62774. */
  62775. get normalMapColor(): NodeMaterialConnectionPoint;
  62776. /**
  62777. * Gets the strength input component
  62778. */
  62779. get strength(): NodeMaterialConnectionPoint;
  62780. /**
  62781. * Gets the output component
  62782. */
  62783. get output(): NodeMaterialConnectionPoint;
  62784. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62785. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62786. autoConfigure(material: NodeMaterial): void;
  62787. protected _buildBlock(state: NodeMaterialBuildState): this;
  62788. protected _dumpPropertiesCode(): string;
  62789. serialize(): any;
  62790. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62791. }
  62792. }
  62793. declare module BABYLON {
  62794. /**
  62795. * Block used to discard a pixel if a value is smaller than a cutoff
  62796. */
  62797. export class DiscardBlock extends NodeMaterialBlock {
  62798. /**
  62799. * Create a new DiscardBlock
  62800. * @param name defines the block name
  62801. */
  62802. constructor(name: string);
  62803. /**
  62804. * Gets the current class name
  62805. * @returns the class name
  62806. */
  62807. getClassName(): string;
  62808. /**
  62809. * Gets the color input component
  62810. */
  62811. get value(): NodeMaterialConnectionPoint;
  62812. /**
  62813. * Gets the cutoff input component
  62814. */
  62815. get cutoff(): NodeMaterialConnectionPoint;
  62816. protected _buildBlock(state: NodeMaterialBuildState): this;
  62817. }
  62818. }
  62819. declare module BABYLON {
  62820. /**
  62821. * Block used to test if the fragment shader is front facing
  62822. */
  62823. export class FrontFacingBlock extends NodeMaterialBlock {
  62824. /**
  62825. * Creates a new FrontFacingBlock
  62826. * @param name defines the block name
  62827. */
  62828. constructor(name: string);
  62829. /**
  62830. * Gets the current class name
  62831. * @returns the class name
  62832. */
  62833. getClassName(): string;
  62834. /**
  62835. * Gets the output component
  62836. */
  62837. get output(): NodeMaterialConnectionPoint;
  62838. protected _buildBlock(state: NodeMaterialBuildState): this;
  62839. }
  62840. }
  62841. declare module BABYLON {
  62842. /**
  62843. * Block used to get the derivative value on x and y of a given input
  62844. */
  62845. export class DerivativeBlock extends NodeMaterialBlock {
  62846. /**
  62847. * Create a new DerivativeBlock
  62848. * @param name defines the block name
  62849. */
  62850. constructor(name: string);
  62851. /**
  62852. * Gets the current class name
  62853. * @returns the class name
  62854. */
  62855. getClassName(): string;
  62856. /**
  62857. * Gets the input component
  62858. */
  62859. get input(): NodeMaterialConnectionPoint;
  62860. /**
  62861. * Gets the derivative output on x
  62862. */
  62863. get dx(): NodeMaterialConnectionPoint;
  62864. /**
  62865. * Gets the derivative output on y
  62866. */
  62867. get dy(): NodeMaterialConnectionPoint;
  62868. protected _buildBlock(state: NodeMaterialBuildState): this;
  62869. }
  62870. }
  62871. declare module BABYLON {
  62872. /**
  62873. * Block used to make gl_FragCoord available
  62874. */
  62875. export class FragCoordBlock extends NodeMaterialBlock {
  62876. /**
  62877. * Creates a new FragCoordBlock
  62878. * @param name defines the block name
  62879. */
  62880. constructor(name: string);
  62881. /**
  62882. * Gets the current class name
  62883. * @returns the class name
  62884. */
  62885. getClassName(): string;
  62886. /**
  62887. * Gets the xy component
  62888. */
  62889. get xy(): NodeMaterialConnectionPoint;
  62890. /**
  62891. * Gets the xyz component
  62892. */
  62893. get xyz(): NodeMaterialConnectionPoint;
  62894. /**
  62895. * Gets the xyzw component
  62896. */
  62897. get xyzw(): NodeMaterialConnectionPoint;
  62898. /**
  62899. * Gets the x component
  62900. */
  62901. get x(): NodeMaterialConnectionPoint;
  62902. /**
  62903. * Gets the y component
  62904. */
  62905. get y(): NodeMaterialConnectionPoint;
  62906. /**
  62907. * Gets the z component
  62908. */
  62909. get z(): NodeMaterialConnectionPoint;
  62910. /**
  62911. * Gets the w component
  62912. */
  62913. get output(): NodeMaterialConnectionPoint;
  62914. protected writeOutputs(state: NodeMaterialBuildState): string;
  62915. protected _buildBlock(state: NodeMaterialBuildState): this;
  62916. }
  62917. }
  62918. declare module BABYLON {
  62919. /**
  62920. * Block used to get the screen sizes
  62921. */
  62922. export class ScreenSizeBlock extends NodeMaterialBlock {
  62923. private _varName;
  62924. private _scene;
  62925. /**
  62926. * Creates a new ScreenSizeBlock
  62927. * @param name defines the block name
  62928. */
  62929. constructor(name: string);
  62930. /**
  62931. * Gets the current class name
  62932. * @returns the class name
  62933. */
  62934. getClassName(): string;
  62935. /**
  62936. * Gets the xy component
  62937. */
  62938. get xy(): NodeMaterialConnectionPoint;
  62939. /**
  62940. * Gets the x component
  62941. */
  62942. get x(): NodeMaterialConnectionPoint;
  62943. /**
  62944. * Gets the y component
  62945. */
  62946. get y(): NodeMaterialConnectionPoint;
  62947. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62948. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  62949. protected _buildBlock(state: NodeMaterialBuildState): this;
  62950. }
  62951. }
  62952. declare module BABYLON {
  62953. /**
  62954. * Block used to add support for scene fog
  62955. */
  62956. export class FogBlock extends NodeMaterialBlock {
  62957. private _fogDistanceName;
  62958. private _fogParameters;
  62959. /**
  62960. * Create a new FogBlock
  62961. * @param name defines the block name
  62962. */
  62963. constructor(name: string);
  62964. /**
  62965. * Gets the current class name
  62966. * @returns the class name
  62967. */
  62968. getClassName(): string;
  62969. /**
  62970. * Gets the world position input component
  62971. */
  62972. get worldPosition(): NodeMaterialConnectionPoint;
  62973. /**
  62974. * Gets the view input component
  62975. */
  62976. get view(): NodeMaterialConnectionPoint;
  62977. /**
  62978. * Gets the color input component
  62979. */
  62980. get input(): NodeMaterialConnectionPoint;
  62981. /**
  62982. * Gets the fog color input component
  62983. */
  62984. get fogColor(): NodeMaterialConnectionPoint;
  62985. /**
  62986. * Gets the output component
  62987. */
  62988. get output(): NodeMaterialConnectionPoint;
  62989. autoConfigure(material: NodeMaterial): void;
  62990. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62991. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62992. protected _buildBlock(state: NodeMaterialBuildState): this;
  62993. }
  62994. }
  62995. declare module BABYLON {
  62996. /**
  62997. * Block used to add light in the fragment shader
  62998. */
  62999. export class LightBlock extends NodeMaterialBlock {
  63000. private _lightId;
  63001. /**
  63002. * Gets or sets the light associated with this block
  63003. */
  63004. light: Nullable<Light>;
  63005. /**
  63006. * Create a new LightBlock
  63007. * @param name defines the block name
  63008. */
  63009. constructor(name: string);
  63010. /**
  63011. * Gets the current class name
  63012. * @returns the class name
  63013. */
  63014. getClassName(): string;
  63015. /**
  63016. * Gets the world position input component
  63017. */
  63018. get worldPosition(): NodeMaterialConnectionPoint;
  63019. /**
  63020. * Gets the world normal input component
  63021. */
  63022. get worldNormal(): NodeMaterialConnectionPoint;
  63023. /**
  63024. * Gets the camera (or eye) position component
  63025. */
  63026. get cameraPosition(): NodeMaterialConnectionPoint;
  63027. /**
  63028. * Gets the glossiness component
  63029. */
  63030. get glossiness(): NodeMaterialConnectionPoint;
  63031. /**
  63032. * Gets the glossinness power component
  63033. */
  63034. get glossPower(): NodeMaterialConnectionPoint;
  63035. /**
  63036. * Gets the diffuse color component
  63037. */
  63038. get diffuseColor(): NodeMaterialConnectionPoint;
  63039. /**
  63040. * Gets the specular color component
  63041. */
  63042. get specularColor(): NodeMaterialConnectionPoint;
  63043. /**
  63044. * Gets the diffuse output component
  63045. */
  63046. get diffuseOutput(): NodeMaterialConnectionPoint;
  63047. /**
  63048. * Gets the specular output component
  63049. */
  63050. get specularOutput(): NodeMaterialConnectionPoint;
  63051. /**
  63052. * Gets the shadow output component
  63053. */
  63054. get shadow(): NodeMaterialConnectionPoint;
  63055. autoConfigure(material: NodeMaterial): void;
  63056. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63057. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63058. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63059. private _injectVertexCode;
  63060. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63061. serialize(): any;
  63062. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63063. }
  63064. }
  63065. declare module BABYLON {
  63066. /**
  63067. * Block used to read a reflection texture from a sampler
  63068. */
  63069. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  63070. /**
  63071. * Create a new ReflectionTextureBlock
  63072. * @param name defines the block name
  63073. */
  63074. constructor(name: string);
  63075. /**
  63076. * Gets the current class name
  63077. * @returns the class name
  63078. */
  63079. getClassName(): string;
  63080. /**
  63081. * Gets the world position input component
  63082. */
  63083. get position(): NodeMaterialConnectionPoint;
  63084. /**
  63085. * Gets the world position input component
  63086. */
  63087. get worldPosition(): NodeMaterialConnectionPoint;
  63088. /**
  63089. * Gets the world normal input component
  63090. */
  63091. get worldNormal(): NodeMaterialConnectionPoint;
  63092. /**
  63093. * Gets the world input component
  63094. */
  63095. get world(): NodeMaterialConnectionPoint;
  63096. /**
  63097. * Gets the camera (or eye) position component
  63098. */
  63099. get cameraPosition(): NodeMaterialConnectionPoint;
  63100. /**
  63101. * Gets the view input component
  63102. */
  63103. get view(): NodeMaterialConnectionPoint;
  63104. /**
  63105. * Gets the rgb output component
  63106. */
  63107. get rgb(): NodeMaterialConnectionPoint;
  63108. /**
  63109. * Gets the rgba output component
  63110. */
  63111. get rgba(): NodeMaterialConnectionPoint;
  63112. /**
  63113. * Gets the r output component
  63114. */
  63115. get r(): NodeMaterialConnectionPoint;
  63116. /**
  63117. * Gets the g output component
  63118. */
  63119. get g(): NodeMaterialConnectionPoint;
  63120. /**
  63121. * Gets the b output component
  63122. */
  63123. get b(): NodeMaterialConnectionPoint;
  63124. /**
  63125. * Gets the a output component
  63126. */
  63127. get a(): NodeMaterialConnectionPoint;
  63128. autoConfigure(material: NodeMaterial): void;
  63129. protected _buildBlock(state: NodeMaterialBuildState): this;
  63130. }
  63131. }
  63132. declare module BABYLON {
  63133. /**
  63134. * Block used to add 2 vectors
  63135. */
  63136. export class AddBlock extends NodeMaterialBlock {
  63137. /**
  63138. * Creates a new AddBlock
  63139. * @param name defines the block name
  63140. */
  63141. constructor(name: string);
  63142. /**
  63143. * Gets the current class name
  63144. * @returns the class name
  63145. */
  63146. getClassName(): string;
  63147. /**
  63148. * Gets the left operand input component
  63149. */
  63150. get left(): NodeMaterialConnectionPoint;
  63151. /**
  63152. * Gets the right operand input component
  63153. */
  63154. get right(): NodeMaterialConnectionPoint;
  63155. /**
  63156. * Gets the output component
  63157. */
  63158. get output(): NodeMaterialConnectionPoint;
  63159. protected _buildBlock(state: NodeMaterialBuildState): this;
  63160. }
  63161. }
  63162. declare module BABYLON {
  63163. /**
  63164. * Block used to scale a vector by a float
  63165. */
  63166. export class ScaleBlock extends NodeMaterialBlock {
  63167. /**
  63168. * Creates a new ScaleBlock
  63169. * @param name defines the block name
  63170. */
  63171. constructor(name: string);
  63172. /**
  63173. * Gets the current class name
  63174. * @returns the class name
  63175. */
  63176. getClassName(): string;
  63177. /**
  63178. * Gets the input component
  63179. */
  63180. get input(): NodeMaterialConnectionPoint;
  63181. /**
  63182. * Gets the factor input component
  63183. */
  63184. get factor(): NodeMaterialConnectionPoint;
  63185. /**
  63186. * Gets the output component
  63187. */
  63188. get output(): NodeMaterialConnectionPoint;
  63189. protected _buildBlock(state: NodeMaterialBuildState): this;
  63190. }
  63191. }
  63192. declare module BABYLON {
  63193. /**
  63194. * Block used to clamp a float
  63195. */
  63196. export class ClampBlock extends NodeMaterialBlock {
  63197. /** Gets or sets the minimum range */
  63198. minimum: number;
  63199. /** Gets or sets the maximum range */
  63200. maximum: number;
  63201. /**
  63202. * Creates a new ClampBlock
  63203. * @param name defines the block name
  63204. */
  63205. constructor(name: string);
  63206. /**
  63207. * Gets the current class name
  63208. * @returns the class name
  63209. */
  63210. getClassName(): string;
  63211. /**
  63212. * Gets the value input component
  63213. */
  63214. get value(): NodeMaterialConnectionPoint;
  63215. /**
  63216. * Gets the output component
  63217. */
  63218. get output(): NodeMaterialConnectionPoint;
  63219. protected _buildBlock(state: NodeMaterialBuildState): this;
  63220. protected _dumpPropertiesCode(): string;
  63221. serialize(): any;
  63222. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63223. }
  63224. }
  63225. declare module BABYLON {
  63226. /**
  63227. * Block used to apply a cross product between 2 vectors
  63228. */
  63229. export class CrossBlock extends NodeMaterialBlock {
  63230. /**
  63231. * Creates a new CrossBlock
  63232. * @param name defines the block name
  63233. */
  63234. constructor(name: string);
  63235. /**
  63236. * Gets the current class name
  63237. * @returns the class name
  63238. */
  63239. getClassName(): string;
  63240. /**
  63241. * Gets the left operand input component
  63242. */
  63243. get left(): NodeMaterialConnectionPoint;
  63244. /**
  63245. * Gets the right operand input component
  63246. */
  63247. get right(): NodeMaterialConnectionPoint;
  63248. /**
  63249. * Gets the output component
  63250. */
  63251. get output(): NodeMaterialConnectionPoint;
  63252. protected _buildBlock(state: NodeMaterialBuildState): this;
  63253. }
  63254. }
  63255. declare module BABYLON {
  63256. /**
  63257. * Block used to apply a dot product between 2 vectors
  63258. */
  63259. export class DotBlock extends NodeMaterialBlock {
  63260. /**
  63261. * Creates a new DotBlock
  63262. * @param name defines the block name
  63263. */
  63264. constructor(name: string);
  63265. /**
  63266. * Gets the current class name
  63267. * @returns the class name
  63268. */
  63269. getClassName(): string;
  63270. /**
  63271. * Gets the left operand input component
  63272. */
  63273. get left(): NodeMaterialConnectionPoint;
  63274. /**
  63275. * Gets the right operand input component
  63276. */
  63277. get right(): NodeMaterialConnectionPoint;
  63278. /**
  63279. * Gets the output component
  63280. */
  63281. get output(): NodeMaterialConnectionPoint;
  63282. protected _buildBlock(state: NodeMaterialBuildState): this;
  63283. }
  63284. }
  63285. declare module BABYLON {
  63286. /**
  63287. * Block used to normalize a vector
  63288. */
  63289. export class NormalizeBlock extends NodeMaterialBlock {
  63290. /**
  63291. * Creates a new NormalizeBlock
  63292. * @param name defines the block name
  63293. */
  63294. constructor(name: string);
  63295. /**
  63296. * Gets the current class name
  63297. * @returns the class name
  63298. */
  63299. getClassName(): string;
  63300. /**
  63301. * Gets the input component
  63302. */
  63303. get input(): NodeMaterialConnectionPoint;
  63304. /**
  63305. * Gets the output component
  63306. */
  63307. get output(): NodeMaterialConnectionPoint;
  63308. protected _buildBlock(state: NodeMaterialBuildState): this;
  63309. }
  63310. }
  63311. declare module BABYLON {
  63312. /**
  63313. * Block used to create a Color3/4 out of individual inputs (one for each component)
  63314. */
  63315. export class ColorMergerBlock extends NodeMaterialBlock {
  63316. /**
  63317. * Create a new ColorMergerBlock
  63318. * @param name defines the block name
  63319. */
  63320. constructor(name: string);
  63321. /**
  63322. * Gets the current class name
  63323. * @returns the class name
  63324. */
  63325. getClassName(): string;
  63326. /**
  63327. * Gets the rgb component (input)
  63328. */
  63329. get rgbIn(): NodeMaterialConnectionPoint;
  63330. /**
  63331. * Gets the r component (input)
  63332. */
  63333. get r(): NodeMaterialConnectionPoint;
  63334. /**
  63335. * Gets the g component (input)
  63336. */
  63337. get g(): NodeMaterialConnectionPoint;
  63338. /**
  63339. * Gets the b component (input)
  63340. */
  63341. get b(): NodeMaterialConnectionPoint;
  63342. /**
  63343. * Gets the a component (input)
  63344. */
  63345. get a(): NodeMaterialConnectionPoint;
  63346. /**
  63347. * Gets the rgba component (output)
  63348. */
  63349. get rgba(): NodeMaterialConnectionPoint;
  63350. /**
  63351. * Gets the rgb component (output)
  63352. */
  63353. get rgbOut(): NodeMaterialConnectionPoint;
  63354. /**
  63355. * Gets the rgb component (output)
  63356. * @deprecated Please use rgbOut instead.
  63357. */
  63358. get rgb(): NodeMaterialConnectionPoint;
  63359. protected _buildBlock(state: NodeMaterialBuildState): this;
  63360. }
  63361. }
  63362. declare module BABYLON {
  63363. /**
  63364. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63365. */
  63366. export class VectorSplitterBlock extends NodeMaterialBlock {
  63367. /**
  63368. * Create a new VectorSplitterBlock
  63369. * @param name defines the block name
  63370. */
  63371. constructor(name: string);
  63372. /**
  63373. * Gets the current class name
  63374. * @returns the class name
  63375. */
  63376. getClassName(): string;
  63377. /**
  63378. * Gets the xyzw component (input)
  63379. */
  63380. get xyzw(): NodeMaterialConnectionPoint;
  63381. /**
  63382. * Gets the xyz component (input)
  63383. */
  63384. get xyzIn(): NodeMaterialConnectionPoint;
  63385. /**
  63386. * Gets the xy component (input)
  63387. */
  63388. get xyIn(): NodeMaterialConnectionPoint;
  63389. /**
  63390. * Gets the xyz component (output)
  63391. */
  63392. get xyzOut(): NodeMaterialConnectionPoint;
  63393. /**
  63394. * Gets the xy component (output)
  63395. */
  63396. get xyOut(): NodeMaterialConnectionPoint;
  63397. /**
  63398. * Gets the x component (output)
  63399. */
  63400. get x(): NodeMaterialConnectionPoint;
  63401. /**
  63402. * Gets the y component (output)
  63403. */
  63404. get y(): NodeMaterialConnectionPoint;
  63405. /**
  63406. * Gets the z component (output)
  63407. */
  63408. get z(): NodeMaterialConnectionPoint;
  63409. /**
  63410. * Gets the w component (output)
  63411. */
  63412. get w(): NodeMaterialConnectionPoint;
  63413. protected _inputRename(name: string): string;
  63414. protected _outputRename(name: string): string;
  63415. protected _buildBlock(state: NodeMaterialBuildState): this;
  63416. }
  63417. }
  63418. declare module BABYLON {
  63419. /**
  63420. * Block used to lerp between 2 values
  63421. */
  63422. export class LerpBlock extends NodeMaterialBlock {
  63423. /**
  63424. * Creates a new LerpBlock
  63425. * @param name defines the block name
  63426. */
  63427. constructor(name: string);
  63428. /**
  63429. * Gets the current class name
  63430. * @returns the class name
  63431. */
  63432. getClassName(): string;
  63433. /**
  63434. * Gets the left operand input component
  63435. */
  63436. get left(): NodeMaterialConnectionPoint;
  63437. /**
  63438. * Gets the right operand input component
  63439. */
  63440. get right(): NodeMaterialConnectionPoint;
  63441. /**
  63442. * Gets the gradient operand input component
  63443. */
  63444. get gradient(): NodeMaterialConnectionPoint;
  63445. /**
  63446. * Gets the output component
  63447. */
  63448. get output(): NodeMaterialConnectionPoint;
  63449. protected _buildBlock(state: NodeMaterialBuildState): this;
  63450. }
  63451. }
  63452. declare module BABYLON {
  63453. /**
  63454. * Block used to divide 2 vectors
  63455. */
  63456. export class DivideBlock extends NodeMaterialBlock {
  63457. /**
  63458. * Creates a new DivideBlock
  63459. * @param name defines the block name
  63460. */
  63461. constructor(name: string);
  63462. /**
  63463. * Gets the current class name
  63464. * @returns the class name
  63465. */
  63466. getClassName(): string;
  63467. /**
  63468. * Gets the left operand input component
  63469. */
  63470. get left(): NodeMaterialConnectionPoint;
  63471. /**
  63472. * Gets the right operand input component
  63473. */
  63474. get right(): NodeMaterialConnectionPoint;
  63475. /**
  63476. * Gets the output component
  63477. */
  63478. get output(): NodeMaterialConnectionPoint;
  63479. protected _buildBlock(state: NodeMaterialBuildState): this;
  63480. }
  63481. }
  63482. declare module BABYLON {
  63483. /**
  63484. * Block used to subtract 2 vectors
  63485. */
  63486. export class SubtractBlock extends NodeMaterialBlock {
  63487. /**
  63488. * Creates a new SubtractBlock
  63489. * @param name defines the block name
  63490. */
  63491. constructor(name: string);
  63492. /**
  63493. * Gets the current class name
  63494. * @returns the class name
  63495. */
  63496. getClassName(): string;
  63497. /**
  63498. * Gets the left operand input component
  63499. */
  63500. get left(): NodeMaterialConnectionPoint;
  63501. /**
  63502. * Gets the right operand input component
  63503. */
  63504. get right(): NodeMaterialConnectionPoint;
  63505. /**
  63506. * Gets the output component
  63507. */
  63508. get output(): NodeMaterialConnectionPoint;
  63509. protected _buildBlock(state: NodeMaterialBuildState): this;
  63510. }
  63511. }
  63512. declare module BABYLON {
  63513. /**
  63514. * Block used to step a value
  63515. */
  63516. export class StepBlock extends NodeMaterialBlock {
  63517. /**
  63518. * Creates a new StepBlock
  63519. * @param name defines the block name
  63520. */
  63521. constructor(name: string);
  63522. /**
  63523. * Gets the current class name
  63524. * @returns the class name
  63525. */
  63526. getClassName(): string;
  63527. /**
  63528. * Gets the value operand input component
  63529. */
  63530. get value(): NodeMaterialConnectionPoint;
  63531. /**
  63532. * Gets the edge operand input component
  63533. */
  63534. get edge(): NodeMaterialConnectionPoint;
  63535. /**
  63536. * Gets the output component
  63537. */
  63538. get output(): NodeMaterialConnectionPoint;
  63539. protected _buildBlock(state: NodeMaterialBuildState): this;
  63540. }
  63541. }
  63542. declare module BABYLON {
  63543. /**
  63544. * Block used to get the opposite (1 - x) of a value
  63545. */
  63546. export class OneMinusBlock extends NodeMaterialBlock {
  63547. /**
  63548. * Creates a new OneMinusBlock
  63549. * @param name defines the block name
  63550. */
  63551. constructor(name: string);
  63552. /**
  63553. * Gets the current class name
  63554. * @returns the class name
  63555. */
  63556. getClassName(): string;
  63557. /**
  63558. * Gets the input component
  63559. */
  63560. get input(): NodeMaterialConnectionPoint;
  63561. /**
  63562. * Gets the output component
  63563. */
  63564. get output(): NodeMaterialConnectionPoint;
  63565. protected _buildBlock(state: NodeMaterialBuildState): this;
  63566. }
  63567. }
  63568. declare module BABYLON {
  63569. /**
  63570. * Block used to get the view direction
  63571. */
  63572. export class ViewDirectionBlock extends NodeMaterialBlock {
  63573. /**
  63574. * Creates a new ViewDirectionBlock
  63575. * @param name defines the block name
  63576. */
  63577. constructor(name: string);
  63578. /**
  63579. * Gets the current class name
  63580. * @returns the class name
  63581. */
  63582. getClassName(): string;
  63583. /**
  63584. * Gets the world position component
  63585. */
  63586. get worldPosition(): NodeMaterialConnectionPoint;
  63587. /**
  63588. * Gets the camera position component
  63589. */
  63590. get cameraPosition(): NodeMaterialConnectionPoint;
  63591. /**
  63592. * Gets the output component
  63593. */
  63594. get output(): NodeMaterialConnectionPoint;
  63595. autoConfigure(material: NodeMaterial): void;
  63596. protected _buildBlock(state: NodeMaterialBuildState): this;
  63597. }
  63598. }
  63599. declare module BABYLON {
  63600. /**
  63601. * Block used to compute fresnel value
  63602. */
  63603. export class FresnelBlock extends NodeMaterialBlock {
  63604. /**
  63605. * Create a new FresnelBlock
  63606. * @param name defines the block name
  63607. */
  63608. constructor(name: string);
  63609. /**
  63610. * Gets the current class name
  63611. * @returns the class name
  63612. */
  63613. getClassName(): string;
  63614. /**
  63615. * Gets the world normal input component
  63616. */
  63617. get worldNormal(): NodeMaterialConnectionPoint;
  63618. /**
  63619. * Gets the view direction input component
  63620. */
  63621. get viewDirection(): NodeMaterialConnectionPoint;
  63622. /**
  63623. * Gets the bias input component
  63624. */
  63625. get bias(): NodeMaterialConnectionPoint;
  63626. /**
  63627. * Gets the camera (or eye) position component
  63628. */
  63629. get power(): NodeMaterialConnectionPoint;
  63630. /**
  63631. * Gets the fresnel output component
  63632. */
  63633. get fresnel(): NodeMaterialConnectionPoint;
  63634. autoConfigure(material: NodeMaterial): void;
  63635. protected _buildBlock(state: NodeMaterialBuildState): this;
  63636. }
  63637. }
  63638. declare module BABYLON {
  63639. /**
  63640. * Block used to get the max of 2 values
  63641. */
  63642. export class MaxBlock extends NodeMaterialBlock {
  63643. /**
  63644. * Creates a new MaxBlock
  63645. * @param name defines the block name
  63646. */
  63647. constructor(name: string);
  63648. /**
  63649. * Gets the current class name
  63650. * @returns the class name
  63651. */
  63652. getClassName(): string;
  63653. /**
  63654. * Gets the left operand input component
  63655. */
  63656. get left(): NodeMaterialConnectionPoint;
  63657. /**
  63658. * Gets the right operand input component
  63659. */
  63660. get right(): NodeMaterialConnectionPoint;
  63661. /**
  63662. * Gets the output component
  63663. */
  63664. get output(): NodeMaterialConnectionPoint;
  63665. protected _buildBlock(state: NodeMaterialBuildState): this;
  63666. }
  63667. }
  63668. declare module BABYLON {
  63669. /**
  63670. * Block used to get the min of 2 values
  63671. */
  63672. export class MinBlock extends NodeMaterialBlock {
  63673. /**
  63674. * Creates a new MinBlock
  63675. * @param name defines the block name
  63676. */
  63677. constructor(name: string);
  63678. /**
  63679. * Gets the current class name
  63680. * @returns the class name
  63681. */
  63682. getClassName(): string;
  63683. /**
  63684. * Gets the left operand input component
  63685. */
  63686. get left(): NodeMaterialConnectionPoint;
  63687. /**
  63688. * Gets the right operand input component
  63689. */
  63690. get right(): NodeMaterialConnectionPoint;
  63691. /**
  63692. * Gets the output component
  63693. */
  63694. get output(): NodeMaterialConnectionPoint;
  63695. protected _buildBlock(state: NodeMaterialBuildState): this;
  63696. }
  63697. }
  63698. declare module BABYLON {
  63699. /**
  63700. * Block used to get the distance between 2 values
  63701. */
  63702. export class DistanceBlock extends NodeMaterialBlock {
  63703. /**
  63704. * Creates a new DistanceBlock
  63705. * @param name defines the block name
  63706. */
  63707. constructor(name: string);
  63708. /**
  63709. * Gets the current class name
  63710. * @returns the class name
  63711. */
  63712. getClassName(): string;
  63713. /**
  63714. * Gets the left operand input component
  63715. */
  63716. get left(): NodeMaterialConnectionPoint;
  63717. /**
  63718. * Gets the right operand input component
  63719. */
  63720. get right(): NodeMaterialConnectionPoint;
  63721. /**
  63722. * Gets the output component
  63723. */
  63724. get output(): NodeMaterialConnectionPoint;
  63725. protected _buildBlock(state: NodeMaterialBuildState): this;
  63726. }
  63727. }
  63728. declare module BABYLON {
  63729. /**
  63730. * Block used to get the length of a vector
  63731. */
  63732. export class LengthBlock extends NodeMaterialBlock {
  63733. /**
  63734. * Creates a new LengthBlock
  63735. * @param name defines the block name
  63736. */
  63737. constructor(name: string);
  63738. /**
  63739. * Gets the current class name
  63740. * @returns the class name
  63741. */
  63742. getClassName(): string;
  63743. /**
  63744. * Gets the value input component
  63745. */
  63746. get value(): NodeMaterialConnectionPoint;
  63747. /**
  63748. * Gets the output component
  63749. */
  63750. get output(): NodeMaterialConnectionPoint;
  63751. protected _buildBlock(state: NodeMaterialBuildState): this;
  63752. }
  63753. }
  63754. declare module BABYLON {
  63755. /**
  63756. * Block used to get negative version of a value (i.e. x * -1)
  63757. */
  63758. export class NegateBlock extends NodeMaterialBlock {
  63759. /**
  63760. * Creates a new NegateBlock
  63761. * @param name defines the block name
  63762. */
  63763. constructor(name: string);
  63764. /**
  63765. * Gets the current class name
  63766. * @returns the class name
  63767. */
  63768. getClassName(): string;
  63769. /**
  63770. * Gets the value input component
  63771. */
  63772. get value(): NodeMaterialConnectionPoint;
  63773. /**
  63774. * Gets the output component
  63775. */
  63776. get output(): NodeMaterialConnectionPoint;
  63777. protected _buildBlock(state: NodeMaterialBuildState): this;
  63778. }
  63779. }
  63780. declare module BABYLON {
  63781. /**
  63782. * Block used to get the value of the first parameter raised to the power of the second
  63783. */
  63784. export class PowBlock extends NodeMaterialBlock {
  63785. /**
  63786. * Creates a new PowBlock
  63787. * @param name defines the block name
  63788. */
  63789. constructor(name: string);
  63790. /**
  63791. * Gets the current class name
  63792. * @returns the class name
  63793. */
  63794. getClassName(): string;
  63795. /**
  63796. * Gets the value operand input component
  63797. */
  63798. get value(): NodeMaterialConnectionPoint;
  63799. /**
  63800. * Gets the power operand input component
  63801. */
  63802. get power(): NodeMaterialConnectionPoint;
  63803. /**
  63804. * Gets the output component
  63805. */
  63806. get output(): NodeMaterialConnectionPoint;
  63807. protected _buildBlock(state: NodeMaterialBuildState): this;
  63808. }
  63809. }
  63810. declare module BABYLON {
  63811. /**
  63812. * Block used to get a random number
  63813. */
  63814. export class RandomNumberBlock extends NodeMaterialBlock {
  63815. /**
  63816. * Creates a new RandomNumberBlock
  63817. * @param name defines the block name
  63818. */
  63819. constructor(name: string);
  63820. /**
  63821. * Gets the current class name
  63822. * @returns the class name
  63823. */
  63824. getClassName(): string;
  63825. /**
  63826. * Gets the seed input component
  63827. */
  63828. get seed(): NodeMaterialConnectionPoint;
  63829. /**
  63830. * Gets the output component
  63831. */
  63832. get output(): NodeMaterialConnectionPoint;
  63833. protected _buildBlock(state: NodeMaterialBuildState): this;
  63834. }
  63835. }
  63836. declare module BABYLON {
  63837. /**
  63838. * Block used to compute arc tangent of 2 values
  63839. */
  63840. export class ArcTan2Block extends NodeMaterialBlock {
  63841. /**
  63842. * Creates a new ArcTan2Block
  63843. * @param name defines the block name
  63844. */
  63845. constructor(name: string);
  63846. /**
  63847. * Gets the current class name
  63848. * @returns the class name
  63849. */
  63850. getClassName(): string;
  63851. /**
  63852. * Gets the x operand input component
  63853. */
  63854. get x(): NodeMaterialConnectionPoint;
  63855. /**
  63856. * Gets the y operand input component
  63857. */
  63858. get y(): NodeMaterialConnectionPoint;
  63859. /**
  63860. * Gets the output component
  63861. */
  63862. get output(): NodeMaterialConnectionPoint;
  63863. protected _buildBlock(state: NodeMaterialBuildState): this;
  63864. }
  63865. }
  63866. declare module BABYLON {
  63867. /**
  63868. * Block used to smooth step a value
  63869. */
  63870. export class SmoothStepBlock extends NodeMaterialBlock {
  63871. /**
  63872. * Creates a new SmoothStepBlock
  63873. * @param name defines the block name
  63874. */
  63875. constructor(name: string);
  63876. /**
  63877. * Gets the current class name
  63878. * @returns the class name
  63879. */
  63880. getClassName(): string;
  63881. /**
  63882. * Gets the value operand input component
  63883. */
  63884. get value(): NodeMaterialConnectionPoint;
  63885. /**
  63886. * Gets the first edge operand input component
  63887. */
  63888. get edge0(): NodeMaterialConnectionPoint;
  63889. /**
  63890. * Gets the second edge operand input component
  63891. */
  63892. get edge1(): NodeMaterialConnectionPoint;
  63893. /**
  63894. * Gets the output component
  63895. */
  63896. get output(): NodeMaterialConnectionPoint;
  63897. protected _buildBlock(state: NodeMaterialBuildState): this;
  63898. }
  63899. }
  63900. declare module BABYLON {
  63901. /**
  63902. * Block used to get the reciprocal (1 / x) of a value
  63903. */
  63904. export class ReciprocalBlock extends NodeMaterialBlock {
  63905. /**
  63906. * Creates a new ReciprocalBlock
  63907. * @param name defines the block name
  63908. */
  63909. constructor(name: string);
  63910. /**
  63911. * Gets the current class name
  63912. * @returns the class name
  63913. */
  63914. getClassName(): string;
  63915. /**
  63916. * Gets the input component
  63917. */
  63918. get input(): NodeMaterialConnectionPoint;
  63919. /**
  63920. * Gets the output component
  63921. */
  63922. get output(): NodeMaterialConnectionPoint;
  63923. protected _buildBlock(state: NodeMaterialBuildState): this;
  63924. }
  63925. }
  63926. declare module BABYLON {
  63927. /**
  63928. * Block used to replace a color by another one
  63929. */
  63930. export class ReplaceColorBlock extends NodeMaterialBlock {
  63931. /**
  63932. * Creates a new ReplaceColorBlock
  63933. * @param name defines the block name
  63934. */
  63935. constructor(name: string);
  63936. /**
  63937. * Gets the current class name
  63938. * @returns the class name
  63939. */
  63940. getClassName(): string;
  63941. /**
  63942. * Gets the value input component
  63943. */
  63944. get value(): NodeMaterialConnectionPoint;
  63945. /**
  63946. * Gets the reference input component
  63947. */
  63948. get reference(): NodeMaterialConnectionPoint;
  63949. /**
  63950. * Gets the distance input component
  63951. */
  63952. get distance(): NodeMaterialConnectionPoint;
  63953. /**
  63954. * Gets the replacement input component
  63955. */
  63956. get replacement(): NodeMaterialConnectionPoint;
  63957. /**
  63958. * Gets the output component
  63959. */
  63960. get output(): NodeMaterialConnectionPoint;
  63961. protected _buildBlock(state: NodeMaterialBuildState): this;
  63962. }
  63963. }
  63964. declare module BABYLON {
  63965. /**
  63966. * Block used to posterize a value
  63967. * @see https://en.wikipedia.org/wiki/Posterization
  63968. */
  63969. export class PosterizeBlock extends NodeMaterialBlock {
  63970. /**
  63971. * Creates a new PosterizeBlock
  63972. * @param name defines the block name
  63973. */
  63974. constructor(name: string);
  63975. /**
  63976. * Gets the current class name
  63977. * @returns the class name
  63978. */
  63979. getClassName(): string;
  63980. /**
  63981. * Gets the value input component
  63982. */
  63983. get value(): NodeMaterialConnectionPoint;
  63984. /**
  63985. * Gets the steps input component
  63986. */
  63987. get steps(): NodeMaterialConnectionPoint;
  63988. /**
  63989. * Gets the output component
  63990. */
  63991. get output(): NodeMaterialConnectionPoint;
  63992. protected _buildBlock(state: NodeMaterialBuildState): this;
  63993. }
  63994. }
  63995. declare module BABYLON {
  63996. /**
  63997. * Operations supported by the Wave block
  63998. */
  63999. export enum WaveBlockKind {
  64000. /** SawTooth */
  64001. SawTooth = 0,
  64002. /** Square */
  64003. Square = 1,
  64004. /** Triangle */
  64005. Triangle = 2
  64006. }
  64007. /**
  64008. * Block used to apply wave operation to floats
  64009. */
  64010. export class WaveBlock extends NodeMaterialBlock {
  64011. /**
  64012. * Gets or sets the kibnd of wave to be applied by the block
  64013. */
  64014. kind: WaveBlockKind;
  64015. /**
  64016. * Creates a new WaveBlock
  64017. * @param name defines the block name
  64018. */
  64019. constructor(name: string);
  64020. /**
  64021. * Gets the current class name
  64022. * @returns the class name
  64023. */
  64024. getClassName(): string;
  64025. /**
  64026. * Gets the input component
  64027. */
  64028. get input(): NodeMaterialConnectionPoint;
  64029. /**
  64030. * Gets the output component
  64031. */
  64032. get output(): NodeMaterialConnectionPoint;
  64033. protected _buildBlock(state: NodeMaterialBuildState): this;
  64034. serialize(): any;
  64035. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64036. }
  64037. }
  64038. declare module BABYLON {
  64039. /**
  64040. * Class used to store a color step for the GradientBlock
  64041. */
  64042. export class GradientBlockColorStep {
  64043. private _step;
  64044. /**
  64045. * Gets value indicating which step this color is associated with (between 0 and 1)
  64046. */
  64047. get step(): number;
  64048. /**
  64049. * Sets a value indicating which step this color is associated with (between 0 and 1)
  64050. */
  64051. set step(val: number);
  64052. private _color;
  64053. /**
  64054. * Gets the color associated with this step
  64055. */
  64056. get color(): Color3;
  64057. /**
  64058. * Sets the color associated with this step
  64059. */
  64060. set color(val: Color3);
  64061. /**
  64062. * Creates a new GradientBlockColorStep
  64063. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  64064. * @param color defines the color associated with this step
  64065. */
  64066. constructor(step: number, color: Color3);
  64067. }
  64068. /**
  64069. * Block used to return a color from a gradient based on an input value between 0 and 1
  64070. */
  64071. export class GradientBlock extends NodeMaterialBlock {
  64072. /**
  64073. * Gets or sets the list of color steps
  64074. */
  64075. colorSteps: GradientBlockColorStep[];
  64076. /** Gets an observable raised when the value is changed */
  64077. onValueChangedObservable: Observable<GradientBlock>;
  64078. /** calls observable when the value is changed*/
  64079. colorStepsUpdated(): void;
  64080. /**
  64081. * Creates a new GradientBlock
  64082. * @param name defines the block name
  64083. */
  64084. constructor(name: string);
  64085. /**
  64086. * Gets the current class name
  64087. * @returns the class name
  64088. */
  64089. getClassName(): string;
  64090. /**
  64091. * Gets the gradient input component
  64092. */
  64093. get gradient(): NodeMaterialConnectionPoint;
  64094. /**
  64095. * Gets the output component
  64096. */
  64097. get output(): NodeMaterialConnectionPoint;
  64098. private _writeColorConstant;
  64099. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64100. serialize(): any;
  64101. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64102. protected _dumpPropertiesCode(): string;
  64103. }
  64104. }
  64105. declare module BABYLON {
  64106. /**
  64107. * Block used to normalize lerp between 2 values
  64108. */
  64109. export class NLerpBlock extends NodeMaterialBlock {
  64110. /**
  64111. * Creates a new NLerpBlock
  64112. * @param name defines the block name
  64113. */
  64114. constructor(name: string);
  64115. /**
  64116. * Gets the current class name
  64117. * @returns the class name
  64118. */
  64119. getClassName(): string;
  64120. /**
  64121. * Gets the left operand input component
  64122. */
  64123. get left(): NodeMaterialConnectionPoint;
  64124. /**
  64125. * Gets the right operand input component
  64126. */
  64127. get right(): NodeMaterialConnectionPoint;
  64128. /**
  64129. * Gets the gradient operand input component
  64130. */
  64131. get gradient(): NodeMaterialConnectionPoint;
  64132. /**
  64133. * Gets the output component
  64134. */
  64135. get output(): NodeMaterialConnectionPoint;
  64136. protected _buildBlock(state: NodeMaterialBuildState): this;
  64137. }
  64138. }
  64139. declare module BABYLON {
  64140. /**
  64141. * block used to Generate a Worley Noise 3D Noise Pattern
  64142. */
  64143. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  64144. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64145. manhattanDistance: boolean;
  64146. /**
  64147. * Creates a new WorleyNoise3DBlock
  64148. * @param name defines the block name
  64149. */
  64150. constructor(name: string);
  64151. /**
  64152. * Gets the current class name
  64153. * @returns the class name
  64154. */
  64155. getClassName(): string;
  64156. /**
  64157. * Gets the seed input component
  64158. */
  64159. get seed(): NodeMaterialConnectionPoint;
  64160. /**
  64161. * Gets the jitter input component
  64162. */
  64163. get jitter(): NodeMaterialConnectionPoint;
  64164. /**
  64165. * Gets the output component
  64166. */
  64167. get output(): NodeMaterialConnectionPoint;
  64168. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64169. /**
  64170. * Exposes the properties to the UI?
  64171. */
  64172. protected _dumpPropertiesCode(): string;
  64173. /**
  64174. * Exposes the properties to the Seralize?
  64175. */
  64176. serialize(): any;
  64177. /**
  64178. * Exposes the properties to the deseralize?
  64179. */
  64180. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64181. }
  64182. }
  64183. declare module BABYLON {
  64184. /**
  64185. * block used to Generate a Simplex Perlin 3d Noise Pattern
  64186. */
  64187. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  64188. /**
  64189. * Creates a new SimplexPerlin3DBlock
  64190. * @param name defines the block name
  64191. */
  64192. constructor(name: string);
  64193. /**
  64194. * Gets the current class name
  64195. * @returns the class name
  64196. */
  64197. getClassName(): string;
  64198. /**
  64199. * Gets the seed operand input component
  64200. */
  64201. get seed(): NodeMaterialConnectionPoint;
  64202. /**
  64203. * Gets the output component
  64204. */
  64205. get output(): NodeMaterialConnectionPoint;
  64206. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64207. }
  64208. }
  64209. declare module BABYLON {
  64210. /**
  64211. * Block used to blend normals
  64212. */
  64213. export class NormalBlendBlock extends NodeMaterialBlock {
  64214. /**
  64215. * Creates a new NormalBlendBlock
  64216. * @param name defines the block name
  64217. */
  64218. constructor(name: string);
  64219. /**
  64220. * Gets the current class name
  64221. * @returns the class name
  64222. */
  64223. getClassName(): string;
  64224. /**
  64225. * Gets the first input component
  64226. */
  64227. get normalMap0(): NodeMaterialConnectionPoint;
  64228. /**
  64229. * Gets the second input component
  64230. */
  64231. get normalMap1(): NodeMaterialConnectionPoint;
  64232. /**
  64233. * Gets the output component
  64234. */
  64235. get output(): NodeMaterialConnectionPoint;
  64236. protected _buildBlock(state: NodeMaterialBuildState): this;
  64237. }
  64238. }
  64239. declare module BABYLON {
  64240. /**
  64241. * Block used to rotate a 2d vector by a given angle
  64242. */
  64243. export class Rotate2dBlock extends NodeMaterialBlock {
  64244. /**
  64245. * Creates a new Rotate2dBlock
  64246. * @param name defines the block name
  64247. */
  64248. constructor(name: string);
  64249. /**
  64250. * Gets the current class name
  64251. * @returns the class name
  64252. */
  64253. getClassName(): string;
  64254. /**
  64255. * Gets the input vector
  64256. */
  64257. get input(): NodeMaterialConnectionPoint;
  64258. /**
  64259. * Gets the input angle
  64260. */
  64261. get angle(): NodeMaterialConnectionPoint;
  64262. /**
  64263. * Gets the output component
  64264. */
  64265. get output(): NodeMaterialConnectionPoint;
  64266. autoConfigure(material: NodeMaterial): void;
  64267. protected _buildBlock(state: NodeMaterialBuildState): this;
  64268. }
  64269. }
  64270. declare module BABYLON {
  64271. /**
  64272. * Block used to get the reflected vector from a direction and a normal
  64273. */
  64274. export class ReflectBlock extends NodeMaterialBlock {
  64275. /**
  64276. * Creates a new ReflectBlock
  64277. * @param name defines the block name
  64278. */
  64279. constructor(name: string);
  64280. /**
  64281. * Gets the current class name
  64282. * @returns the class name
  64283. */
  64284. getClassName(): string;
  64285. /**
  64286. * Gets the incident component
  64287. */
  64288. get incident(): NodeMaterialConnectionPoint;
  64289. /**
  64290. * Gets the normal component
  64291. */
  64292. get normal(): NodeMaterialConnectionPoint;
  64293. /**
  64294. * Gets the output component
  64295. */
  64296. get output(): NodeMaterialConnectionPoint;
  64297. protected _buildBlock(state: NodeMaterialBuildState): this;
  64298. }
  64299. }
  64300. declare module BABYLON {
  64301. /**
  64302. * Block used to get the refracted vector from a direction and a normal
  64303. */
  64304. export class RefractBlock extends NodeMaterialBlock {
  64305. /**
  64306. * Creates a new RefractBlock
  64307. * @param name defines the block name
  64308. */
  64309. constructor(name: string);
  64310. /**
  64311. * Gets the current class name
  64312. * @returns the class name
  64313. */
  64314. getClassName(): string;
  64315. /**
  64316. * Gets the incident component
  64317. */
  64318. get incident(): NodeMaterialConnectionPoint;
  64319. /**
  64320. * Gets the normal component
  64321. */
  64322. get normal(): NodeMaterialConnectionPoint;
  64323. /**
  64324. * Gets the index of refraction component
  64325. */
  64326. get ior(): NodeMaterialConnectionPoint;
  64327. /**
  64328. * Gets the output component
  64329. */
  64330. get output(): NodeMaterialConnectionPoint;
  64331. protected _buildBlock(state: NodeMaterialBuildState): this;
  64332. }
  64333. }
  64334. declare module BABYLON {
  64335. /**
  64336. * Block used to desaturate a color
  64337. */
  64338. export class DesaturateBlock extends NodeMaterialBlock {
  64339. /**
  64340. * Creates a new DesaturateBlock
  64341. * @param name defines the block name
  64342. */
  64343. constructor(name: string);
  64344. /**
  64345. * Gets the current class name
  64346. * @returns the class name
  64347. */
  64348. getClassName(): string;
  64349. /**
  64350. * Gets the color operand input component
  64351. */
  64352. get color(): NodeMaterialConnectionPoint;
  64353. /**
  64354. * Gets the level operand input component
  64355. */
  64356. get level(): NodeMaterialConnectionPoint;
  64357. /**
  64358. * Gets the output component
  64359. */
  64360. get output(): NodeMaterialConnectionPoint;
  64361. protected _buildBlock(state: NodeMaterialBuildState): this;
  64362. }
  64363. }
  64364. declare module BABYLON {
  64365. /**
  64366. * Block used to implement the ambient occlusion module of the PBR material
  64367. */
  64368. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64369. /**
  64370. * Create a new AmbientOcclusionBlock
  64371. * @param name defines the block name
  64372. */
  64373. constructor(name: string);
  64374. /**
  64375. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64376. */
  64377. useAmbientInGrayScale: boolean;
  64378. /**
  64379. * Initialize the block and prepare the context for build
  64380. * @param state defines the state that will be used for the build
  64381. */
  64382. initialize(state: NodeMaterialBuildState): void;
  64383. /**
  64384. * Gets the current class name
  64385. * @returns the class name
  64386. */
  64387. getClassName(): string;
  64388. /**
  64389. * Gets the texture input component
  64390. */
  64391. get texture(): NodeMaterialConnectionPoint;
  64392. /**
  64393. * Gets the texture intensity component
  64394. */
  64395. get intensity(): NodeMaterialConnectionPoint;
  64396. /**
  64397. * Gets the direct light intensity input component
  64398. */
  64399. get directLightIntensity(): NodeMaterialConnectionPoint;
  64400. /**
  64401. * Gets the ambient occlusion object output component
  64402. */
  64403. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64404. /**
  64405. * Gets the main code of the block (fragment side)
  64406. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64407. * @returns the shader code
  64408. */
  64409. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64410. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64411. protected _buildBlock(state: NodeMaterialBuildState): this;
  64412. protected _dumpPropertiesCode(): string;
  64413. serialize(): any;
  64414. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64415. }
  64416. }
  64417. declare module BABYLON {
  64418. /**
  64419. * Block used to implement the reflection module of the PBR material
  64420. */
  64421. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64422. /** @hidden */
  64423. _defineLODReflectionAlpha: string;
  64424. /** @hidden */
  64425. _defineLinearSpecularReflection: string;
  64426. private _vEnvironmentIrradianceName;
  64427. /** @hidden */
  64428. _vReflectionMicrosurfaceInfosName: string;
  64429. /** @hidden */
  64430. _vReflectionInfosName: string;
  64431. /** @hidden */
  64432. _vReflectionFilteringInfoName: string;
  64433. private _scene;
  64434. /**
  64435. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64436. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64437. * It's less burden on the user side in the editor part.
  64438. */
  64439. /** @hidden */
  64440. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64441. /** @hidden */
  64442. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64443. /** @hidden */
  64444. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64445. /**
  64446. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64447. * diffuse part of the IBL.
  64448. */
  64449. useSphericalHarmonics: boolean;
  64450. /**
  64451. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64452. */
  64453. forceIrradianceInFragment: boolean;
  64454. /**
  64455. * Create a new ReflectionBlock
  64456. * @param name defines the block name
  64457. */
  64458. constructor(name: string);
  64459. /**
  64460. * Gets the current class name
  64461. * @returns the class name
  64462. */
  64463. getClassName(): string;
  64464. /**
  64465. * Gets the position input component
  64466. */
  64467. get position(): NodeMaterialConnectionPoint;
  64468. /**
  64469. * Gets the world position input component
  64470. */
  64471. get worldPosition(): NodeMaterialConnectionPoint;
  64472. /**
  64473. * Gets the world normal input component
  64474. */
  64475. get worldNormal(): NodeMaterialConnectionPoint;
  64476. /**
  64477. * Gets the world input component
  64478. */
  64479. get world(): NodeMaterialConnectionPoint;
  64480. /**
  64481. * Gets the camera (or eye) position component
  64482. */
  64483. get cameraPosition(): NodeMaterialConnectionPoint;
  64484. /**
  64485. * Gets the view input component
  64486. */
  64487. get view(): NodeMaterialConnectionPoint;
  64488. /**
  64489. * Gets the color input component
  64490. */
  64491. get color(): NodeMaterialConnectionPoint;
  64492. /**
  64493. * Gets the reflection object output component
  64494. */
  64495. get reflection(): NodeMaterialConnectionPoint;
  64496. /**
  64497. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  64498. */
  64499. get hasTexture(): boolean;
  64500. /**
  64501. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  64502. */
  64503. get reflectionColor(): string;
  64504. protected _getTexture(): Nullable<BaseTexture>;
  64505. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64506. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64507. /**
  64508. * Gets the code to inject in the vertex shader
  64509. * @param state current state of the node material building
  64510. * @returns the shader code
  64511. */
  64512. handleVertexSide(state: NodeMaterialBuildState): string;
  64513. /**
  64514. * Gets the main code of the block (fragment side)
  64515. * @param state current state of the node material building
  64516. * @param normalVarName name of the existing variable corresponding to the normal
  64517. * @returns the shader code
  64518. */
  64519. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64520. protected _buildBlock(state: NodeMaterialBuildState): this;
  64521. protected _dumpPropertiesCode(): string;
  64522. serialize(): any;
  64523. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64524. }
  64525. }
  64526. declare module BABYLON {
  64527. /**
  64528. * Block used to implement the sheen module of the PBR material
  64529. */
  64530. export class SheenBlock extends NodeMaterialBlock {
  64531. /**
  64532. * Create a new SheenBlock
  64533. * @param name defines the block name
  64534. */
  64535. constructor(name: string);
  64536. /**
  64537. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  64538. * It allows the strength of the sheen effect to not depend on the base color of the material,
  64539. * making it easier to setup and tweak the effect
  64540. */
  64541. albedoScaling: boolean;
  64542. /**
  64543. * Defines if the sheen is linked to the sheen color.
  64544. */
  64545. linkSheenWithAlbedo: boolean;
  64546. /**
  64547. * Initialize the block and prepare the context for build
  64548. * @param state defines the state that will be used for the build
  64549. */
  64550. initialize(state: NodeMaterialBuildState): void;
  64551. /**
  64552. * Gets the current class name
  64553. * @returns the class name
  64554. */
  64555. getClassName(): string;
  64556. /**
  64557. * Gets the intensity input component
  64558. */
  64559. get intensity(): NodeMaterialConnectionPoint;
  64560. /**
  64561. * Gets the color input component
  64562. */
  64563. get color(): NodeMaterialConnectionPoint;
  64564. /**
  64565. * Gets the roughness input component
  64566. */
  64567. get roughness(): NodeMaterialConnectionPoint;
  64568. /**
  64569. * Gets the sheen object output component
  64570. */
  64571. get sheen(): NodeMaterialConnectionPoint;
  64572. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64573. /**
  64574. * Gets the main code of the block (fragment side)
  64575. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64576. * @returns the shader code
  64577. */
  64578. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  64579. protected _buildBlock(state: NodeMaterialBuildState): this;
  64580. protected _dumpPropertiesCode(): string;
  64581. serialize(): any;
  64582. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64583. }
  64584. }
  64585. declare module BABYLON {
  64586. /**
  64587. * Block used to implement the reflectivity module of the PBR material
  64588. */
  64589. export class ReflectivityBlock extends NodeMaterialBlock {
  64590. private _metallicReflectanceColor;
  64591. private _metallicF0Factor;
  64592. /** @hidden */
  64593. _vMetallicReflectanceFactorsName: string;
  64594. /**
  64595. * The property below is set by the main PBR block prior to calling methods of this class.
  64596. */
  64597. /** @hidden */
  64598. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  64599. /**
  64600. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  64601. */
  64602. useAmbientOcclusionFromMetallicTextureRed: boolean;
  64603. /**
  64604. * Specifies if the metallic texture contains the metallness information in its blue channel.
  64605. */
  64606. useMetallnessFromMetallicTextureBlue: boolean;
  64607. /**
  64608. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  64609. */
  64610. useRoughnessFromMetallicTextureAlpha: boolean;
  64611. /**
  64612. * Specifies if the metallic texture contains the roughness information in its green channel.
  64613. */
  64614. useRoughnessFromMetallicTextureGreen: boolean;
  64615. /**
  64616. * Create a new ReflectivityBlock
  64617. * @param name defines the block name
  64618. */
  64619. constructor(name: string);
  64620. /**
  64621. * Initialize the block and prepare the context for build
  64622. * @param state defines the state that will be used for the build
  64623. */
  64624. initialize(state: NodeMaterialBuildState): void;
  64625. /**
  64626. * Gets the current class name
  64627. * @returns the class name
  64628. */
  64629. getClassName(): string;
  64630. /**
  64631. * Gets the metallic input component
  64632. */
  64633. get metallic(): NodeMaterialConnectionPoint;
  64634. /**
  64635. * Gets the roughness input component
  64636. */
  64637. get roughness(): NodeMaterialConnectionPoint;
  64638. /**
  64639. * Gets the texture input component
  64640. */
  64641. get texture(): NodeMaterialConnectionPoint;
  64642. /**
  64643. * Gets the reflectivity object output component
  64644. */
  64645. get reflectivity(): NodeMaterialConnectionPoint;
  64646. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64647. /**
  64648. * Gets the main code of the block (fragment side)
  64649. * @param state current state of the node material building
  64650. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64651. * @returns the shader code
  64652. */
  64653. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  64654. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64655. protected _buildBlock(state: NodeMaterialBuildState): this;
  64656. protected _dumpPropertiesCode(): string;
  64657. serialize(): any;
  64658. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64659. }
  64660. }
  64661. declare module BABYLON {
  64662. /**
  64663. * Block used to implement the anisotropy module of the PBR material
  64664. */
  64665. export class AnisotropyBlock extends NodeMaterialBlock {
  64666. /**
  64667. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64668. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64669. * It's less burden on the user side in the editor part.
  64670. */
  64671. /** @hidden */
  64672. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64673. /** @hidden */
  64674. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64675. /**
  64676. * Create a new AnisotropyBlock
  64677. * @param name defines the block name
  64678. */
  64679. constructor(name: string);
  64680. /**
  64681. * Initialize the block and prepare the context for build
  64682. * @param state defines the state that will be used for the build
  64683. */
  64684. initialize(state: NodeMaterialBuildState): void;
  64685. /**
  64686. * Gets the current class name
  64687. * @returns the class name
  64688. */
  64689. getClassName(): string;
  64690. /**
  64691. * Gets the intensity input component
  64692. */
  64693. get intensity(): NodeMaterialConnectionPoint;
  64694. /**
  64695. * Gets the direction input component
  64696. */
  64697. get direction(): NodeMaterialConnectionPoint;
  64698. /**
  64699. * Gets the texture input component
  64700. */
  64701. get texture(): NodeMaterialConnectionPoint;
  64702. /**
  64703. * Gets the uv input component
  64704. */
  64705. get uv(): NodeMaterialConnectionPoint;
  64706. /**
  64707. * Gets the worldTangent input component
  64708. */
  64709. get worldTangent(): NodeMaterialConnectionPoint;
  64710. /**
  64711. * Gets the anisotropy object output component
  64712. */
  64713. get anisotropy(): NodeMaterialConnectionPoint;
  64714. private _generateTBNSpace;
  64715. /**
  64716. * Gets the main code of the block (fragment side)
  64717. * @param state current state of the node material building
  64718. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64719. * @returns the shader code
  64720. */
  64721. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64722. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64723. protected _buildBlock(state: NodeMaterialBuildState): this;
  64724. }
  64725. }
  64726. declare module BABYLON {
  64727. /**
  64728. * Block used to implement the clear coat module of the PBR material
  64729. */
  64730. export class ClearCoatBlock extends NodeMaterialBlock {
  64731. private _scene;
  64732. /**
  64733. * Create a new ClearCoatBlock
  64734. * @param name defines the block name
  64735. */
  64736. constructor(name: string);
  64737. /**
  64738. * Initialize the block and prepare the context for build
  64739. * @param state defines the state that will be used for the build
  64740. */
  64741. initialize(state: NodeMaterialBuildState): void;
  64742. /**
  64743. * Gets the current class name
  64744. * @returns the class name
  64745. */
  64746. getClassName(): string;
  64747. /**
  64748. * Gets the intensity input component
  64749. */
  64750. get intensity(): NodeMaterialConnectionPoint;
  64751. /**
  64752. * Gets the roughness input component
  64753. */
  64754. get roughness(): NodeMaterialConnectionPoint;
  64755. /**
  64756. * Gets the ior input component
  64757. */
  64758. get ior(): NodeMaterialConnectionPoint;
  64759. /**
  64760. * Gets the texture input component
  64761. */
  64762. get texture(): NodeMaterialConnectionPoint;
  64763. /**
  64764. * Gets the bump texture input component
  64765. */
  64766. get bumpTexture(): NodeMaterialConnectionPoint;
  64767. /**
  64768. * Gets the uv input component
  64769. */
  64770. get uv(): NodeMaterialConnectionPoint;
  64771. /**
  64772. * Gets the tint color input component
  64773. */
  64774. get tintColor(): NodeMaterialConnectionPoint;
  64775. /**
  64776. * Gets the tint "at distance" input component
  64777. */
  64778. get tintAtDistance(): NodeMaterialConnectionPoint;
  64779. /**
  64780. * Gets the tint thickness input component
  64781. */
  64782. get tintThickness(): NodeMaterialConnectionPoint;
  64783. /**
  64784. * Gets the world tangent input component
  64785. */
  64786. get worldTangent(): NodeMaterialConnectionPoint;
  64787. /**
  64788. * Gets the clear coat object output component
  64789. */
  64790. get clearcoat(): NodeMaterialConnectionPoint;
  64791. autoConfigure(material: NodeMaterial): void;
  64792. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64793. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64794. private _generateTBNSpace;
  64795. /**
  64796. * Gets the main code of the block (fragment side)
  64797. * @param state current state of the node material building
  64798. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64799. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64800. * @param worldPosVarName name of the variable holding the world position
  64801. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64802. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64803. * @param worldNormalVarName name of the variable holding the world normal
  64804. * @returns the shader code
  64805. */
  64806. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64807. protected _buildBlock(state: NodeMaterialBuildState): this;
  64808. }
  64809. }
  64810. declare module BABYLON {
  64811. /**
  64812. * Block used to implement the sub surface module of the PBR material
  64813. */
  64814. export class SubSurfaceBlock extends NodeMaterialBlock {
  64815. /**
  64816. * Create a new SubSurfaceBlock
  64817. * @param name defines the block name
  64818. */
  64819. constructor(name: string);
  64820. /**
  64821. * Stores the intensity of the different subsurface effects in the thickness texture.
  64822. * * the green channel is the translucency intensity.
  64823. * * the blue channel is the scattering intensity.
  64824. * * the alpha channel is the refraction intensity.
  64825. */
  64826. useMaskFromThicknessTexture: boolean;
  64827. /**
  64828. * Initialize the block and prepare the context for build
  64829. * @param state defines the state that will be used for the build
  64830. */
  64831. initialize(state: NodeMaterialBuildState): void;
  64832. /**
  64833. * Gets the current class name
  64834. * @returns the class name
  64835. */
  64836. getClassName(): string;
  64837. /**
  64838. * Gets the min thickness input component
  64839. */
  64840. get minThickness(): NodeMaterialConnectionPoint;
  64841. /**
  64842. * Gets the max thickness input component
  64843. */
  64844. get maxThickness(): NodeMaterialConnectionPoint;
  64845. /**
  64846. * Gets the thickness texture component
  64847. */
  64848. get thicknessTexture(): NodeMaterialConnectionPoint;
  64849. /**
  64850. * Gets the tint color input component
  64851. */
  64852. get tintColor(): NodeMaterialConnectionPoint;
  64853. /**
  64854. * Gets the translucency intensity input component
  64855. */
  64856. get translucencyIntensity(): NodeMaterialConnectionPoint;
  64857. /**
  64858. * Gets the translucency diffusion distance input component
  64859. */
  64860. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  64861. /**
  64862. * Gets the refraction object parameters
  64863. */
  64864. get refraction(): NodeMaterialConnectionPoint;
  64865. /**
  64866. * Gets the sub surface object output component
  64867. */
  64868. get subsurface(): NodeMaterialConnectionPoint;
  64869. autoConfigure(material: NodeMaterial): void;
  64870. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64871. /**
  64872. * Gets the main code of the block (fragment side)
  64873. * @param state current state of the node material building
  64874. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  64875. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64876. * @param worldPosVarName name of the variable holding the world position
  64877. * @returns the shader code
  64878. */
  64879. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  64880. protected _buildBlock(state: NodeMaterialBuildState): this;
  64881. }
  64882. }
  64883. declare module BABYLON {
  64884. /**
  64885. * Block used to implement the PBR metallic/roughness model
  64886. */
  64887. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  64888. /**
  64889. * Gets or sets the light associated with this block
  64890. */
  64891. light: Nullable<Light>;
  64892. private _lightId;
  64893. private _scene;
  64894. private _environmentBRDFTexture;
  64895. private _environmentBrdfSamplerName;
  64896. private _vNormalWName;
  64897. private _invertNormalName;
  64898. /**
  64899. * Create a new ReflectionBlock
  64900. * @param name defines the block name
  64901. */
  64902. constructor(name: string);
  64903. /**
  64904. * Intensity of the direct lights e.g. the four lights available in your scene.
  64905. * This impacts both the direct diffuse and specular highlights.
  64906. */
  64907. directIntensity: number;
  64908. /**
  64909. * Intensity of the environment e.g. how much the environment will light the object
  64910. * either through harmonics for rough material or through the refelction for shiny ones.
  64911. */
  64912. environmentIntensity: number;
  64913. /**
  64914. * This is a special control allowing the reduction of the specular highlights coming from the
  64915. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  64916. */
  64917. specularIntensity: number;
  64918. /**
  64919. * Defines the falloff type used in this material.
  64920. * It by default is Physical.
  64921. */
  64922. lightFalloff: number;
  64923. /**
  64924. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  64925. */
  64926. useAlphaFromAlbedoTexture: boolean;
  64927. /**
  64928. * Specifies that alpha test should be used
  64929. */
  64930. useAlphaTest: boolean;
  64931. /**
  64932. * Defines the alpha limits in alpha test mode.
  64933. */
  64934. alphaTestCutoff: number;
  64935. /**
  64936. * Specifies that alpha blending should be used
  64937. */
  64938. useAlphaBlending: boolean;
  64939. /**
  64940. * Defines if the alpha value should be determined via the rgb values.
  64941. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  64942. */
  64943. opacityRGB: boolean;
  64944. /**
  64945. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  64946. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  64947. */
  64948. useRadianceOverAlpha: boolean;
  64949. /**
  64950. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  64951. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  64952. */
  64953. useSpecularOverAlpha: boolean;
  64954. /**
  64955. * Enables specular anti aliasing in the PBR shader.
  64956. * It will both interacts on the Geometry for analytical and IBL lighting.
  64957. * It also prefilter the roughness map based on the bump values.
  64958. */
  64959. enableSpecularAntiAliasing: boolean;
  64960. /**
  64961. * Enables realtime filtering on the texture.
  64962. */
  64963. realTimeFiltering: boolean;
  64964. /**
  64965. * Quality switch for realtime filtering
  64966. */
  64967. realTimeFilteringQuality: number;
  64968. /**
  64969. * Defines if the material uses energy conservation.
  64970. */
  64971. useEnergyConservation: boolean;
  64972. /**
  64973. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  64974. * too much the area relying on ambient texture to define their ambient occlusion.
  64975. */
  64976. useRadianceOcclusion: boolean;
  64977. /**
  64978. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  64979. * makes the reflect vector face the model (under horizon).
  64980. */
  64981. useHorizonOcclusion: boolean;
  64982. /**
  64983. * If set to true, no lighting calculations will be applied.
  64984. */
  64985. unlit: boolean;
  64986. /**
  64987. * Force normal to face away from face.
  64988. */
  64989. forceNormalForward: boolean;
  64990. /**
  64991. * Defines the material debug mode.
  64992. * It helps seeing only some components of the material while troubleshooting.
  64993. */
  64994. debugMode: number;
  64995. /**
  64996. * Specify from where on screen the debug mode should start.
  64997. * The value goes from -1 (full screen) to 1 (not visible)
  64998. * It helps with side by side comparison against the final render
  64999. * This defaults to 0
  65000. */
  65001. debugLimit: number;
  65002. /**
  65003. * As the default viewing range might not be enough (if the ambient is really small for instance)
  65004. * You can use the factor to better multiply the final value.
  65005. */
  65006. debugFactor: number;
  65007. /**
  65008. * Initialize the block and prepare the context for build
  65009. * @param state defines the state that will be used for the build
  65010. */
  65011. initialize(state: NodeMaterialBuildState): void;
  65012. /**
  65013. * Gets the current class name
  65014. * @returns the class name
  65015. */
  65016. getClassName(): string;
  65017. /**
  65018. * Gets the world position input component
  65019. */
  65020. get worldPosition(): NodeMaterialConnectionPoint;
  65021. /**
  65022. * Gets the world normal input component
  65023. */
  65024. get worldNormal(): NodeMaterialConnectionPoint;
  65025. /**
  65026. * Gets the perturbed normal input component
  65027. */
  65028. get perturbedNormal(): NodeMaterialConnectionPoint;
  65029. /**
  65030. * Gets the camera position input component
  65031. */
  65032. get cameraPosition(): NodeMaterialConnectionPoint;
  65033. /**
  65034. * Gets the base color input component
  65035. */
  65036. get baseColor(): NodeMaterialConnectionPoint;
  65037. /**
  65038. * Gets the opacity texture input component
  65039. */
  65040. get opacityTexture(): NodeMaterialConnectionPoint;
  65041. /**
  65042. * Gets the ambient color input component
  65043. */
  65044. get ambientColor(): NodeMaterialConnectionPoint;
  65045. /**
  65046. * Gets the reflectivity object parameters
  65047. */
  65048. get reflectivity(): NodeMaterialConnectionPoint;
  65049. /**
  65050. * Gets the ambient occlusion object parameters
  65051. */
  65052. get ambientOcclusion(): NodeMaterialConnectionPoint;
  65053. /**
  65054. * Gets the reflection object parameters
  65055. */
  65056. get reflection(): NodeMaterialConnectionPoint;
  65057. /**
  65058. * Gets the sheen object parameters
  65059. */
  65060. get sheen(): NodeMaterialConnectionPoint;
  65061. /**
  65062. * Gets the clear coat object parameters
  65063. */
  65064. get clearcoat(): NodeMaterialConnectionPoint;
  65065. /**
  65066. * Gets the sub surface object parameters
  65067. */
  65068. get subsurface(): NodeMaterialConnectionPoint;
  65069. /**
  65070. * Gets the anisotropy object parameters
  65071. */
  65072. get anisotropy(): NodeMaterialConnectionPoint;
  65073. /**
  65074. * Gets the ambient output component
  65075. */
  65076. get ambient(): NodeMaterialConnectionPoint;
  65077. /**
  65078. * Gets the diffuse output component
  65079. */
  65080. get diffuse(): NodeMaterialConnectionPoint;
  65081. /**
  65082. * Gets the specular output component
  65083. */
  65084. get specular(): NodeMaterialConnectionPoint;
  65085. /**
  65086. * Gets the sheen output component
  65087. */
  65088. get sheenDir(): NodeMaterialConnectionPoint;
  65089. /**
  65090. * Gets the clear coat output component
  65091. */
  65092. get clearcoatDir(): NodeMaterialConnectionPoint;
  65093. /**
  65094. * Gets the indirect diffuse output component
  65095. */
  65096. get diffuseIndirect(): NodeMaterialConnectionPoint;
  65097. /**
  65098. * Gets the indirect specular output component
  65099. */
  65100. get specularIndirect(): NodeMaterialConnectionPoint;
  65101. /**
  65102. * Gets the indirect sheen output component
  65103. */
  65104. get sheenIndirect(): NodeMaterialConnectionPoint;
  65105. /**
  65106. * Gets the indirect clear coat output component
  65107. */
  65108. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  65109. /**
  65110. * Gets the refraction output component
  65111. */
  65112. get refraction(): NodeMaterialConnectionPoint;
  65113. /**
  65114. * Gets the global lighting output component
  65115. */
  65116. get lighting(): NodeMaterialConnectionPoint;
  65117. /**
  65118. * Gets the shadow output component
  65119. */
  65120. get shadow(): NodeMaterialConnectionPoint;
  65121. /**
  65122. * Gets the alpha output component
  65123. */
  65124. get alpha(): NodeMaterialConnectionPoint;
  65125. autoConfigure(material: NodeMaterial): void;
  65126. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65127. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65128. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65129. private _injectVertexCode;
  65130. /**
  65131. * Gets the code corresponding to the albedo/opacity module
  65132. * @returns the shader code
  65133. */
  65134. getAlbedoOpacityCode(): string;
  65135. protected _buildBlock(state: NodeMaterialBuildState): this;
  65136. protected _dumpPropertiesCode(): string;
  65137. serialize(): any;
  65138. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65139. }
  65140. }
  65141. declare module BABYLON {
  65142. /**
  65143. * Block used to compute value of one parameter modulo another
  65144. */
  65145. export class ModBlock extends NodeMaterialBlock {
  65146. /**
  65147. * Creates a new ModBlock
  65148. * @param name defines the block name
  65149. */
  65150. constructor(name: string);
  65151. /**
  65152. * Gets the current class name
  65153. * @returns the class name
  65154. */
  65155. getClassName(): string;
  65156. /**
  65157. * Gets the left operand input component
  65158. */
  65159. get left(): NodeMaterialConnectionPoint;
  65160. /**
  65161. * Gets the right operand input component
  65162. */
  65163. get right(): NodeMaterialConnectionPoint;
  65164. /**
  65165. * Gets the output component
  65166. */
  65167. get output(): NodeMaterialConnectionPoint;
  65168. protected _buildBlock(state: NodeMaterialBuildState): this;
  65169. }
  65170. }
  65171. declare module BABYLON {
  65172. /**
  65173. * Configuration for Draco compression
  65174. */
  65175. export interface IDracoCompressionConfiguration {
  65176. /**
  65177. * Configuration for the decoder.
  65178. */
  65179. decoder: {
  65180. /**
  65181. * The url to the WebAssembly module.
  65182. */
  65183. wasmUrl?: string;
  65184. /**
  65185. * The url to the WebAssembly binary.
  65186. */
  65187. wasmBinaryUrl?: string;
  65188. /**
  65189. * The url to the fallback JavaScript module.
  65190. */
  65191. fallbackUrl?: string;
  65192. };
  65193. }
  65194. /**
  65195. * Draco compression (https://google.github.io/draco/)
  65196. *
  65197. * This class wraps the Draco module.
  65198. *
  65199. * **Encoder**
  65200. *
  65201. * The encoder is not currently implemented.
  65202. *
  65203. * **Decoder**
  65204. *
  65205. * 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.
  65206. *
  65207. * To update the configuration, use the following code:
  65208. * ```javascript
  65209. * DracoCompression.Configuration = {
  65210. * decoder: {
  65211. * wasmUrl: "<url to the WebAssembly library>",
  65212. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  65213. * fallbackUrl: "<url to the fallback JavaScript library>",
  65214. * }
  65215. * };
  65216. * ```
  65217. *
  65218. * 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.
  65219. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  65220. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  65221. *
  65222. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  65223. * ```javascript
  65224. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  65225. * ```
  65226. *
  65227. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  65228. */
  65229. export class DracoCompression implements IDisposable {
  65230. private _workerPoolPromise?;
  65231. private _decoderModulePromise?;
  65232. /**
  65233. * The configuration. Defaults to the following urls:
  65234. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  65235. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  65236. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  65237. */
  65238. static Configuration: IDracoCompressionConfiguration;
  65239. /**
  65240. * Returns true if the decoder configuration is available.
  65241. */
  65242. static get DecoderAvailable(): boolean;
  65243. /**
  65244. * Default number of workers to create when creating the draco compression object.
  65245. */
  65246. static DefaultNumWorkers: number;
  65247. private static GetDefaultNumWorkers;
  65248. private static _Default;
  65249. /**
  65250. * Default instance for the draco compression object.
  65251. */
  65252. static get Default(): DracoCompression;
  65253. /**
  65254. * Constructor
  65255. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65256. */
  65257. constructor(numWorkers?: number);
  65258. /**
  65259. * Stop all async operations and release resources.
  65260. */
  65261. dispose(): void;
  65262. /**
  65263. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65264. * @returns a promise that resolves when ready
  65265. */
  65266. whenReadyAsync(): Promise<void>;
  65267. /**
  65268. * Decode Draco compressed mesh data to vertex data.
  65269. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65270. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65271. * @returns A promise that resolves with the decoded vertex data
  65272. */
  65273. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65274. [kind: string]: number;
  65275. }): Promise<VertexData>;
  65276. }
  65277. }
  65278. declare module BABYLON {
  65279. /**
  65280. * Class for building Constructive Solid Geometry
  65281. */
  65282. export class CSG {
  65283. private polygons;
  65284. /**
  65285. * The world matrix
  65286. */
  65287. matrix: Matrix;
  65288. /**
  65289. * Stores the position
  65290. */
  65291. position: Vector3;
  65292. /**
  65293. * Stores the rotation
  65294. */
  65295. rotation: Vector3;
  65296. /**
  65297. * Stores the rotation quaternion
  65298. */
  65299. rotationQuaternion: Nullable<Quaternion>;
  65300. /**
  65301. * Stores the scaling vector
  65302. */
  65303. scaling: Vector3;
  65304. /**
  65305. * Convert the Mesh to CSG
  65306. * @param mesh The Mesh to convert to CSG
  65307. * @returns A new CSG from the Mesh
  65308. */
  65309. static FromMesh(mesh: Mesh): CSG;
  65310. /**
  65311. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65312. * @param polygons Polygons used to construct a CSG solid
  65313. */
  65314. private static FromPolygons;
  65315. /**
  65316. * Clones, or makes a deep copy, of the CSG
  65317. * @returns A new CSG
  65318. */
  65319. clone(): CSG;
  65320. /**
  65321. * Unions this CSG with another CSG
  65322. * @param csg The CSG to union against this CSG
  65323. * @returns The unioned CSG
  65324. */
  65325. union(csg: CSG): CSG;
  65326. /**
  65327. * Unions this CSG with another CSG in place
  65328. * @param csg The CSG to union against this CSG
  65329. */
  65330. unionInPlace(csg: CSG): void;
  65331. /**
  65332. * Subtracts this CSG with another CSG
  65333. * @param csg The CSG to subtract against this CSG
  65334. * @returns A new CSG
  65335. */
  65336. subtract(csg: CSG): CSG;
  65337. /**
  65338. * Subtracts this CSG with another CSG in place
  65339. * @param csg The CSG to subtact against this CSG
  65340. */
  65341. subtractInPlace(csg: CSG): void;
  65342. /**
  65343. * Intersect this CSG with another CSG
  65344. * @param csg The CSG to intersect against this CSG
  65345. * @returns A new CSG
  65346. */
  65347. intersect(csg: CSG): CSG;
  65348. /**
  65349. * Intersects this CSG with another CSG in place
  65350. * @param csg The CSG to intersect against this CSG
  65351. */
  65352. intersectInPlace(csg: CSG): void;
  65353. /**
  65354. * Return a new CSG solid with solid and empty space switched. This solid is
  65355. * not modified.
  65356. * @returns A new CSG solid with solid and empty space switched
  65357. */
  65358. inverse(): CSG;
  65359. /**
  65360. * Inverses the CSG in place
  65361. */
  65362. inverseInPlace(): void;
  65363. /**
  65364. * This is used to keep meshes transformations so they can be restored
  65365. * when we build back a Babylon Mesh
  65366. * NB : All CSG operations are performed in world coordinates
  65367. * @param csg The CSG to copy the transform attributes from
  65368. * @returns This CSG
  65369. */
  65370. copyTransformAttributes(csg: CSG): CSG;
  65371. /**
  65372. * Build Raw mesh from CSG
  65373. * Coordinates here are in world space
  65374. * @param name The name of the mesh geometry
  65375. * @param scene The Scene
  65376. * @param keepSubMeshes Specifies if the submeshes should be kept
  65377. * @returns A new Mesh
  65378. */
  65379. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65380. /**
  65381. * Build Mesh from CSG taking material and transforms into account
  65382. * @param name The name of the Mesh
  65383. * @param material The material of the Mesh
  65384. * @param scene The Scene
  65385. * @param keepSubMeshes Specifies if submeshes should be kept
  65386. * @returns The new Mesh
  65387. */
  65388. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65389. }
  65390. }
  65391. declare module BABYLON {
  65392. /**
  65393. * Class used to create a trail following a mesh
  65394. */
  65395. export class TrailMesh extends Mesh {
  65396. private _generator;
  65397. private _autoStart;
  65398. private _running;
  65399. private _diameter;
  65400. private _length;
  65401. private _sectionPolygonPointsCount;
  65402. private _sectionVectors;
  65403. private _sectionNormalVectors;
  65404. private _beforeRenderObserver;
  65405. /**
  65406. * @constructor
  65407. * @param name The value used by scene.getMeshByName() to do a lookup.
  65408. * @param generator The mesh or transform node to generate a trail.
  65409. * @param scene The scene to add this mesh to.
  65410. * @param diameter Diameter of trailing mesh. Default is 1.
  65411. * @param length Length of trailing mesh. Default is 60.
  65412. * @param autoStart Automatically start trailing mesh. Default true.
  65413. */
  65414. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65415. /**
  65416. * "TrailMesh"
  65417. * @returns "TrailMesh"
  65418. */
  65419. getClassName(): string;
  65420. private _createMesh;
  65421. /**
  65422. * Start trailing mesh.
  65423. */
  65424. start(): void;
  65425. /**
  65426. * Stop trailing mesh.
  65427. */
  65428. stop(): void;
  65429. /**
  65430. * Update trailing mesh geometry.
  65431. */
  65432. update(): void;
  65433. /**
  65434. * Returns a new TrailMesh object.
  65435. * @param name is a string, the name given to the new mesh
  65436. * @param newGenerator use new generator object for cloned trail mesh
  65437. * @returns a new mesh
  65438. */
  65439. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65440. /**
  65441. * Serializes this trail mesh
  65442. * @param serializationObject object to write serialization to
  65443. */
  65444. serialize(serializationObject: any): void;
  65445. /**
  65446. * Parses a serialized trail mesh
  65447. * @param parsedMesh the serialized mesh
  65448. * @param scene the scene to create the trail mesh in
  65449. * @returns the created trail mesh
  65450. */
  65451. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65452. }
  65453. }
  65454. declare module BABYLON {
  65455. /**
  65456. * Class containing static functions to help procedurally build meshes
  65457. */
  65458. export class TiledBoxBuilder {
  65459. /**
  65460. * Creates a box mesh
  65461. * 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)
  65462. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65463. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65464. * * 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
  65465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65466. * @param name defines the name of the mesh
  65467. * @param options defines the options used to create the mesh
  65468. * @param scene defines the hosting scene
  65469. * @returns the box mesh
  65470. */
  65471. static CreateTiledBox(name: string, options: {
  65472. pattern?: number;
  65473. width?: number;
  65474. height?: number;
  65475. depth?: number;
  65476. tileSize?: number;
  65477. tileWidth?: number;
  65478. tileHeight?: number;
  65479. alignHorizontal?: number;
  65480. alignVertical?: number;
  65481. faceUV?: Vector4[];
  65482. faceColors?: Color4[];
  65483. sideOrientation?: number;
  65484. updatable?: boolean;
  65485. }, scene?: Nullable<Scene>): Mesh;
  65486. }
  65487. }
  65488. declare module BABYLON {
  65489. /**
  65490. * Class containing static functions to help procedurally build meshes
  65491. */
  65492. export class TorusKnotBuilder {
  65493. /**
  65494. * Creates a torus knot mesh
  65495. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65496. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65497. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65498. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65500. * * 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
  65501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65502. * @param name defines the name of the mesh
  65503. * @param options defines the options used to create the mesh
  65504. * @param scene defines the hosting scene
  65505. * @returns the torus knot mesh
  65506. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65507. */
  65508. static CreateTorusKnot(name: string, options: {
  65509. radius?: number;
  65510. tube?: number;
  65511. radialSegments?: number;
  65512. tubularSegments?: number;
  65513. p?: number;
  65514. q?: number;
  65515. updatable?: boolean;
  65516. sideOrientation?: number;
  65517. frontUVs?: Vector4;
  65518. backUVs?: Vector4;
  65519. }, scene: any): Mesh;
  65520. }
  65521. }
  65522. declare module BABYLON {
  65523. /**
  65524. * Polygon
  65525. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  65526. */
  65527. export class Polygon {
  65528. /**
  65529. * Creates a rectangle
  65530. * @param xmin bottom X coord
  65531. * @param ymin bottom Y coord
  65532. * @param xmax top X coord
  65533. * @param ymax top Y coord
  65534. * @returns points that make the resulting rectation
  65535. */
  65536. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  65537. /**
  65538. * Creates a circle
  65539. * @param radius radius of circle
  65540. * @param cx scale in x
  65541. * @param cy scale in y
  65542. * @param numberOfSides number of sides that make up the circle
  65543. * @returns points that make the resulting circle
  65544. */
  65545. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  65546. /**
  65547. * Creates a polygon from input string
  65548. * @param input Input polygon data
  65549. * @returns the parsed points
  65550. */
  65551. static Parse(input: string): Vector2[];
  65552. /**
  65553. * Starts building a polygon from x and y coordinates
  65554. * @param x x coordinate
  65555. * @param y y coordinate
  65556. * @returns the started path2
  65557. */
  65558. static StartingAt(x: number, y: number): Path2;
  65559. }
  65560. /**
  65561. * Builds a polygon
  65562. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  65563. */
  65564. export class PolygonMeshBuilder {
  65565. private _points;
  65566. private _outlinepoints;
  65567. private _holes;
  65568. private _name;
  65569. private _scene;
  65570. private _epoints;
  65571. private _eholes;
  65572. private _addToepoint;
  65573. /**
  65574. * Babylon reference to the earcut plugin.
  65575. */
  65576. bjsEarcut: any;
  65577. /**
  65578. * Creates a PolygonMeshBuilder
  65579. * @param name name of the builder
  65580. * @param contours Path of the polygon
  65581. * @param scene scene to add to when creating the mesh
  65582. * @param earcutInjection can be used to inject your own earcut reference
  65583. */
  65584. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  65585. /**
  65586. * Adds a whole within the polygon
  65587. * @param hole Array of points defining the hole
  65588. * @returns this
  65589. */
  65590. addHole(hole: Vector2[]): PolygonMeshBuilder;
  65591. /**
  65592. * Creates the polygon
  65593. * @param updatable If the mesh should be updatable
  65594. * @param depth The depth of the mesh created
  65595. * @returns the created mesh
  65596. */
  65597. build(updatable?: boolean, depth?: number): Mesh;
  65598. /**
  65599. * Creates the polygon
  65600. * @param depth The depth of the mesh created
  65601. * @returns the created VertexData
  65602. */
  65603. buildVertexData(depth?: number): VertexData;
  65604. /**
  65605. * Adds a side to the polygon
  65606. * @param positions points that make the polygon
  65607. * @param normals normals of the polygon
  65608. * @param uvs uvs of the polygon
  65609. * @param indices indices of the polygon
  65610. * @param bounds bounds of the polygon
  65611. * @param points points of the polygon
  65612. * @param depth depth of the polygon
  65613. * @param flip flip of the polygon
  65614. */
  65615. private addSide;
  65616. }
  65617. }
  65618. declare module BABYLON {
  65619. /**
  65620. * Class containing static functions to help procedurally build meshes
  65621. */
  65622. export class PolygonBuilder {
  65623. /**
  65624. * Creates a polygon mesh
  65625. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65626. * * 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
  65627. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65629. * * 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)
  65630. * * Remember you can only change the shape positions, not their number when updating a polygon
  65631. * @param name defines the name of the mesh
  65632. * @param options defines the options used to create the mesh
  65633. * @param scene defines the hosting scene
  65634. * @param earcutInjection can be used to inject your own earcut reference
  65635. * @returns the polygon mesh
  65636. */
  65637. static CreatePolygon(name: string, options: {
  65638. shape: Vector3[];
  65639. holes?: Vector3[][];
  65640. depth?: number;
  65641. faceUV?: Vector4[];
  65642. faceColors?: Color4[];
  65643. updatable?: boolean;
  65644. sideOrientation?: number;
  65645. frontUVs?: Vector4;
  65646. backUVs?: Vector4;
  65647. wrap?: boolean;
  65648. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65649. /**
  65650. * Creates an extruded polygon mesh, with depth in the Y direction.
  65651. * * 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)
  65652. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65653. * @param name defines the name of the mesh
  65654. * @param options defines the options used to create the mesh
  65655. * @param scene defines the hosting scene
  65656. * @param earcutInjection can be used to inject your own earcut reference
  65657. * @returns the polygon mesh
  65658. */
  65659. static ExtrudePolygon(name: string, options: {
  65660. shape: Vector3[];
  65661. holes?: Vector3[][];
  65662. depth?: number;
  65663. faceUV?: Vector4[];
  65664. faceColors?: Color4[];
  65665. updatable?: boolean;
  65666. sideOrientation?: number;
  65667. frontUVs?: Vector4;
  65668. backUVs?: Vector4;
  65669. wrap?: boolean;
  65670. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65671. }
  65672. }
  65673. declare module BABYLON {
  65674. /**
  65675. * Class containing static functions to help procedurally build meshes
  65676. */
  65677. export class LatheBuilder {
  65678. /**
  65679. * Creates lathe mesh.
  65680. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65681. * * 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
  65682. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65683. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65684. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65685. * * 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
  65686. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65687. * * 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
  65688. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65689. * * 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
  65690. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65692. * @param name defines the name of the mesh
  65693. * @param options defines the options used to create the mesh
  65694. * @param scene defines the hosting scene
  65695. * @returns the lathe mesh
  65696. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65697. */
  65698. static CreateLathe(name: string, options: {
  65699. shape: Vector3[];
  65700. radius?: number;
  65701. tessellation?: number;
  65702. clip?: number;
  65703. arc?: number;
  65704. closed?: boolean;
  65705. updatable?: boolean;
  65706. sideOrientation?: number;
  65707. frontUVs?: Vector4;
  65708. backUVs?: Vector4;
  65709. cap?: number;
  65710. invertUV?: boolean;
  65711. }, scene?: Nullable<Scene>): Mesh;
  65712. }
  65713. }
  65714. declare module BABYLON {
  65715. /**
  65716. * Class containing static functions to help procedurally build meshes
  65717. */
  65718. export class TiledPlaneBuilder {
  65719. /**
  65720. * Creates a tiled plane mesh
  65721. * * The parameter `pattern` will, depending on value, do nothing or
  65722. * * * flip (reflect about central vertical) alternate tiles across and up
  65723. * * * flip every tile on alternate rows
  65724. * * * rotate (180 degs) alternate tiles across and up
  65725. * * * rotate every tile on alternate rows
  65726. * * * flip and rotate alternate tiles across and up
  65727. * * * flip and rotate every tile on alternate rows
  65728. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  65729. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  65730. * * 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
  65731. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65732. * * 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)
  65733. * * 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)
  65734. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65735. * @param name defines the name of the mesh
  65736. * @param options defines the options used to create the mesh
  65737. * @param scene defines the hosting scene
  65738. * @returns the box mesh
  65739. */
  65740. static CreateTiledPlane(name: string, options: {
  65741. pattern?: number;
  65742. tileSize?: number;
  65743. tileWidth?: number;
  65744. tileHeight?: number;
  65745. size?: number;
  65746. width?: number;
  65747. height?: number;
  65748. alignHorizontal?: number;
  65749. alignVertical?: number;
  65750. sideOrientation?: number;
  65751. frontUVs?: Vector4;
  65752. backUVs?: Vector4;
  65753. updatable?: boolean;
  65754. }, scene?: Nullable<Scene>): Mesh;
  65755. }
  65756. }
  65757. declare module BABYLON {
  65758. /**
  65759. * Class containing static functions to help procedurally build meshes
  65760. */
  65761. export class TubeBuilder {
  65762. /**
  65763. * Creates a tube mesh.
  65764. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65765. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65766. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65767. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65768. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65769. * * 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)
  65770. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65771. * * 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
  65772. * * 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
  65773. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65774. * * 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
  65775. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65777. * @param name defines the name of the mesh
  65778. * @param options defines the options used to create the mesh
  65779. * @param scene defines the hosting scene
  65780. * @returns the tube mesh
  65781. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65782. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65783. */
  65784. static CreateTube(name: string, options: {
  65785. path: Vector3[];
  65786. radius?: number;
  65787. tessellation?: number;
  65788. radiusFunction?: {
  65789. (i: number, distance: number): number;
  65790. };
  65791. cap?: number;
  65792. arc?: number;
  65793. updatable?: boolean;
  65794. sideOrientation?: number;
  65795. frontUVs?: Vector4;
  65796. backUVs?: Vector4;
  65797. instance?: Mesh;
  65798. invertUV?: boolean;
  65799. }, scene?: Nullable<Scene>): Mesh;
  65800. }
  65801. }
  65802. declare module BABYLON {
  65803. /**
  65804. * Class containing static functions to help procedurally build meshes
  65805. */
  65806. export class IcoSphereBuilder {
  65807. /**
  65808. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65809. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65810. * * 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`)
  65811. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65812. * * 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
  65813. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65814. * * 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
  65815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65816. * @param name defines the name of the mesh
  65817. * @param options defines the options used to create the mesh
  65818. * @param scene defines the hosting scene
  65819. * @returns the icosahedron mesh
  65820. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65821. */
  65822. static CreateIcoSphere(name: string, options: {
  65823. radius?: number;
  65824. radiusX?: number;
  65825. radiusY?: number;
  65826. radiusZ?: number;
  65827. flat?: boolean;
  65828. subdivisions?: number;
  65829. sideOrientation?: number;
  65830. frontUVs?: Vector4;
  65831. backUVs?: Vector4;
  65832. updatable?: boolean;
  65833. }, scene?: Nullable<Scene>): Mesh;
  65834. }
  65835. }
  65836. declare module BABYLON {
  65837. /**
  65838. * Class containing static functions to help procedurally build meshes
  65839. */
  65840. export class DecalBuilder {
  65841. /**
  65842. * Creates a decal mesh.
  65843. * 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
  65844. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65845. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65846. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65847. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65848. * @param name defines the name of the mesh
  65849. * @param sourceMesh defines the mesh where the decal must be applied
  65850. * @param options defines the options used to create the mesh
  65851. * @param scene defines the hosting scene
  65852. * @returns the decal mesh
  65853. * @see https://doc.babylonjs.com/how_to/decals
  65854. */
  65855. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65856. position?: Vector3;
  65857. normal?: Vector3;
  65858. size?: Vector3;
  65859. angle?: number;
  65860. }): Mesh;
  65861. }
  65862. }
  65863. declare module BABYLON {
  65864. /**
  65865. * Class containing static functions to help procedurally build meshes
  65866. */
  65867. export class MeshBuilder {
  65868. /**
  65869. * Creates a box mesh
  65870. * * The parameter `size` sets the size (float) of each box side (default 1)
  65871. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  65872. * * 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)
  65873. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65874. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65875. * * 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
  65876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65877. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65878. * @param name defines the name of the mesh
  65879. * @param options defines the options used to create the mesh
  65880. * @param scene defines the hosting scene
  65881. * @returns the box mesh
  65882. */
  65883. static CreateBox(name: string, options: {
  65884. size?: number;
  65885. width?: number;
  65886. height?: number;
  65887. depth?: number;
  65888. faceUV?: Vector4[];
  65889. faceColors?: Color4[];
  65890. sideOrientation?: number;
  65891. frontUVs?: Vector4;
  65892. backUVs?: Vector4;
  65893. wrap?: boolean;
  65894. topBaseAt?: number;
  65895. bottomBaseAt?: number;
  65896. updatable?: boolean;
  65897. }, scene?: Nullable<Scene>): Mesh;
  65898. /**
  65899. * Creates a tiled box mesh
  65900. * * faceTiles sets the pattern, tile size and number of tiles for a face
  65901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65902. * @param name defines the name of the mesh
  65903. * @param options defines the options used to create the mesh
  65904. * @param scene defines the hosting scene
  65905. * @returns the tiled box mesh
  65906. */
  65907. static CreateTiledBox(name: string, options: {
  65908. pattern?: number;
  65909. size?: number;
  65910. width?: number;
  65911. height?: number;
  65912. depth: number;
  65913. tileSize?: number;
  65914. tileWidth?: number;
  65915. tileHeight?: number;
  65916. faceUV?: Vector4[];
  65917. faceColors?: Color4[];
  65918. alignHorizontal?: number;
  65919. alignVertical?: number;
  65920. sideOrientation?: number;
  65921. updatable?: boolean;
  65922. }, scene?: Nullable<Scene>): Mesh;
  65923. /**
  65924. * Creates a sphere mesh
  65925. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  65926. * * 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`)
  65927. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  65928. * * 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
  65929. * * 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)
  65930. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65931. * * 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
  65932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65933. * @param name defines the name of the mesh
  65934. * @param options defines the options used to create the mesh
  65935. * @param scene defines the hosting scene
  65936. * @returns the sphere mesh
  65937. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  65938. */
  65939. static CreateSphere(name: string, options: {
  65940. segments?: number;
  65941. diameter?: number;
  65942. diameterX?: number;
  65943. diameterY?: number;
  65944. diameterZ?: number;
  65945. arc?: number;
  65946. slice?: number;
  65947. sideOrientation?: number;
  65948. frontUVs?: Vector4;
  65949. backUVs?: Vector4;
  65950. updatable?: boolean;
  65951. }, scene?: Nullable<Scene>): Mesh;
  65952. /**
  65953. * Creates a plane polygonal mesh. By default, this is a disc
  65954. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  65955. * * 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
  65956. * * 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
  65957. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65958. * * 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
  65959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65960. * @param name defines the name of the mesh
  65961. * @param options defines the options used to create the mesh
  65962. * @param scene defines the hosting scene
  65963. * @returns the plane polygonal mesh
  65964. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  65965. */
  65966. static CreateDisc(name: string, options: {
  65967. radius?: number;
  65968. tessellation?: number;
  65969. arc?: number;
  65970. updatable?: boolean;
  65971. sideOrientation?: number;
  65972. frontUVs?: Vector4;
  65973. backUVs?: Vector4;
  65974. }, scene?: Nullable<Scene>): Mesh;
  65975. /**
  65976. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65977. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65978. * * 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`)
  65979. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65980. * * 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
  65981. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65982. * * 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
  65983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65984. * @param name defines the name of the mesh
  65985. * @param options defines the options used to create the mesh
  65986. * @param scene defines the hosting scene
  65987. * @returns the icosahedron mesh
  65988. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65989. */
  65990. static CreateIcoSphere(name: string, options: {
  65991. radius?: number;
  65992. radiusX?: number;
  65993. radiusY?: number;
  65994. radiusZ?: number;
  65995. flat?: boolean;
  65996. subdivisions?: number;
  65997. sideOrientation?: number;
  65998. frontUVs?: Vector4;
  65999. backUVs?: Vector4;
  66000. updatable?: boolean;
  66001. }, scene?: Nullable<Scene>): Mesh;
  66002. /**
  66003. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66004. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  66005. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  66006. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  66007. * * 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
  66008. * * 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
  66009. * * 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
  66010. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66011. * * 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
  66012. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66013. * * 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
  66014. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  66015. * * 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
  66016. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  66017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66018. * @param name defines the name of the mesh
  66019. * @param options defines the options used to create the mesh
  66020. * @param scene defines the hosting scene
  66021. * @returns the ribbon mesh
  66022. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  66023. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66024. */
  66025. static CreateRibbon(name: string, options: {
  66026. pathArray: Vector3[][];
  66027. closeArray?: boolean;
  66028. closePath?: boolean;
  66029. offset?: number;
  66030. updatable?: boolean;
  66031. sideOrientation?: number;
  66032. frontUVs?: Vector4;
  66033. backUVs?: Vector4;
  66034. instance?: Mesh;
  66035. invertUV?: boolean;
  66036. uvs?: Vector2[];
  66037. colors?: Color4[];
  66038. }, scene?: Nullable<Scene>): Mesh;
  66039. /**
  66040. * Creates a cylinder or a cone mesh
  66041. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  66042. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  66043. * * 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.
  66044. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  66045. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  66046. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  66047. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  66048. * * 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).
  66049. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  66050. * * 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).
  66051. * * 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
  66052. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  66053. * * 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
  66054. * * 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.
  66055. * * If `enclose` is false, a ring surface is one element.
  66056. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  66057. * * 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
  66058. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66059. * * 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
  66060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66061. * @param name defines the name of the mesh
  66062. * @param options defines the options used to create the mesh
  66063. * @param scene defines the hosting scene
  66064. * @returns the cylinder mesh
  66065. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  66066. */
  66067. static CreateCylinder(name: string, options: {
  66068. height?: number;
  66069. diameterTop?: number;
  66070. diameterBottom?: number;
  66071. diameter?: number;
  66072. tessellation?: number;
  66073. subdivisions?: number;
  66074. arc?: number;
  66075. faceColors?: Color4[];
  66076. faceUV?: Vector4[];
  66077. updatable?: boolean;
  66078. hasRings?: boolean;
  66079. enclose?: boolean;
  66080. cap?: number;
  66081. sideOrientation?: number;
  66082. frontUVs?: Vector4;
  66083. backUVs?: Vector4;
  66084. }, scene?: Nullable<Scene>): Mesh;
  66085. /**
  66086. * Creates a torus mesh
  66087. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  66088. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  66089. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  66090. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66091. * * 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
  66092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66093. * @param name defines the name of the mesh
  66094. * @param options defines the options used to create the mesh
  66095. * @param scene defines the hosting scene
  66096. * @returns the torus mesh
  66097. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  66098. */
  66099. static CreateTorus(name: string, options: {
  66100. diameter?: number;
  66101. thickness?: number;
  66102. tessellation?: number;
  66103. updatable?: boolean;
  66104. sideOrientation?: number;
  66105. frontUVs?: Vector4;
  66106. backUVs?: Vector4;
  66107. }, scene?: Nullable<Scene>): Mesh;
  66108. /**
  66109. * Creates a torus knot mesh
  66110. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66111. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66112. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66113. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66115. * * 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
  66116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66117. * @param name defines the name of the mesh
  66118. * @param options defines the options used to create the mesh
  66119. * @param scene defines the hosting scene
  66120. * @returns the torus knot mesh
  66121. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66122. */
  66123. static CreateTorusKnot(name: string, options: {
  66124. radius?: number;
  66125. tube?: number;
  66126. radialSegments?: number;
  66127. tubularSegments?: number;
  66128. p?: number;
  66129. q?: number;
  66130. updatable?: boolean;
  66131. sideOrientation?: number;
  66132. frontUVs?: Vector4;
  66133. backUVs?: Vector4;
  66134. }, scene?: Nullable<Scene>): Mesh;
  66135. /**
  66136. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  66137. * * 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
  66138. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  66139. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  66140. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  66141. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  66142. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  66143. * * 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
  66144. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  66145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66146. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  66147. * @param name defines the name of the new line system
  66148. * @param options defines the options used to create the line system
  66149. * @param scene defines the hosting scene
  66150. * @returns a new line system mesh
  66151. */
  66152. static CreateLineSystem(name: string, options: {
  66153. lines: Vector3[][];
  66154. updatable?: boolean;
  66155. instance?: Nullable<LinesMesh>;
  66156. colors?: Nullable<Color4[][]>;
  66157. useVertexAlpha?: boolean;
  66158. }, scene: Nullable<Scene>): LinesMesh;
  66159. /**
  66160. * Creates a line mesh
  66161. * 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
  66162. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66163. * * The parameter `points` is an array successive Vector3
  66164. * * 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
  66165. * * The optional parameter `colors` is an array of successive Color4, one per line point
  66166. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  66167. * * When updating an instance, remember that only point positions can change, not the number of points
  66168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66169. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  66170. * @param name defines the name of the new line system
  66171. * @param options defines the options used to create the line system
  66172. * @param scene defines the hosting scene
  66173. * @returns a new line mesh
  66174. */
  66175. static CreateLines(name: string, options: {
  66176. points: Vector3[];
  66177. updatable?: boolean;
  66178. instance?: Nullable<LinesMesh>;
  66179. colors?: Color4[];
  66180. useVertexAlpha?: boolean;
  66181. }, scene?: Nullable<Scene>): LinesMesh;
  66182. /**
  66183. * Creates a dashed line mesh
  66184. * * 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
  66185. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66186. * * The parameter `points` is an array successive Vector3
  66187. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  66188. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  66189. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  66190. * * 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
  66191. * * When updating an instance, remember that only point positions can change, not the number of points
  66192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66193. * @param name defines the name of the mesh
  66194. * @param options defines the options used to create the mesh
  66195. * @param scene defines the hosting scene
  66196. * @returns the dashed line mesh
  66197. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  66198. */
  66199. static CreateDashedLines(name: string, options: {
  66200. points: Vector3[];
  66201. dashSize?: number;
  66202. gapSize?: number;
  66203. dashNb?: number;
  66204. updatable?: boolean;
  66205. instance?: LinesMesh;
  66206. }, scene?: Nullable<Scene>): LinesMesh;
  66207. /**
  66208. * 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.
  66209. * * 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.
  66210. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66211. * * 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.
  66212. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  66213. * * 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
  66214. * * 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
  66215. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  66216. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66217. * * 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
  66218. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  66219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66220. * @param name defines the name of the mesh
  66221. * @param options defines the options used to create the mesh
  66222. * @param scene defines the hosting scene
  66223. * @returns the extruded shape mesh
  66224. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66225. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66226. */
  66227. static ExtrudeShape(name: string, options: {
  66228. shape: Vector3[];
  66229. path: Vector3[];
  66230. scale?: number;
  66231. rotation?: number;
  66232. cap?: number;
  66233. updatable?: boolean;
  66234. sideOrientation?: number;
  66235. frontUVs?: Vector4;
  66236. backUVs?: Vector4;
  66237. instance?: Mesh;
  66238. invertUV?: boolean;
  66239. }, scene?: Nullable<Scene>): Mesh;
  66240. /**
  66241. * Creates an custom extruded shape mesh.
  66242. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  66243. * * 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.
  66244. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66245. * * 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
  66246. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  66247. * * 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
  66248. * * It must returns a float value that will be the scale value applied to the shape on each path point
  66249. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  66250. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  66251. * * 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
  66252. * * 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
  66253. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  66254. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66255. * * 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
  66256. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66258. * @param name defines the name of the mesh
  66259. * @param options defines the options used to create the mesh
  66260. * @param scene defines the hosting scene
  66261. * @returns the custom extruded shape mesh
  66262. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66263. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66264. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66265. */
  66266. static ExtrudeShapeCustom(name: string, options: {
  66267. shape: Vector3[];
  66268. path: Vector3[];
  66269. scaleFunction?: any;
  66270. rotationFunction?: any;
  66271. ribbonCloseArray?: boolean;
  66272. ribbonClosePath?: boolean;
  66273. cap?: number;
  66274. updatable?: boolean;
  66275. sideOrientation?: number;
  66276. frontUVs?: Vector4;
  66277. backUVs?: Vector4;
  66278. instance?: Mesh;
  66279. invertUV?: boolean;
  66280. }, scene?: Nullable<Scene>): Mesh;
  66281. /**
  66282. * Creates lathe mesh.
  66283. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66284. * * 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
  66285. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66286. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66287. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66288. * * 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
  66289. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66290. * * 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
  66291. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66292. * * 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
  66293. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66295. * @param name defines the name of the mesh
  66296. * @param options defines the options used to create the mesh
  66297. * @param scene defines the hosting scene
  66298. * @returns the lathe mesh
  66299. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66300. */
  66301. static CreateLathe(name: string, options: {
  66302. shape: Vector3[];
  66303. radius?: number;
  66304. tessellation?: number;
  66305. clip?: number;
  66306. arc?: number;
  66307. closed?: boolean;
  66308. updatable?: boolean;
  66309. sideOrientation?: number;
  66310. frontUVs?: Vector4;
  66311. backUVs?: Vector4;
  66312. cap?: number;
  66313. invertUV?: boolean;
  66314. }, scene?: Nullable<Scene>): Mesh;
  66315. /**
  66316. * Creates a tiled plane mesh
  66317. * * You can set a limited pattern arrangement with the tiles
  66318. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66319. * * 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
  66320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66321. * @param name defines the name of the mesh
  66322. * @param options defines the options used to create the mesh
  66323. * @param scene defines the hosting scene
  66324. * @returns the plane mesh
  66325. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66326. */
  66327. static CreateTiledPlane(name: string, options: {
  66328. pattern?: number;
  66329. tileSize?: number;
  66330. tileWidth?: number;
  66331. tileHeight?: number;
  66332. size?: number;
  66333. width?: number;
  66334. height?: number;
  66335. alignHorizontal?: number;
  66336. alignVertical?: number;
  66337. sideOrientation?: number;
  66338. frontUVs?: Vector4;
  66339. backUVs?: Vector4;
  66340. updatable?: boolean;
  66341. }, scene?: Nullable<Scene>): Mesh;
  66342. /**
  66343. * Creates a plane mesh
  66344. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66345. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66346. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66348. * * 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
  66349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66350. * @param name defines the name of the mesh
  66351. * @param options defines the options used to create the mesh
  66352. * @param scene defines the hosting scene
  66353. * @returns the plane mesh
  66354. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66355. */
  66356. static CreatePlane(name: string, options: {
  66357. size?: number;
  66358. width?: number;
  66359. height?: number;
  66360. sideOrientation?: number;
  66361. frontUVs?: Vector4;
  66362. backUVs?: Vector4;
  66363. updatable?: boolean;
  66364. sourcePlane?: Plane;
  66365. }, scene?: Nullable<Scene>): Mesh;
  66366. /**
  66367. * Creates a ground mesh
  66368. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66369. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66371. * @param name defines the name of the mesh
  66372. * @param options defines the options used to create the mesh
  66373. * @param scene defines the hosting scene
  66374. * @returns the ground mesh
  66375. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66376. */
  66377. static CreateGround(name: string, options: {
  66378. width?: number;
  66379. height?: number;
  66380. subdivisions?: number;
  66381. subdivisionsX?: number;
  66382. subdivisionsY?: number;
  66383. updatable?: boolean;
  66384. }, scene?: Nullable<Scene>): Mesh;
  66385. /**
  66386. * Creates a tiled ground mesh
  66387. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66388. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66389. * * 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
  66390. * * 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
  66391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66392. * @param name defines the name of the mesh
  66393. * @param options defines the options used to create the mesh
  66394. * @param scene defines the hosting scene
  66395. * @returns the tiled ground mesh
  66396. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66397. */
  66398. static CreateTiledGround(name: string, options: {
  66399. xmin: number;
  66400. zmin: number;
  66401. xmax: number;
  66402. zmax: number;
  66403. subdivisions?: {
  66404. w: number;
  66405. h: number;
  66406. };
  66407. precision?: {
  66408. w: number;
  66409. h: number;
  66410. };
  66411. updatable?: boolean;
  66412. }, scene?: Nullable<Scene>): Mesh;
  66413. /**
  66414. * Creates a ground mesh from a height map
  66415. * * The parameter `url` sets the URL of the height map image resource.
  66416. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66417. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66418. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66419. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66420. * * 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.
  66421. * * 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).
  66422. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  66423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66424. * @param name defines the name of the mesh
  66425. * @param url defines the url to the height map
  66426. * @param options defines the options used to create the mesh
  66427. * @param scene defines the hosting scene
  66428. * @returns the ground mesh
  66429. * @see https://doc.babylonjs.com/babylon101/height_map
  66430. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66431. */
  66432. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66433. width?: number;
  66434. height?: number;
  66435. subdivisions?: number;
  66436. minHeight?: number;
  66437. maxHeight?: number;
  66438. colorFilter?: Color3;
  66439. alphaFilter?: number;
  66440. updatable?: boolean;
  66441. onReady?: (mesh: GroundMesh) => void;
  66442. }, scene?: Nullable<Scene>): GroundMesh;
  66443. /**
  66444. * Creates a polygon mesh
  66445. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66446. * * 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
  66447. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66449. * * 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)
  66450. * * Remember you can only change the shape positions, not their number when updating a polygon
  66451. * @param name defines the name of the mesh
  66452. * @param options defines the options used to create the mesh
  66453. * @param scene defines the hosting scene
  66454. * @param earcutInjection can be used to inject your own earcut reference
  66455. * @returns the polygon mesh
  66456. */
  66457. static CreatePolygon(name: string, options: {
  66458. shape: Vector3[];
  66459. holes?: Vector3[][];
  66460. depth?: number;
  66461. faceUV?: Vector4[];
  66462. faceColors?: Color4[];
  66463. updatable?: boolean;
  66464. sideOrientation?: number;
  66465. frontUVs?: Vector4;
  66466. backUVs?: Vector4;
  66467. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66468. /**
  66469. * Creates an extruded polygon mesh, with depth in the Y direction.
  66470. * * 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)
  66471. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66472. * @param name defines the name of the mesh
  66473. * @param options defines the options used to create the mesh
  66474. * @param scene defines the hosting scene
  66475. * @param earcutInjection can be used to inject your own earcut reference
  66476. * @returns the polygon mesh
  66477. */
  66478. static ExtrudePolygon(name: string, options: {
  66479. shape: Vector3[];
  66480. holes?: Vector3[][];
  66481. depth?: number;
  66482. faceUV?: Vector4[];
  66483. faceColors?: Color4[];
  66484. updatable?: boolean;
  66485. sideOrientation?: number;
  66486. frontUVs?: Vector4;
  66487. backUVs?: Vector4;
  66488. wrap?: boolean;
  66489. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66490. /**
  66491. * Creates a tube mesh.
  66492. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66493. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66494. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66495. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66496. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66497. * * 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)
  66498. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66499. * * 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
  66500. * * 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
  66501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66502. * * 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
  66503. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66505. * @param name defines the name of the mesh
  66506. * @param options defines the options used to create the mesh
  66507. * @param scene defines the hosting scene
  66508. * @returns the tube mesh
  66509. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66510. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66511. */
  66512. static CreateTube(name: string, options: {
  66513. path: Vector3[];
  66514. radius?: number;
  66515. tessellation?: number;
  66516. radiusFunction?: {
  66517. (i: number, distance: number): number;
  66518. };
  66519. cap?: number;
  66520. arc?: number;
  66521. updatable?: boolean;
  66522. sideOrientation?: number;
  66523. frontUVs?: Vector4;
  66524. backUVs?: Vector4;
  66525. instance?: Mesh;
  66526. invertUV?: boolean;
  66527. }, scene?: Nullable<Scene>): Mesh;
  66528. /**
  66529. * Creates a polyhedron mesh
  66530. * * 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
  66531. * * The parameter `size` (positive float, default 1) sets the polygon size
  66532. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  66533. * * 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`
  66534. * * 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
  66535. * * 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)`)
  66536. * * 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
  66537. * * 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
  66538. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66539. * * 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
  66540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66541. * @param name defines the name of the mesh
  66542. * @param options defines the options used to create the mesh
  66543. * @param scene defines the hosting scene
  66544. * @returns the polyhedron mesh
  66545. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  66546. */
  66547. static CreatePolyhedron(name: string, options: {
  66548. type?: number;
  66549. size?: number;
  66550. sizeX?: number;
  66551. sizeY?: number;
  66552. sizeZ?: number;
  66553. custom?: any;
  66554. faceUV?: Vector4[];
  66555. faceColors?: Color4[];
  66556. flat?: boolean;
  66557. updatable?: boolean;
  66558. sideOrientation?: number;
  66559. frontUVs?: Vector4;
  66560. backUVs?: Vector4;
  66561. }, scene?: Nullable<Scene>): Mesh;
  66562. /**
  66563. * Creates a decal mesh.
  66564. * 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
  66565. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66566. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66567. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66568. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66569. * @param name defines the name of the mesh
  66570. * @param sourceMesh defines the mesh where the decal must be applied
  66571. * @param options defines the options used to create the mesh
  66572. * @param scene defines the hosting scene
  66573. * @returns the decal mesh
  66574. * @see https://doc.babylonjs.com/how_to/decals
  66575. */
  66576. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66577. position?: Vector3;
  66578. normal?: Vector3;
  66579. size?: Vector3;
  66580. angle?: number;
  66581. }): Mesh;
  66582. /**
  66583. * Creates a Capsule Mesh
  66584. * @param name defines the name of the mesh.
  66585. * @param options the constructors options used to shape the mesh.
  66586. * @param scene defines the scene the mesh is scoped to.
  66587. * @returns the capsule mesh
  66588. * @see https://doc.babylonjs.com/how_to/capsule_shape
  66589. */
  66590. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  66591. }
  66592. }
  66593. declare module BABYLON {
  66594. /**
  66595. * A simplifier interface for future simplification implementations
  66596. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66597. */
  66598. export interface ISimplifier {
  66599. /**
  66600. * Simplification of a given mesh according to the given settings.
  66601. * Since this requires computation, it is assumed that the function runs async.
  66602. * @param settings The settings of the simplification, including quality and distance
  66603. * @param successCallback A callback that will be called after the mesh was simplified.
  66604. * @param errorCallback in case of an error, this callback will be called. optional.
  66605. */
  66606. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  66607. }
  66608. /**
  66609. * Expected simplification settings.
  66610. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  66611. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66612. */
  66613. export interface ISimplificationSettings {
  66614. /**
  66615. * Gets or sets the expected quality
  66616. */
  66617. quality: number;
  66618. /**
  66619. * Gets or sets the distance when this optimized version should be used
  66620. */
  66621. distance: number;
  66622. /**
  66623. * Gets an already optimized mesh
  66624. */
  66625. optimizeMesh?: boolean;
  66626. }
  66627. /**
  66628. * Class used to specify simplification options
  66629. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66630. */
  66631. export class SimplificationSettings implements ISimplificationSettings {
  66632. /** expected quality */
  66633. quality: number;
  66634. /** distance when this optimized version should be used */
  66635. distance: number;
  66636. /** already optimized mesh */
  66637. optimizeMesh?: boolean | undefined;
  66638. /**
  66639. * Creates a SimplificationSettings
  66640. * @param quality expected quality
  66641. * @param distance distance when this optimized version should be used
  66642. * @param optimizeMesh already optimized mesh
  66643. */
  66644. constructor(
  66645. /** expected quality */
  66646. quality: number,
  66647. /** distance when this optimized version should be used */
  66648. distance: number,
  66649. /** already optimized mesh */
  66650. optimizeMesh?: boolean | undefined);
  66651. }
  66652. /**
  66653. * Interface used to define a simplification task
  66654. */
  66655. export interface ISimplificationTask {
  66656. /**
  66657. * Array of settings
  66658. */
  66659. settings: Array<ISimplificationSettings>;
  66660. /**
  66661. * Simplification type
  66662. */
  66663. simplificationType: SimplificationType;
  66664. /**
  66665. * Mesh to simplify
  66666. */
  66667. mesh: Mesh;
  66668. /**
  66669. * Callback called on success
  66670. */
  66671. successCallback?: () => void;
  66672. /**
  66673. * Defines if parallel processing can be used
  66674. */
  66675. parallelProcessing: boolean;
  66676. }
  66677. /**
  66678. * Queue used to order the simplification tasks
  66679. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66680. */
  66681. export class SimplificationQueue {
  66682. private _simplificationArray;
  66683. /**
  66684. * Gets a boolean indicating that the process is still running
  66685. */
  66686. running: boolean;
  66687. /**
  66688. * Creates a new queue
  66689. */
  66690. constructor();
  66691. /**
  66692. * Adds a new simplification task
  66693. * @param task defines a task to add
  66694. */
  66695. addTask(task: ISimplificationTask): void;
  66696. /**
  66697. * Execute next task
  66698. */
  66699. executeNext(): void;
  66700. /**
  66701. * Execute a simplification task
  66702. * @param task defines the task to run
  66703. */
  66704. runSimplification(task: ISimplificationTask): void;
  66705. private getSimplifier;
  66706. }
  66707. /**
  66708. * The implemented types of simplification
  66709. * At the moment only Quadratic Error Decimation is implemented
  66710. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66711. */
  66712. export enum SimplificationType {
  66713. /** Quadratic error decimation */
  66714. QUADRATIC = 0
  66715. }
  66716. /**
  66717. * An implementation of the Quadratic Error simplification algorithm.
  66718. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  66719. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  66720. * @author RaananW
  66721. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66722. */
  66723. export class QuadraticErrorSimplification implements ISimplifier {
  66724. private _mesh;
  66725. private triangles;
  66726. private vertices;
  66727. private references;
  66728. private _reconstructedMesh;
  66729. /** Gets or sets the number pf sync interations */
  66730. syncIterations: number;
  66731. /** Gets or sets the aggressiveness of the simplifier */
  66732. aggressiveness: number;
  66733. /** Gets or sets the number of allowed iterations for decimation */
  66734. decimationIterations: number;
  66735. /** Gets or sets the espilon to use for bounding box computation */
  66736. boundingBoxEpsilon: number;
  66737. /**
  66738. * Creates a new QuadraticErrorSimplification
  66739. * @param _mesh defines the target mesh
  66740. */
  66741. constructor(_mesh: Mesh);
  66742. /**
  66743. * Simplification of a given mesh according to the given settings.
  66744. * Since this requires computation, it is assumed that the function runs async.
  66745. * @param settings The settings of the simplification, including quality and distance
  66746. * @param successCallback A callback that will be called after the mesh was simplified.
  66747. */
  66748. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  66749. private runDecimation;
  66750. private initWithMesh;
  66751. private init;
  66752. private reconstructMesh;
  66753. private initDecimatedMesh;
  66754. private isFlipped;
  66755. private updateTriangles;
  66756. private identifyBorder;
  66757. private updateMesh;
  66758. private vertexError;
  66759. private calculateError;
  66760. }
  66761. }
  66762. declare module BABYLON {
  66763. interface Scene {
  66764. /** @hidden (Backing field) */
  66765. _simplificationQueue: SimplificationQueue;
  66766. /**
  66767. * Gets or sets the simplification queue attached to the scene
  66768. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66769. */
  66770. simplificationQueue: SimplificationQueue;
  66771. }
  66772. interface Mesh {
  66773. /**
  66774. * Simplify the mesh according to the given array of settings.
  66775. * Function will return immediately and will simplify async
  66776. * @param settings a collection of simplification settings
  66777. * @param parallelProcessing should all levels calculate parallel or one after the other
  66778. * @param simplificationType the type of simplification to run
  66779. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  66780. * @returns the current mesh
  66781. */
  66782. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  66783. }
  66784. /**
  66785. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  66786. * created in a scene
  66787. */
  66788. export class SimplicationQueueSceneComponent implements ISceneComponent {
  66789. /**
  66790. * The component name helpfull to identify the component in the list of scene components.
  66791. */
  66792. readonly name: string;
  66793. /**
  66794. * The scene the component belongs to.
  66795. */
  66796. scene: Scene;
  66797. /**
  66798. * Creates a new instance of the component for the given scene
  66799. * @param scene Defines the scene to register the component in
  66800. */
  66801. constructor(scene: Scene);
  66802. /**
  66803. * Registers the component in a given scene
  66804. */
  66805. register(): void;
  66806. /**
  66807. * Rebuilds the elements related to this component in case of
  66808. * context lost for instance.
  66809. */
  66810. rebuild(): void;
  66811. /**
  66812. * Disposes the component and the associated ressources
  66813. */
  66814. dispose(): void;
  66815. private _beforeCameraUpdate;
  66816. }
  66817. }
  66818. declare module BABYLON {
  66819. interface Mesh {
  66820. /**
  66821. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  66822. */
  66823. thinInstanceEnablePicking: boolean;
  66824. /**
  66825. * Creates a new thin instance
  66826. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  66827. * @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
  66828. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  66829. */
  66830. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  66831. /**
  66832. * Adds the transformation (matrix) of the current mesh as a thin instance
  66833. * @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
  66834. * @returns the thin instance index number
  66835. */
  66836. thinInstanceAddSelf(refresh: boolean): number;
  66837. /**
  66838. * Registers a custom attribute to be used with thin instances
  66839. * @param kind name of the attribute
  66840. * @param stride size in floats of the attribute
  66841. */
  66842. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  66843. /**
  66844. * Sets the matrix of a thin instance
  66845. * @param index index of the thin instance
  66846. * @param matrix matrix to set
  66847. * @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
  66848. */
  66849. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  66850. /**
  66851. * Sets the value of a custom attribute for a thin instance
  66852. * @param kind name of the attribute
  66853. * @param index index of the thin instance
  66854. * @param value value to set
  66855. * @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
  66856. */
  66857. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  66858. /**
  66859. * 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.
  66860. */
  66861. thinInstanceCount: number;
  66862. /**
  66863. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  66864. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  66865. * @param buffer buffer to set
  66866. * @param stride size in floats of each value of the buffer
  66867. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  66868. */
  66869. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  66870. /**
  66871. * Gets the list of world matrices
  66872. * @return an array containing all the world matrices from the thin instances
  66873. */
  66874. thinInstanceGetWorldMatrices(): Matrix[];
  66875. /**
  66876. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  66877. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66878. */
  66879. thinInstanceBufferUpdated(kind: string): void;
  66880. /**
  66881. * Applies a partial update to a buffer directly on the GPU
  66882. * 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
  66883. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66884. * @param data the data to set in the GPU buffer
  66885. * @param offset the offset in the GPU buffer where to update the data
  66886. */
  66887. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  66888. /**
  66889. * Refreshes the bounding info, taking into account all the thin instances defined
  66890. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  66891. */
  66892. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  66893. /** @hidden */
  66894. _thinInstanceInitializeUserStorage(): void;
  66895. /** @hidden */
  66896. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  66897. /** @hidden */
  66898. _userThinInstanceBuffersStorage: {
  66899. data: {
  66900. [key: string]: Float32Array;
  66901. };
  66902. sizes: {
  66903. [key: string]: number;
  66904. };
  66905. vertexBuffers: {
  66906. [key: string]: Nullable<VertexBuffer>;
  66907. };
  66908. strides: {
  66909. [key: string]: number;
  66910. };
  66911. };
  66912. }
  66913. }
  66914. declare module BABYLON {
  66915. /**
  66916. * Navigation plugin interface to add navigation constrained by a navigation mesh
  66917. */
  66918. export interface INavigationEnginePlugin {
  66919. /**
  66920. * plugin name
  66921. */
  66922. name: string;
  66923. /**
  66924. * Creates a navigation mesh
  66925. * @param meshes array of all the geometry used to compute the navigatio mesh
  66926. * @param parameters bunch of parameters used to filter geometry
  66927. */
  66928. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66929. /**
  66930. * Create a navigation mesh debug mesh
  66931. * @param scene is where the mesh will be added
  66932. * @returns debug display mesh
  66933. */
  66934. createDebugNavMesh(scene: Scene): Mesh;
  66935. /**
  66936. * Get a navigation mesh constrained position, closest to the parameter position
  66937. * @param position world position
  66938. * @returns the closest point to position constrained by the navigation mesh
  66939. */
  66940. getClosestPoint(position: Vector3): Vector3;
  66941. /**
  66942. * Get a navigation mesh constrained position, closest to the parameter position
  66943. * @param position world position
  66944. * @param result output the closest point to position constrained by the navigation mesh
  66945. */
  66946. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66947. /**
  66948. * Get a navigation mesh constrained position, within a particular radius
  66949. * @param position world position
  66950. * @param maxRadius the maximum distance to the constrained world position
  66951. * @returns the closest point to position constrained by the navigation mesh
  66952. */
  66953. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66954. /**
  66955. * Get a navigation mesh constrained position, within a particular radius
  66956. * @param position world position
  66957. * @param maxRadius the maximum distance to the constrained world position
  66958. * @param result output the closest point to position constrained by the navigation mesh
  66959. */
  66960. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66961. /**
  66962. * Compute the final position from a segment made of destination-position
  66963. * @param position world position
  66964. * @param destination world position
  66965. * @returns the resulting point along the navmesh
  66966. */
  66967. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66968. /**
  66969. * Compute the final position from a segment made of destination-position
  66970. * @param position world position
  66971. * @param destination world position
  66972. * @param result output the resulting point along the navmesh
  66973. */
  66974. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66975. /**
  66976. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66977. * @param start world position
  66978. * @param end world position
  66979. * @returns array containing world position composing the path
  66980. */
  66981. computePath(start: Vector3, end: Vector3): Vector3[];
  66982. /**
  66983. * If this plugin is supported
  66984. * @returns true if plugin is supported
  66985. */
  66986. isSupported(): boolean;
  66987. /**
  66988. * Create a new Crowd so you can add agents
  66989. * @param maxAgents the maximum agent count in the crowd
  66990. * @param maxAgentRadius the maximum radius an agent can have
  66991. * @param scene to attach the crowd to
  66992. * @returns the crowd you can add agents to
  66993. */
  66994. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66995. /**
  66996. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66997. * The queries will try to find a solution within those bounds
  66998. * default is (1,1,1)
  66999. * @param extent x,y,z value that define the extent around the queries point of reference
  67000. */
  67001. setDefaultQueryExtent(extent: Vector3): void;
  67002. /**
  67003. * Get the Bounding box extent specified by setDefaultQueryExtent
  67004. * @returns the box extent values
  67005. */
  67006. getDefaultQueryExtent(): Vector3;
  67007. /**
  67008. * build the navmesh from a previously saved state using getNavmeshData
  67009. * @param data the Uint8Array returned by getNavmeshData
  67010. */
  67011. buildFromNavmeshData(data: Uint8Array): void;
  67012. /**
  67013. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67014. * @returns data the Uint8Array that can be saved and reused
  67015. */
  67016. getNavmeshData(): Uint8Array;
  67017. /**
  67018. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67019. * @param result output the box extent values
  67020. */
  67021. getDefaultQueryExtentToRef(result: Vector3): void;
  67022. /**
  67023. * Release all resources
  67024. */
  67025. dispose(): void;
  67026. }
  67027. /**
  67028. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  67029. */
  67030. export interface ICrowd {
  67031. /**
  67032. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67033. * You can attach anything to that node. The node position is updated in the scene update tick.
  67034. * @param pos world position that will be constrained by the navigation mesh
  67035. * @param parameters agent parameters
  67036. * @param transform hooked to the agent that will be update by the scene
  67037. * @returns agent index
  67038. */
  67039. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67040. /**
  67041. * Returns the agent position in world space
  67042. * @param index agent index returned by addAgent
  67043. * @returns world space position
  67044. */
  67045. getAgentPosition(index: number): Vector3;
  67046. /**
  67047. * Gets the agent position result in world space
  67048. * @param index agent index returned by addAgent
  67049. * @param result output world space position
  67050. */
  67051. getAgentPositionToRef(index: number, result: Vector3): void;
  67052. /**
  67053. * Gets the agent velocity in world space
  67054. * @param index agent index returned by addAgent
  67055. * @returns world space velocity
  67056. */
  67057. getAgentVelocity(index: number): Vector3;
  67058. /**
  67059. * Gets the agent velocity result in world space
  67060. * @param index agent index returned by addAgent
  67061. * @param result output world space velocity
  67062. */
  67063. getAgentVelocityToRef(index: number, result: Vector3): void;
  67064. /**
  67065. * remove a particular agent previously created
  67066. * @param index agent index returned by addAgent
  67067. */
  67068. removeAgent(index: number): void;
  67069. /**
  67070. * get the list of all agents attached to this crowd
  67071. * @returns list of agent indices
  67072. */
  67073. getAgents(): number[];
  67074. /**
  67075. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67076. * @param deltaTime in seconds
  67077. */
  67078. update(deltaTime: number): void;
  67079. /**
  67080. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67081. * @param index agent index returned by addAgent
  67082. * @param destination targeted world position
  67083. */
  67084. agentGoto(index: number, destination: Vector3): void;
  67085. /**
  67086. * Teleport the agent to a new position
  67087. * @param index agent index returned by addAgent
  67088. * @param destination targeted world position
  67089. */
  67090. agentTeleport(index: number, destination: Vector3): void;
  67091. /**
  67092. * Update agent parameters
  67093. * @param index agent index returned by addAgent
  67094. * @param parameters agent parameters
  67095. */
  67096. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67097. /**
  67098. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67099. * The queries will try to find a solution within those bounds
  67100. * default is (1,1,1)
  67101. * @param extent x,y,z value that define the extent around the queries point of reference
  67102. */
  67103. setDefaultQueryExtent(extent: Vector3): void;
  67104. /**
  67105. * Get the Bounding box extent specified by setDefaultQueryExtent
  67106. * @returns the box extent values
  67107. */
  67108. getDefaultQueryExtent(): Vector3;
  67109. /**
  67110. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67111. * @param result output the box extent values
  67112. */
  67113. getDefaultQueryExtentToRef(result: Vector3): void;
  67114. /**
  67115. * Release all resources
  67116. */
  67117. dispose(): void;
  67118. }
  67119. /**
  67120. * Configures an agent
  67121. */
  67122. export interface IAgentParameters {
  67123. /**
  67124. * Agent radius. [Limit: >= 0]
  67125. */
  67126. radius: number;
  67127. /**
  67128. * Agent height. [Limit: > 0]
  67129. */
  67130. height: number;
  67131. /**
  67132. * Maximum allowed acceleration. [Limit: >= 0]
  67133. */
  67134. maxAcceleration: number;
  67135. /**
  67136. * Maximum allowed speed. [Limit: >= 0]
  67137. */
  67138. maxSpeed: number;
  67139. /**
  67140. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  67141. */
  67142. collisionQueryRange: number;
  67143. /**
  67144. * The path visibility optimization range. [Limit: > 0]
  67145. */
  67146. pathOptimizationRange: number;
  67147. /**
  67148. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  67149. */
  67150. separationWeight: number;
  67151. }
  67152. /**
  67153. * Configures the navigation mesh creation
  67154. */
  67155. export interface INavMeshParameters {
  67156. /**
  67157. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  67158. */
  67159. cs: number;
  67160. /**
  67161. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  67162. */
  67163. ch: number;
  67164. /**
  67165. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  67166. */
  67167. walkableSlopeAngle: number;
  67168. /**
  67169. * Minimum floor to 'ceiling' height that will still allow the floor area to
  67170. * be considered walkable. [Limit: >= 3] [Units: vx]
  67171. */
  67172. walkableHeight: number;
  67173. /**
  67174. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  67175. */
  67176. walkableClimb: number;
  67177. /**
  67178. * The distance to erode/shrink the walkable area of the heightfield away from
  67179. * obstructions. [Limit: >=0] [Units: vx]
  67180. */
  67181. walkableRadius: number;
  67182. /**
  67183. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  67184. */
  67185. maxEdgeLen: number;
  67186. /**
  67187. * The maximum distance a simplfied contour's border edges should deviate
  67188. * the original raw contour. [Limit: >=0] [Units: vx]
  67189. */
  67190. maxSimplificationError: number;
  67191. /**
  67192. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  67193. */
  67194. minRegionArea: number;
  67195. /**
  67196. * Any regions with a span count smaller than this value will, if possible,
  67197. * be merged with larger regions. [Limit: >=0] [Units: vx]
  67198. */
  67199. mergeRegionArea: number;
  67200. /**
  67201. * The maximum number of vertices allowed for polygons generated during the
  67202. * contour to polygon conversion process. [Limit: >= 3]
  67203. */
  67204. maxVertsPerPoly: number;
  67205. /**
  67206. * Sets the sampling distance to use when generating the detail mesh.
  67207. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  67208. */
  67209. detailSampleDist: number;
  67210. /**
  67211. * The maximum distance the detail mesh surface should deviate from heightfield
  67212. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  67213. */
  67214. detailSampleMaxError: number;
  67215. }
  67216. }
  67217. declare module BABYLON {
  67218. /**
  67219. * RecastJS navigation plugin
  67220. */
  67221. export class RecastJSPlugin implements INavigationEnginePlugin {
  67222. /**
  67223. * Reference to the Recast library
  67224. */
  67225. bjsRECAST: any;
  67226. /**
  67227. * plugin name
  67228. */
  67229. name: string;
  67230. /**
  67231. * the first navmesh created. We might extend this to support multiple navmeshes
  67232. */
  67233. navMesh: any;
  67234. /**
  67235. * Initializes the recastJS plugin
  67236. * @param recastInjection can be used to inject your own recast reference
  67237. */
  67238. constructor(recastInjection?: any);
  67239. /**
  67240. * Creates a navigation mesh
  67241. * @param meshes array of all the geometry used to compute the navigatio mesh
  67242. * @param parameters bunch of parameters used to filter geometry
  67243. */
  67244. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67245. /**
  67246. * Create a navigation mesh debug mesh
  67247. * @param scene is where the mesh will be added
  67248. * @returns debug display mesh
  67249. */
  67250. createDebugNavMesh(scene: Scene): Mesh;
  67251. /**
  67252. * Get a navigation mesh constrained position, closest to the parameter position
  67253. * @param position world position
  67254. * @returns the closest point to position constrained by the navigation mesh
  67255. */
  67256. getClosestPoint(position: Vector3): Vector3;
  67257. /**
  67258. * Get a navigation mesh constrained position, closest to the parameter position
  67259. * @param position world position
  67260. * @param result output the closest point to position constrained by the navigation mesh
  67261. */
  67262. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67263. /**
  67264. * Get a navigation mesh constrained position, within a particular radius
  67265. * @param position world position
  67266. * @param maxRadius the maximum distance to the constrained world position
  67267. * @returns the closest point to position constrained by the navigation mesh
  67268. */
  67269. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67270. /**
  67271. * Get a navigation mesh constrained position, within a particular radius
  67272. * @param position world position
  67273. * @param maxRadius the maximum distance to the constrained world position
  67274. * @param result output the closest point to position constrained by the navigation mesh
  67275. */
  67276. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67277. /**
  67278. * Compute the final position from a segment made of destination-position
  67279. * @param position world position
  67280. * @param destination world position
  67281. * @returns the resulting point along the navmesh
  67282. */
  67283. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67284. /**
  67285. * Compute the final position from a segment made of destination-position
  67286. * @param position world position
  67287. * @param destination world position
  67288. * @param result output the resulting point along the navmesh
  67289. */
  67290. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67291. /**
  67292. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67293. * @param start world position
  67294. * @param end world position
  67295. * @returns array containing world position composing the path
  67296. */
  67297. computePath(start: Vector3, end: Vector3): Vector3[];
  67298. /**
  67299. * Create a new Crowd so you can add agents
  67300. * @param maxAgents the maximum agent count in the crowd
  67301. * @param maxAgentRadius the maximum radius an agent can have
  67302. * @param scene to attach the crowd to
  67303. * @returns the crowd you can add agents to
  67304. */
  67305. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67306. /**
  67307. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67308. * The queries will try to find a solution within those bounds
  67309. * default is (1,1,1)
  67310. * @param extent x,y,z value that define the extent around the queries point of reference
  67311. */
  67312. setDefaultQueryExtent(extent: Vector3): void;
  67313. /**
  67314. * Get the Bounding box extent specified by setDefaultQueryExtent
  67315. * @returns the box extent values
  67316. */
  67317. getDefaultQueryExtent(): Vector3;
  67318. /**
  67319. * build the navmesh from a previously saved state using getNavmeshData
  67320. * @param data the Uint8Array returned by getNavmeshData
  67321. */
  67322. buildFromNavmeshData(data: Uint8Array): void;
  67323. /**
  67324. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67325. * @returns data the Uint8Array that can be saved and reused
  67326. */
  67327. getNavmeshData(): Uint8Array;
  67328. /**
  67329. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67330. * @param result output the box extent values
  67331. */
  67332. getDefaultQueryExtentToRef(result: Vector3): void;
  67333. /**
  67334. * Disposes
  67335. */
  67336. dispose(): void;
  67337. /**
  67338. * If this plugin is supported
  67339. * @returns true if plugin is supported
  67340. */
  67341. isSupported(): boolean;
  67342. }
  67343. /**
  67344. * Recast detour crowd implementation
  67345. */
  67346. export class RecastJSCrowd implements ICrowd {
  67347. /**
  67348. * Recast/detour plugin
  67349. */
  67350. bjsRECASTPlugin: RecastJSPlugin;
  67351. /**
  67352. * Link to the detour crowd
  67353. */
  67354. recastCrowd: any;
  67355. /**
  67356. * One transform per agent
  67357. */
  67358. transforms: TransformNode[];
  67359. /**
  67360. * All agents created
  67361. */
  67362. agents: number[];
  67363. /**
  67364. * Link to the scene is kept to unregister the crowd from the scene
  67365. */
  67366. private _scene;
  67367. /**
  67368. * Observer for crowd updates
  67369. */
  67370. private _onBeforeAnimationsObserver;
  67371. /**
  67372. * Constructor
  67373. * @param plugin recastJS plugin
  67374. * @param maxAgents the maximum agent count in the crowd
  67375. * @param maxAgentRadius the maximum radius an agent can have
  67376. * @param scene to attach the crowd to
  67377. * @returns the crowd you can add agents to
  67378. */
  67379. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67380. /**
  67381. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67382. * You can attach anything to that node. The node position is updated in the scene update tick.
  67383. * @param pos world position that will be constrained by the navigation mesh
  67384. * @param parameters agent parameters
  67385. * @param transform hooked to the agent that will be update by the scene
  67386. * @returns agent index
  67387. */
  67388. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67389. /**
  67390. * Returns the agent position in world space
  67391. * @param index agent index returned by addAgent
  67392. * @returns world space position
  67393. */
  67394. getAgentPosition(index: number): Vector3;
  67395. /**
  67396. * Returns the agent position result in world space
  67397. * @param index agent index returned by addAgent
  67398. * @param result output world space position
  67399. */
  67400. getAgentPositionToRef(index: number, result: Vector3): void;
  67401. /**
  67402. * Returns the agent velocity in world space
  67403. * @param index agent index returned by addAgent
  67404. * @returns world space velocity
  67405. */
  67406. getAgentVelocity(index: number): Vector3;
  67407. /**
  67408. * Returns the agent velocity result in world space
  67409. * @param index agent index returned by addAgent
  67410. * @param result output world space velocity
  67411. */
  67412. getAgentVelocityToRef(index: number, result: Vector3): void;
  67413. /**
  67414. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67415. * @param index agent index returned by addAgent
  67416. * @param destination targeted world position
  67417. */
  67418. agentGoto(index: number, destination: Vector3): void;
  67419. /**
  67420. * Teleport the agent to a new position
  67421. * @param index agent index returned by addAgent
  67422. * @param destination targeted world position
  67423. */
  67424. agentTeleport(index: number, destination: Vector3): void;
  67425. /**
  67426. * Update agent parameters
  67427. * @param index agent index returned by addAgent
  67428. * @param parameters agent parameters
  67429. */
  67430. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67431. /**
  67432. * remove a particular agent previously created
  67433. * @param index agent index returned by addAgent
  67434. */
  67435. removeAgent(index: number): void;
  67436. /**
  67437. * get the list of all agents attached to this crowd
  67438. * @returns list of agent indices
  67439. */
  67440. getAgents(): number[];
  67441. /**
  67442. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67443. * @param deltaTime in seconds
  67444. */
  67445. update(deltaTime: number): void;
  67446. /**
  67447. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67448. * The queries will try to find a solution within those bounds
  67449. * default is (1,1,1)
  67450. * @param extent x,y,z value that define the extent around the queries point of reference
  67451. */
  67452. setDefaultQueryExtent(extent: Vector3): void;
  67453. /**
  67454. * Get the Bounding box extent specified by setDefaultQueryExtent
  67455. * @returns the box extent values
  67456. */
  67457. getDefaultQueryExtent(): Vector3;
  67458. /**
  67459. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67460. * @param result output the box extent values
  67461. */
  67462. getDefaultQueryExtentToRef(result: Vector3): void;
  67463. /**
  67464. * Release all resources
  67465. */
  67466. dispose(): void;
  67467. }
  67468. }
  67469. declare module BABYLON {
  67470. /**
  67471. * Class used to enable access to IndexedDB
  67472. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67473. */
  67474. export class Database implements IOfflineProvider {
  67475. private _callbackManifestChecked;
  67476. private _currentSceneUrl;
  67477. private _db;
  67478. private _enableSceneOffline;
  67479. private _enableTexturesOffline;
  67480. private _manifestVersionFound;
  67481. private _mustUpdateRessources;
  67482. private _hasReachedQuota;
  67483. private _isSupported;
  67484. private _idbFactory;
  67485. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  67486. private static IsUASupportingBlobStorage;
  67487. /**
  67488. * Gets a boolean indicating if Database storate is enabled (off by default)
  67489. */
  67490. static IDBStorageEnabled: boolean;
  67491. /**
  67492. * Gets a boolean indicating if scene must be saved in the database
  67493. */
  67494. get enableSceneOffline(): boolean;
  67495. /**
  67496. * Gets a boolean indicating if textures must be saved in the database
  67497. */
  67498. get enableTexturesOffline(): boolean;
  67499. /**
  67500. * Creates a new Database
  67501. * @param urlToScene defines the url to load the scene
  67502. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67503. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67504. */
  67505. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67506. private static _ParseURL;
  67507. private static _ReturnFullUrlLocation;
  67508. private _checkManifestFile;
  67509. /**
  67510. * Open the database and make it available
  67511. * @param successCallback defines the callback to call on success
  67512. * @param errorCallback defines the callback to call on error
  67513. */
  67514. open(successCallback: () => void, errorCallback: () => void): void;
  67515. /**
  67516. * Loads an image from the database
  67517. * @param url defines the url to load from
  67518. * @param image defines the target DOM image
  67519. */
  67520. loadImage(url: string, image: HTMLImageElement): void;
  67521. private _loadImageFromDBAsync;
  67522. private _saveImageIntoDBAsync;
  67523. private _checkVersionFromDB;
  67524. private _loadVersionFromDBAsync;
  67525. private _saveVersionIntoDBAsync;
  67526. /**
  67527. * Loads a file from database
  67528. * @param url defines the URL to load from
  67529. * @param sceneLoaded defines a callback to call on success
  67530. * @param progressCallBack defines a callback to call when progress changed
  67531. * @param errorCallback defines a callback to call on error
  67532. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67533. */
  67534. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67535. private _loadFileAsync;
  67536. private _saveFileAsync;
  67537. /**
  67538. * Validates if xhr data is correct
  67539. * @param xhr defines the request to validate
  67540. * @param dataType defines the expected data type
  67541. * @returns true if data is correct
  67542. */
  67543. private static _ValidateXHRData;
  67544. }
  67545. }
  67546. declare module BABYLON {
  67547. /** @hidden */
  67548. export var gpuUpdateParticlesPixelShader: {
  67549. name: string;
  67550. shader: string;
  67551. };
  67552. }
  67553. declare module BABYLON {
  67554. /** @hidden */
  67555. export var gpuUpdateParticlesVertexShader: {
  67556. name: string;
  67557. shader: string;
  67558. };
  67559. }
  67560. declare module BABYLON {
  67561. /** @hidden */
  67562. export var clipPlaneFragmentDeclaration2: {
  67563. name: string;
  67564. shader: string;
  67565. };
  67566. }
  67567. declare module BABYLON {
  67568. /** @hidden */
  67569. export var gpuRenderParticlesPixelShader: {
  67570. name: string;
  67571. shader: string;
  67572. };
  67573. }
  67574. declare module BABYLON {
  67575. /** @hidden */
  67576. export var clipPlaneVertexDeclaration2: {
  67577. name: string;
  67578. shader: string;
  67579. };
  67580. }
  67581. declare module BABYLON {
  67582. /** @hidden */
  67583. export var gpuRenderParticlesVertexShader: {
  67584. name: string;
  67585. shader: string;
  67586. };
  67587. }
  67588. declare module BABYLON {
  67589. /**
  67590. * This represents a GPU particle system in Babylon
  67591. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  67592. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  67593. */
  67594. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  67595. /**
  67596. * The layer mask we are rendering the particles through.
  67597. */
  67598. layerMask: number;
  67599. private _capacity;
  67600. private _activeCount;
  67601. private _currentActiveCount;
  67602. private _accumulatedCount;
  67603. private _renderEffect;
  67604. private _updateEffect;
  67605. private _buffer0;
  67606. private _buffer1;
  67607. private _spriteBuffer;
  67608. private _updateVAO;
  67609. private _renderVAO;
  67610. private _targetIndex;
  67611. private _sourceBuffer;
  67612. private _targetBuffer;
  67613. private _currentRenderId;
  67614. private _started;
  67615. private _stopped;
  67616. private _timeDelta;
  67617. private _randomTexture;
  67618. private _randomTexture2;
  67619. private _attributesStrideSize;
  67620. private _updateEffectOptions;
  67621. private _randomTextureSize;
  67622. private _actualFrame;
  67623. private _customEffect;
  67624. private readonly _rawTextureWidth;
  67625. /**
  67626. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  67627. */
  67628. static get IsSupported(): boolean;
  67629. /**
  67630. * An event triggered when the system is disposed.
  67631. */
  67632. onDisposeObservable: Observable<IParticleSystem>;
  67633. /**
  67634. * Gets the maximum number of particles active at the same time.
  67635. * @returns The max number of active particles.
  67636. */
  67637. getCapacity(): number;
  67638. /**
  67639. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  67640. * to override the particles.
  67641. */
  67642. forceDepthWrite: boolean;
  67643. /**
  67644. * Gets or set the number of active particles
  67645. */
  67646. get activeParticleCount(): number;
  67647. set activeParticleCount(value: number);
  67648. private _preWarmDone;
  67649. /**
  67650. * Specifies if the particles are updated in emitter local space or world space.
  67651. */
  67652. isLocal: boolean;
  67653. /** Gets or sets a matrix to use to compute projection */
  67654. defaultProjectionMatrix: Matrix;
  67655. /**
  67656. * Is this system ready to be used/rendered
  67657. * @return true if the system is ready
  67658. */
  67659. isReady(): boolean;
  67660. /**
  67661. * Gets if the system has been started. (Note: this will still be true after stop is called)
  67662. * @returns True if it has been started, otherwise false.
  67663. */
  67664. isStarted(): boolean;
  67665. /**
  67666. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  67667. * @returns True if it has been stopped, otherwise false.
  67668. */
  67669. isStopped(): boolean;
  67670. /**
  67671. * Gets a boolean indicating that the system is stopping
  67672. * @returns true if the system is currently stopping
  67673. */
  67674. isStopping(): boolean;
  67675. /**
  67676. * Gets the number of particles active at the same time.
  67677. * @returns The number of active particles.
  67678. */
  67679. getActiveCount(): number;
  67680. /**
  67681. * Starts the particle system and begins to emit
  67682. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  67683. */
  67684. start(delay?: number): void;
  67685. /**
  67686. * Stops the particle system.
  67687. */
  67688. stop(): void;
  67689. /**
  67690. * Remove all active particles
  67691. */
  67692. reset(): void;
  67693. /**
  67694. * Returns the string "GPUParticleSystem"
  67695. * @returns a string containing the class name
  67696. */
  67697. getClassName(): string;
  67698. /**
  67699. * Gets the custom effect used to render the particles
  67700. * @param blendMode Blend mode for which the effect should be retrieved
  67701. * @returns The effect
  67702. */
  67703. getCustomEffect(blendMode?: number): Nullable<Effect>;
  67704. /**
  67705. * Sets the custom effect used to render the particles
  67706. * @param effect The effect to set
  67707. * @param blendMode Blend mode for which the effect should be set
  67708. */
  67709. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  67710. /** @hidden */
  67711. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  67712. /**
  67713. * Observable that will be called just before the particles are drawn
  67714. */
  67715. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  67716. /**
  67717. * Gets the name of the particle vertex shader
  67718. */
  67719. get vertexShaderName(): string;
  67720. private _colorGradientsTexture;
  67721. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  67722. /**
  67723. * Adds a new color gradient
  67724. * @param gradient defines the gradient to use (between 0 and 1)
  67725. * @param color1 defines the color to affect to the specified gradient
  67726. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  67727. * @returns the current particle system
  67728. */
  67729. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  67730. private _refreshColorGradient;
  67731. /** Force the system to rebuild all gradients that need to be resync */
  67732. forceRefreshGradients(): void;
  67733. /**
  67734. * Remove a specific color gradient
  67735. * @param gradient defines the gradient to remove
  67736. * @returns the current particle system
  67737. */
  67738. removeColorGradient(gradient: number): GPUParticleSystem;
  67739. private _angularSpeedGradientsTexture;
  67740. private _sizeGradientsTexture;
  67741. private _velocityGradientsTexture;
  67742. private _limitVelocityGradientsTexture;
  67743. private _dragGradientsTexture;
  67744. private _addFactorGradient;
  67745. /**
  67746. * Adds a new size gradient
  67747. * @param gradient defines the gradient to use (between 0 and 1)
  67748. * @param factor defines the size factor to affect to the specified gradient
  67749. * @returns the current particle system
  67750. */
  67751. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  67752. /**
  67753. * Remove a specific size gradient
  67754. * @param gradient defines the gradient to remove
  67755. * @returns the current particle system
  67756. */
  67757. removeSizeGradient(gradient: number): GPUParticleSystem;
  67758. private _refreshFactorGradient;
  67759. /**
  67760. * Adds a new angular speed gradient
  67761. * @param gradient defines the gradient to use (between 0 and 1)
  67762. * @param factor defines the angular speed to affect to the specified gradient
  67763. * @returns the current particle system
  67764. */
  67765. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  67766. /**
  67767. * Remove a specific angular speed gradient
  67768. * @param gradient defines the gradient to remove
  67769. * @returns the current particle system
  67770. */
  67771. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  67772. /**
  67773. * Adds a new velocity gradient
  67774. * @param gradient defines the gradient to use (between 0 and 1)
  67775. * @param factor defines the velocity to affect to the specified gradient
  67776. * @returns the current particle system
  67777. */
  67778. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67779. /**
  67780. * Remove a specific velocity gradient
  67781. * @param gradient defines the gradient to remove
  67782. * @returns the current particle system
  67783. */
  67784. removeVelocityGradient(gradient: number): GPUParticleSystem;
  67785. /**
  67786. * Adds a new limit velocity gradient
  67787. * @param gradient defines the gradient to use (between 0 and 1)
  67788. * @param factor defines the limit velocity value to affect to the specified gradient
  67789. * @returns the current particle system
  67790. */
  67791. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67792. /**
  67793. * Remove a specific limit velocity gradient
  67794. * @param gradient defines the gradient to remove
  67795. * @returns the current particle system
  67796. */
  67797. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  67798. /**
  67799. * Adds a new drag gradient
  67800. * @param gradient defines the gradient to use (between 0 and 1)
  67801. * @param factor defines the drag value to affect to the specified gradient
  67802. * @returns the current particle system
  67803. */
  67804. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  67805. /**
  67806. * Remove a specific drag gradient
  67807. * @param gradient defines the gradient to remove
  67808. * @returns the current particle system
  67809. */
  67810. removeDragGradient(gradient: number): GPUParticleSystem;
  67811. /**
  67812. * Not supported by GPUParticleSystem
  67813. * @param gradient defines the gradient to use (between 0 and 1)
  67814. * @param factor defines the emit rate value to affect to the specified gradient
  67815. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67816. * @returns the current particle system
  67817. */
  67818. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67819. /**
  67820. * Not supported by GPUParticleSystem
  67821. * @param gradient defines the gradient to remove
  67822. * @returns the current particle system
  67823. */
  67824. removeEmitRateGradient(gradient: number): IParticleSystem;
  67825. /**
  67826. * Not supported by GPUParticleSystem
  67827. * @param gradient defines the gradient to use (between 0 and 1)
  67828. * @param factor defines the start size value to affect to the specified gradient
  67829. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67830. * @returns the current particle system
  67831. */
  67832. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67833. /**
  67834. * Not supported by GPUParticleSystem
  67835. * @param gradient defines the gradient to remove
  67836. * @returns the current particle system
  67837. */
  67838. removeStartSizeGradient(gradient: number): IParticleSystem;
  67839. /**
  67840. * Not supported by GPUParticleSystem
  67841. * @param gradient defines the gradient to use (between 0 and 1)
  67842. * @param min defines the color remap minimal range
  67843. * @param max defines the color remap maximal range
  67844. * @returns the current particle system
  67845. */
  67846. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67847. /**
  67848. * Not supported by GPUParticleSystem
  67849. * @param gradient defines the gradient to remove
  67850. * @returns the current particle system
  67851. */
  67852. removeColorRemapGradient(): IParticleSystem;
  67853. /**
  67854. * Not supported by GPUParticleSystem
  67855. * @param gradient defines the gradient to use (between 0 and 1)
  67856. * @param min defines the alpha remap minimal range
  67857. * @param max defines the alpha remap maximal range
  67858. * @returns the current particle system
  67859. */
  67860. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67861. /**
  67862. * Not supported by GPUParticleSystem
  67863. * @param gradient defines the gradient to remove
  67864. * @returns the current particle system
  67865. */
  67866. removeAlphaRemapGradient(): IParticleSystem;
  67867. /**
  67868. * Not supported by GPUParticleSystem
  67869. * @param gradient defines the gradient to use (between 0 and 1)
  67870. * @param color defines the color to affect to the specified gradient
  67871. * @returns the current particle system
  67872. */
  67873. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  67874. /**
  67875. * Not supported by GPUParticleSystem
  67876. * @param gradient defines the gradient to remove
  67877. * @returns the current particle system
  67878. */
  67879. removeRampGradient(): IParticleSystem;
  67880. /**
  67881. * Not supported by GPUParticleSystem
  67882. * @returns the list of ramp gradients
  67883. */
  67884. getRampGradients(): Nullable<Array<Color3Gradient>>;
  67885. /**
  67886. * Not supported by GPUParticleSystem
  67887. * Gets or sets a boolean indicating that ramp gradients must be used
  67888. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  67889. */
  67890. get useRampGradients(): boolean;
  67891. set useRampGradients(value: boolean);
  67892. /**
  67893. * Not supported by GPUParticleSystem
  67894. * @param gradient defines the gradient to use (between 0 and 1)
  67895. * @param factor defines the life time factor to affect to the specified gradient
  67896. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67897. * @returns the current particle system
  67898. */
  67899. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67900. /**
  67901. * Not supported by GPUParticleSystem
  67902. * @param gradient defines the gradient to remove
  67903. * @returns the current particle system
  67904. */
  67905. removeLifeTimeGradient(gradient: number): IParticleSystem;
  67906. /**
  67907. * Instantiates a GPU particle system.
  67908. * 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.
  67909. * @param name The name of the particle system
  67910. * @param options The options used to create the system
  67911. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  67912. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  67913. * @param customEffect a custom effect used to change the way particles are rendered by default
  67914. */
  67915. constructor(name: string, options: Partial<{
  67916. capacity: number;
  67917. randomTextureSize: number;
  67918. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  67919. protected _reset(): void;
  67920. private _createUpdateVAO;
  67921. private _createRenderVAO;
  67922. private _initialize;
  67923. /** @hidden */
  67924. _recreateUpdateEffect(): void;
  67925. private _getEffect;
  67926. /**
  67927. * Fill the defines array according to the current settings of the particle system
  67928. * @param defines Array to be updated
  67929. * @param blendMode blend mode to take into account when updating the array
  67930. */
  67931. fillDefines(defines: Array<string>, blendMode?: number): void;
  67932. /**
  67933. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  67934. * @param uniforms Uniforms array to fill
  67935. * @param attributes Attributes array to fill
  67936. * @param samplers Samplers array to fill
  67937. */
  67938. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  67939. /** @hidden */
  67940. _recreateRenderEffect(): Effect;
  67941. /**
  67942. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  67943. * @param preWarm defines if we are in the pre-warmimg phase
  67944. */
  67945. animate(preWarm?: boolean): void;
  67946. private _createFactorGradientTexture;
  67947. private _createSizeGradientTexture;
  67948. private _createAngularSpeedGradientTexture;
  67949. private _createVelocityGradientTexture;
  67950. private _createLimitVelocityGradientTexture;
  67951. private _createDragGradientTexture;
  67952. private _createColorGradientTexture;
  67953. /**
  67954. * Renders the particle system in its current state
  67955. * @param preWarm defines if the system should only update the particles but not render them
  67956. * @returns the current number of particles
  67957. */
  67958. render(preWarm?: boolean): number;
  67959. /**
  67960. * Rebuilds the particle system
  67961. */
  67962. rebuild(): void;
  67963. private _releaseBuffers;
  67964. private _releaseVAOs;
  67965. /**
  67966. * Disposes the particle system and free the associated resources
  67967. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  67968. */
  67969. dispose(disposeTexture?: boolean): void;
  67970. /**
  67971. * Clones the particle system.
  67972. * @param name The name of the cloned object
  67973. * @param newEmitter The new emitter to use
  67974. * @returns the cloned particle system
  67975. */
  67976. clone(name: string, newEmitter: any): GPUParticleSystem;
  67977. /**
  67978. * Serializes the particle system to a JSON object
  67979. * @param serializeTexture defines if the texture must be serialized as well
  67980. * @returns the JSON object
  67981. */
  67982. serialize(serializeTexture?: boolean): any;
  67983. /**
  67984. * Parses a JSON object to create a GPU particle system.
  67985. * @param parsedParticleSystem The JSON object to parse
  67986. * @param sceneOrEngine The scene or the engine to create the particle system in
  67987. * @param rootUrl The root url to use to load external dependencies like texture
  67988. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  67989. * @returns the parsed GPU particle system
  67990. */
  67991. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  67992. }
  67993. }
  67994. declare module BABYLON {
  67995. /**
  67996. * Represents a set of particle systems working together to create a specific effect
  67997. */
  67998. export class ParticleSystemSet implements IDisposable {
  67999. /**
  68000. * Gets or sets base Assets URL
  68001. */
  68002. static BaseAssetsUrl: string;
  68003. private _emitterCreationOptions;
  68004. private _emitterNode;
  68005. /**
  68006. * Gets the particle system list
  68007. */
  68008. systems: IParticleSystem[];
  68009. /**
  68010. * Gets the emitter node used with this set
  68011. */
  68012. get emitterNode(): Nullable<TransformNode>;
  68013. /**
  68014. * Creates a new emitter mesh as a sphere
  68015. * @param options defines the options used to create the sphere
  68016. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  68017. * @param scene defines the hosting scene
  68018. */
  68019. setEmitterAsSphere(options: {
  68020. diameter: number;
  68021. segments: number;
  68022. color: Color3;
  68023. }, renderingGroupId: number, scene: Scene): void;
  68024. /**
  68025. * Starts all particle systems of the set
  68026. * @param emitter defines an optional mesh to use as emitter for the particle systems
  68027. */
  68028. start(emitter?: AbstractMesh): void;
  68029. /**
  68030. * Release all associated resources
  68031. */
  68032. dispose(): void;
  68033. /**
  68034. * Serialize the set into a JSON compatible object
  68035. * @param serializeTexture defines if the texture must be serialized as well
  68036. * @returns a JSON compatible representation of the set
  68037. */
  68038. serialize(serializeTexture?: boolean): any;
  68039. /**
  68040. * Parse a new ParticleSystemSet from a serialized source
  68041. * @param data defines a JSON compatible representation of the set
  68042. * @param scene defines the hosting scene
  68043. * @param gpu defines if we want GPU particles or CPU particles
  68044. * @returns a new ParticleSystemSet
  68045. */
  68046. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  68047. }
  68048. }
  68049. declare module BABYLON {
  68050. /**
  68051. * This class is made for on one-liner static method to help creating particle system set.
  68052. */
  68053. export class ParticleHelper {
  68054. /**
  68055. * Gets or sets base Assets URL
  68056. */
  68057. static BaseAssetsUrl: string;
  68058. /** Define the Url to load snippets */
  68059. static SnippetUrl: string;
  68060. /**
  68061. * Create a default particle system that you can tweak
  68062. * @param emitter defines the emitter to use
  68063. * @param capacity defines the system capacity (default is 500 particles)
  68064. * @param scene defines the hosting scene
  68065. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  68066. * @returns the new Particle system
  68067. */
  68068. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  68069. /**
  68070. * This is the main static method (one-liner) of this helper to create different particle systems
  68071. * @param type This string represents the type to the particle system to create
  68072. * @param scene The scene where the particle system should live
  68073. * @param gpu If the system will use gpu
  68074. * @returns the ParticleSystemSet created
  68075. */
  68076. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  68077. /**
  68078. * Static function used to export a particle system to a ParticleSystemSet variable.
  68079. * Please note that the emitter shape is not exported
  68080. * @param systems defines the particle systems to export
  68081. * @returns the created particle system set
  68082. */
  68083. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  68084. /**
  68085. * Creates a particle system from a snippet saved in a remote file
  68086. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  68087. * @param url defines the url to load from
  68088. * @param scene defines the hosting scene
  68089. * @param gpu If the system will use gpu
  68090. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68091. * @returns a promise that will resolve to the new particle system
  68092. */
  68093. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68094. /**
  68095. * Creates a particle system from a snippet saved by the particle system editor
  68096. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  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 CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68103. }
  68104. }
  68105. declare module BABYLON {
  68106. interface Engine {
  68107. /**
  68108. * Create an effect to use with particle systems.
  68109. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  68110. * the particle system for which you want to create a custom effect in the last parameter
  68111. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  68112. * @param uniformsNames defines a list of attribute names
  68113. * @param samplers defines an array of string used to represent textures
  68114. * @param defines defines the string containing the defines to use to compile the shaders
  68115. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  68116. * @param onCompiled defines a function to call when the effect creation is successful
  68117. * @param onError defines a function to call when the effect creation has failed
  68118. * @param particleSystem the particle system you want to create the effect for
  68119. * @returns the new Effect
  68120. */
  68121. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  68122. }
  68123. interface Mesh {
  68124. /**
  68125. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  68126. * @returns an array of IParticleSystem
  68127. */
  68128. getEmittedParticleSystems(): IParticleSystem[];
  68129. /**
  68130. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  68131. * @returns an array of IParticleSystem
  68132. */
  68133. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  68134. }
  68135. }
  68136. declare module BABYLON {
  68137. /** Defines the 4 color options */
  68138. export enum PointColor {
  68139. /** color value */
  68140. Color = 2,
  68141. /** uv value */
  68142. UV = 1,
  68143. /** random value */
  68144. Random = 0,
  68145. /** stated value */
  68146. Stated = 3
  68147. }
  68148. /**
  68149. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  68150. * 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.
  68151. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  68152. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  68153. *
  68154. * Full documentation here : TO BE ENTERED
  68155. */
  68156. export class PointsCloudSystem implements IDisposable {
  68157. /**
  68158. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  68159. * Example : var p = SPS.particles[i];
  68160. */
  68161. particles: CloudPoint[];
  68162. /**
  68163. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  68164. */
  68165. nbParticles: number;
  68166. /**
  68167. * This a counter for your own usage. It's not set by any SPS functions.
  68168. */
  68169. counter: number;
  68170. /**
  68171. * The PCS name. This name is also given to the underlying mesh.
  68172. */
  68173. name: string;
  68174. /**
  68175. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  68176. */
  68177. mesh: Mesh;
  68178. /**
  68179. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  68180. * Please read :
  68181. */
  68182. vars: any;
  68183. /**
  68184. * @hidden
  68185. */
  68186. _size: number;
  68187. private _scene;
  68188. private _promises;
  68189. private _positions;
  68190. private _indices;
  68191. private _normals;
  68192. private _colors;
  68193. private _uvs;
  68194. private _indices32;
  68195. private _positions32;
  68196. private _colors32;
  68197. private _uvs32;
  68198. private _updatable;
  68199. private _isVisibilityBoxLocked;
  68200. private _alwaysVisible;
  68201. private _groups;
  68202. private _groupCounter;
  68203. private _computeParticleColor;
  68204. private _computeParticleTexture;
  68205. private _computeParticleRotation;
  68206. private _computeBoundingBox;
  68207. private _isReady;
  68208. /**
  68209. * Creates a PCS (Points Cloud System) object
  68210. * @param name (String) is the PCS name, this will be the underlying mesh name
  68211. * @param pointSize (number) is the size for each point
  68212. * @param scene (Scene) is the scene in which the PCS is added
  68213. * @param options defines the options of the PCS e.g.
  68214. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  68215. */
  68216. constructor(name: string, pointSize: number, scene: Scene, options?: {
  68217. updatable?: boolean;
  68218. });
  68219. /**
  68220. * Builds the PCS underlying mesh. Returns a standard Mesh.
  68221. * If no points were added to the PCS, the returned mesh is just a single point.
  68222. * @returns a promise for the created mesh
  68223. */
  68224. buildMeshAsync(): Promise<Mesh>;
  68225. /**
  68226. * @hidden
  68227. */
  68228. private _buildMesh;
  68229. private _addParticle;
  68230. private _randomUnitVector;
  68231. private _getColorIndicesForCoord;
  68232. private _setPointsColorOrUV;
  68233. private _colorFromTexture;
  68234. private _calculateDensity;
  68235. /**
  68236. * Adds points to the PCS in random positions within a unit sphere
  68237. * @param nb (positive integer) the number of particles to be created from this model
  68238. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  68239. * @returns the number of groups in the system
  68240. */
  68241. addPoints(nb: number, pointFunction?: any): number;
  68242. /**
  68243. * Adds points to the PCS from the surface of the model shape
  68244. * @param mesh is any Mesh object that will be used as a surface model for the points
  68245. * @param nb (positive integer) the number of particles to be created from this model
  68246. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68247. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68248. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68249. * @returns the number of groups in the system
  68250. */
  68251. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68252. /**
  68253. * Adds points to the PCS inside the model shape
  68254. * @param mesh is any Mesh object that will be used as a surface model for the points
  68255. * @param nb (positive integer) the number of particles to be created from this model
  68256. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68257. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68258. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68259. * @returns the number of groups in the system
  68260. */
  68261. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68262. /**
  68263. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  68264. * This method calls `updateParticle()` for each particle of the SPS.
  68265. * For an animated SPS, it is usually called within the render loop.
  68266. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  68267. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  68268. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  68269. * @returns the PCS.
  68270. */
  68271. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  68272. /**
  68273. * Disposes the PCS.
  68274. */
  68275. dispose(): void;
  68276. /**
  68277. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68278. * doc :
  68279. * @returns the PCS.
  68280. */
  68281. refreshVisibleSize(): PointsCloudSystem;
  68282. /**
  68283. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68284. * @param size the size (float) of the visibility box
  68285. * note : this doesn't lock the PCS mesh bounding box.
  68286. * doc :
  68287. */
  68288. setVisibilityBox(size: number): void;
  68289. /**
  68290. * Gets whether the PCS is always visible or not
  68291. * doc :
  68292. */
  68293. get isAlwaysVisible(): boolean;
  68294. /**
  68295. * Sets the PCS as always visible or not
  68296. * doc :
  68297. */
  68298. set isAlwaysVisible(val: boolean);
  68299. /**
  68300. * Tells to `setParticles()` to compute the particle rotations or not
  68301. * Default value : false. The PCS is faster when it's set to false
  68302. * Note : particle rotations are only applied to parent particles
  68303. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68304. */
  68305. set computeParticleRotation(val: boolean);
  68306. /**
  68307. * Tells to `setParticles()` to compute the particle colors or not.
  68308. * Default value : true. The PCS is faster when it's set to false.
  68309. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68310. */
  68311. set computeParticleColor(val: boolean);
  68312. set computeParticleTexture(val: boolean);
  68313. /**
  68314. * Gets if `setParticles()` computes the particle colors or not.
  68315. * Default value : false. The PCS is faster when it's set to false.
  68316. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68317. */
  68318. get computeParticleColor(): boolean;
  68319. /**
  68320. * Gets if `setParticles()` computes the particle textures or not.
  68321. * Default value : false. The PCS is faster when it's set to false.
  68322. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68323. */
  68324. get computeParticleTexture(): boolean;
  68325. /**
  68326. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68327. */
  68328. set computeBoundingBox(val: boolean);
  68329. /**
  68330. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68331. */
  68332. get computeBoundingBox(): boolean;
  68333. /**
  68334. * This function does nothing. It may be overwritten to set all the particle first values.
  68335. * The PCS doesn't call this function, you may have to call it by your own.
  68336. * doc :
  68337. */
  68338. initParticles(): void;
  68339. /**
  68340. * This function does nothing. It may be overwritten to recycle a particle
  68341. * The PCS doesn't call this function, you can to call it
  68342. * doc :
  68343. * @param particle The particle to recycle
  68344. * @returns the recycled particle
  68345. */
  68346. recycleParticle(particle: CloudPoint): CloudPoint;
  68347. /**
  68348. * Updates a particle : this function should be overwritten by the user.
  68349. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68350. * doc :
  68351. * @example : just set a particle position or velocity and recycle conditions
  68352. * @param particle The particle to update
  68353. * @returns the updated particle
  68354. */
  68355. updateParticle(particle: CloudPoint): CloudPoint;
  68356. /**
  68357. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68358. * This does nothing and may be overwritten by the user.
  68359. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68360. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68361. * @param update the boolean update value actually passed to setParticles()
  68362. */
  68363. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68364. /**
  68365. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68366. * This 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. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68373. }
  68374. }
  68375. declare module BABYLON {
  68376. /**
  68377. * Represents one particle of a points cloud system.
  68378. */
  68379. export class CloudPoint {
  68380. /**
  68381. * particle global index
  68382. */
  68383. idx: number;
  68384. /**
  68385. * The color of the particle
  68386. */
  68387. color: Nullable<Color4>;
  68388. /**
  68389. * The world space position of the particle.
  68390. */
  68391. position: Vector3;
  68392. /**
  68393. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68394. */
  68395. rotation: Vector3;
  68396. /**
  68397. * The world space rotation quaternion of the particle.
  68398. */
  68399. rotationQuaternion: Nullable<Quaternion>;
  68400. /**
  68401. * The uv of the particle.
  68402. */
  68403. uv: Nullable<Vector2>;
  68404. /**
  68405. * The current speed of the particle.
  68406. */
  68407. velocity: Vector3;
  68408. /**
  68409. * The pivot point in the particle local space.
  68410. */
  68411. pivot: Vector3;
  68412. /**
  68413. * Must the particle be translated from its pivot point in its local space ?
  68414. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68415. * Default : false
  68416. */
  68417. translateFromPivot: boolean;
  68418. /**
  68419. * Index of this particle in the global "positions" array (Internal use)
  68420. * @hidden
  68421. */
  68422. _pos: number;
  68423. /**
  68424. * @hidden Index of this particle in the global "indices" array (Internal use)
  68425. */
  68426. _ind: number;
  68427. /**
  68428. * Group this particle belongs to
  68429. */
  68430. _group: PointsGroup;
  68431. /**
  68432. * Group id of this particle
  68433. */
  68434. groupId: number;
  68435. /**
  68436. * Index of the particle in its group id (Internal use)
  68437. */
  68438. idxInGroup: number;
  68439. /**
  68440. * @hidden Particle BoundingInfo object (Internal use)
  68441. */
  68442. _boundingInfo: BoundingInfo;
  68443. /**
  68444. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68445. */
  68446. _pcs: PointsCloudSystem;
  68447. /**
  68448. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68449. */
  68450. _stillInvisible: boolean;
  68451. /**
  68452. * @hidden Last computed particle rotation matrix
  68453. */
  68454. _rotationMatrix: number[];
  68455. /**
  68456. * Parent particle Id, if any.
  68457. * Default null.
  68458. */
  68459. parentId: Nullable<number>;
  68460. /**
  68461. * @hidden Internal global position in the PCS.
  68462. */
  68463. _globalPosition: Vector3;
  68464. /**
  68465. * Creates a Point Cloud object.
  68466. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  68467. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  68468. * @param group (PointsGroup) is the group the particle belongs to
  68469. * @param groupId (integer) is the group identifier in the PCS.
  68470. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  68471. * @param pcs defines the PCS it is associated to
  68472. */
  68473. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  68474. /**
  68475. * get point size
  68476. */
  68477. get size(): Vector3;
  68478. /**
  68479. * Set point size
  68480. */
  68481. set size(scale: Vector3);
  68482. /**
  68483. * Legacy support, changed quaternion to rotationQuaternion
  68484. */
  68485. get quaternion(): Nullable<Quaternion>;
  68486. /**
  68487. * Legacy support, changed quaternion to rotationQuaternion
  68488. */
  68489. set quaternion(q: Nullable<Quaternion>);
  68490. /**
  68491. * Returns a boolean. True if the particle intersects a mesh, else false
  68492. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  68493. * @param target is the object (point or mesh) what the intersection is computed against
  68494. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  68495. * @returns true if it intersects
  68496. */
  68497. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  68498. /**
  68499. * get the rotation matrix of the particle
  68500. * @hidden
  68501. */
  68502. getRotationMatrix(m: Matrix): void;
  68503. }
  68504. /**
  68505. * Represents a group of points in a points cloud system
  68506. * * PCS internal tool, don't use it manually.
  68507. */
  68508. export class PointsGroup {
  68509. /**
  68510. * The group id
  68511. * @hidden
  68512. */
  68513. groupID: number;
  68514. /**
  68515. * image data for group (internal use)
  68516. * @hidden
  68517. */
  68518. _groupImageData: Nullable<ArrayBufferView>;
  68519. /**
  68520. * Image Width (internal use)
  68521. * @hidden
  68522. */
  68523. _groupImgWidth: number;
  68524. /**
  68525. * Image Height (internal use)
  68526. * @hidden
  68527. */
  68528. _groupImgHeight: number;
  68529. /**
  68530. * Custom position function (internal use)
  68531. * @hidden
  68532. */
  68533. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  68534. /**
  68535. * density per facet for surface points
  68536. * @hidden
  68537. */
  68538. _groupDensity: number[];
  68539. /**
  68540. * Only when points are colored by texture carries pointer to texture list array
  68541. * @hidden
  68542. */
  68543. _textureNb: number;
  68544. /**
  68545. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  68546. * PCS internal tool, don't use it manually.
  68547. * @hidden
  68548. */
  68549. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  68550. }
  68551. }
  68552. declare module BABYLON {
  68553. interface Scene {
  68554. /** @hidden (Backing field) */
  68555. _physicsEngine: Nullable<IPhysicsEngine>;
  68556. /** @hidden */
  68557. _physicsTimeAccumulator: number;
  68558. /**
  68559. * Gets the current physics engine
  68560. * @returns a IPhysicsEngine or null if none attached
  68561. */
  68562. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  68563. /**
  68564. * Enables physics to the current scene
  68565. * @param gravity defines the scene's gravity for the physics engine
  68566. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  68567. * @return a boolean indicating if the physics engine was initialized
  68568. */
  68569. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  68570. /**
  68571. * Disables and disposes the physics engine associated with the scene
  68572. */
  68573. disablePhysicsEngine(): void;
  68574. /**
  68575. * Gets a boolean indicating if there is an active physics engine
  68576. * @returns a boolean indicating if there is an active physics engine
  68577. */
  68578. isPhysicsEnabled(): boolean;
  68579. /**
  68580. * Deletes a physics compound impostor
  68581. * @param compound defines the compound to delete
  68582. */
  68583. deleteCompoundImpostor(compound: any): void;
  68584. /**
  68585. * An event triggered when physic simulation is about to be run
  68586. */
  68587. onBeforePhysicsObservable: Observable<Scene>;
  68588. /**
  68589. * An event triggered when physic simulation has been done
  68590. */
  68591. onAfterPhysicsObservable: Observable<Scene>;
  68592. }
  68593. interface AbstractMesh {
  68594. /** @hidden */
  68595. _physicsImpostor: Nullable<PhysicsImpostor>;
  68596. /**
  68597. * Gets or sets impostor used for physic simulation
  68598. * @see https://doc.babylonjs.com/features/physics_engine
  68599. */
  68600. physicsImpostor: Nullable<PhysicsImpostor>;
  68601. /**
  68602. * Gets the current physics impostor
  68603. * @see https://doc.babylonjs.com/features/physics_engine
  68604. * @returns a physics impostor or null
  68605. */
  68606. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  68607. /** Apply a physic impulse to the mesh
  68608. * @param force defines the force to apply
  68609. * @param contactPoint defines where to apply the force
  68610. * @returns the current mesh
  68611. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  68612. */
  68613. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  68614. /**
  68615. * Creates a physic joint between two meshes
  68616. * @param otherMesh defines the other mesh to use
  68617. * @param pivot1 defines the pivot to use on this mesh
  68618. * @param pivot2 defines the pivot to use on the other mesh
  68619. * @param options defines additional options (can be plugin dependent)
  68620. * @returns the current mesh
  68621. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  68622. */
  68623. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  68624. /** @hidden */
  68625. _disposePhysicsObserver: Nullable<Observer<Node>>;
  68626. }
  68627. /**
  68628. * Defines the physics engine scene component responsible to manage a physics engine
  68629. */
  68630. export class PhysicsEngineSceneComponent implements ISceneComponent {
  68631. /**
  68632. * The component name helpful to identify the component in the list of scene components.
  68633. */
  68634. readonly name: string;
  68635. /**
  68636. * The scene the component belongs to.
  68637. */
  68638. scene: Scene;
  68639. /**
  68640. * Creates a new instance of the component for the given scene
  68641. * @param scene Defines the scene to register the component in
  68642. */
  68643. constructor(scene: Scene);
  68644. /**
  68645. * Registers the component in a given scene
  68646. */
  68647. register(): void;
  68648. /**
  68649. * Rebuilds the elements related to this component in case of
  68650. * context lost for instance.
  68651. */
  68652. rebuild(): void;
  68653. /**
  68654. * Disposes the component and the associated ressources
  68655. */
  68656. dispose(): void;
  68657. }
  68658. }
  68659. declare module BABYLON {
  68660. /**
  68661. * A helper for physics simulations
  68662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68663. */
  68664. export class PhysicsHelper {
  68665. private _scene;
  68666. private _physicsEngine;
  68667. /**
  68668. * Initializes the Physics helper
  68669. * @param scene Babylon.js scene
  68670. */
  68671. constructor(scene: Scene);
  68672. /**
  68673. * Applies a radial explosion impulse
  68674. * @param origin the origin of the explosion
  68675. * @param radiusOrEventOptions the radius or the options of radial explosion
  68676. * @param strength the explosion strength
  68677. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68678. * @returns A physics radial explosion event, or null
  68679. */
  68680. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68681. /**
  68682. * Applies a radial explosion force
  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. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68690. /**
  68691. * Creates a gravitational field
  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 gravitational field event, or null
  68697. */
  68698. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  68699. /**
  68700. * Creates a physics updraft event
  68701. * @param origin the origin of the updraft
  68702. * @param radiusOrEventOptions the radius or the options of the updraft
  68703. * @param strength the strength of the updraft
  68704. * @param height the height of the updraft
  68705. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  68706. * @returns A physics updraft event, or null
  68707. */
  68708. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  68709. /**
  68710. * Creates a physics vortex event
  68711. * @param origin the of the vortex
  68712. * @param radiusOrEventOptions the radius or the options of the vortex
  68713. * @param strength the strength of the vortex
  68714. * @param height the height of the vortex
  68715. * @returns a Physics vortex event, or null
  68716. * A physics vortex event or null
  68717. */
  68718. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  68719. }
  68720. /**
  68721. * Represents a physics radial explosion event
  68722. */
  68723. class PhysicsRadialExplosionEvent {
  68724. private _scene;
  68725. private _options;
  68726. private _sphere;
  68727. private _dataFetched;
  68728. /**
  68729. * Initializes a radial explosioin event
  68730. * @param _scene BabylonJS scene
  68731. * @param _options The options for the vortex event
  68732. */
  68733. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  68734. /**
  68735. * Returns the data related to the radial explosion event (sphere).
  68736. * @returns The radial explosion event data
  68737. */
  68738. getData(): PhysicsRadialExplosionEventData;
  68739. /**
  68740. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  68741. * @param impostor A physics imposter
  68742. * @param origin the origin of the explosion
  68743. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  68744. */
  68745. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  68746. /**
  68747. * Triggers affecterd impostors callbacks
  68748. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  68749. */
  68750. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  68751. /**
  68752. * Disposes the sphere.
  68753. * @param force Specifies if the sphere should be disposed by force
  68754. */
  68755. dispose(force?: boolean): void;
  68756. /*** Helpers ***/
  68757. private _prepareSphere;
  68758. private _intersectsWithSphere;
  68759. }
  68760. /**
  68761. * Represents a gravitational field event
  68762. */
  68763. class PhysicsGravitationalFieldEvent {
  68764. private _physicsHelper;
  68765. private _scene;
  68766. private _origin;
  68767. private _options;
  68768. private _tickCallback;
  68769. private _sphere;
  68770. private _dataFetched;
  68771. /**
  68772. * Initializes the physics gravitational field event
  68773. * @param _physicsHelper A physics helper
  68774. * @param _scene BabylonJS scene
  68775. * @param _origin The origin position of the gravitational field event
  68776. * @param _options The options for the vortex event
  68777. */
  68778. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  68779. /**
  68780. * Returns the data related to the gravitational field event (sphere).
  68781. * @returns A gravitational field event
  68782. */
  68783. getData(): PhysicsGravitationalFieldEventData;
  68784. /**
  68785. * Enables the gravitational field.
  68786. */
  68787. enable(): void;
  68788. /**
  68789. * Disables the gravitational field.
  68790. */
  68791. disable(): void;
  68792. /**
  68793. * Disposes the sphere.
  68794. * @param force The force to dispose from the gravitational field event
  68795. */
  68796. dispose(force?: boolean): void;
  68797. private _tick;
  68798. }
  68799. /**
  68800. * Represents a physics updraft event
  68801. */
  68802. class PhysicsUpdraftEvent {
  68803. private _scene;
  68804. private _origin;
  68805. private _options;
  68806. private _physicsEngine;
  68807. private _originTop;
  68808. private _originDirection;
  68809. private _tickCallback;
  68810. private _cylinder;
  68811. private _cylinderPosition;
  68812. private _dataFetched;
  68813. /**
  68814. * Initializes the physics updraft event
  68815. * @param _scene BabylonJS scene
  68816. * @param _origin The origin position of the updraft
  68817. * @param _options The options for the updraft event
  68818. */
  68819. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  68820. /**
  68821. * Returns the data related to the updraft event (cylinder).
  68822. * @returns A physics updraft event
  68823. */
  68824. getData(): PhysicsUpdraftEventData;
  68825. /**
  68826. * Enables the updraft.
  68827. */
  68828. enable(): void;
  68829. /**
  68830. * Disables the updraft.
  68831. */
  68832. disable(): void;
  68833. /**
  68834. * Disposes the cylinder.
  68835. * @param force Specifies if the updraft should be disposed by force
  68836. */
  68837. dispose(force?: boolean): void;
  68838. private getImpostorHitData;
  68839. private _tick;
  68840. /*** Helpers ***/
  68841. private _prepareCylinder;
  68842. private _intersectsWithCylinder;
  68843. }
  68844. /**
  68845. * Represents a physics vortex event
  68846. */
  68847. class PhysicsVortexEvent {
  68848. private _scene;
  68849. private _origin;
  68850. private _options;
  68851. private _physicsEngine;
  68852. private _originTop;
  68853. private _tickCallback;
  68854. private _cylinder;
  68855. private _cylinderPosition;
  68856. private _dataFetched;
  68857. /**
  68858. * Initializes the physics vortex event
  68859. * @param _scene The BabylonJS scene
  68860. * @param _origin The origin position of the vortex
  68861. * @param _options The options for the vortex event
  68862. */
  68863. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  68864. /**
  68865. * Returns the data related to the vortex event (cylinder).
  68866. * @returns The physics vortex event data
  68867. */
  68868. getData(): PhysicsVortexEventData;
  68869. /**
  68870. * Enables the vortex.
  68871. */
  68872. enable(): void;
  68873. /**
  68874. * Disables the cortex.
  68875. */
  68876. disable(): void;
  68877. /**
  68878. * Disposes the sphere.
  68879. * @param force
  68880. */
  68881. dispose(force?: boolean): void;
  68882. private getImpostorHitData;
  68883. private _tick;
  68884. /*** Helpers ***/
  68885. private _prepareCylinder;
  68886. private _intersectsWithCylinder;
  68887. }
  68888. /**
  68889. * Options fot the radial explosion event
  68890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68891. */
  68892. export class PhysicsRadialExplosionEventOptions {
  68893. /**
  68894. * The radius of the sphere for the radial explosion.
  68895. */
  68896. radius: number;
  68897. /**
  68898. * The strenth of the explosion.
  68899. */
  68900. strength: number;
  68901. /**
  68902. * The strenght of the force in correspondence to the distance of the affected object
  68903. */
  68904. falloff: PhysicsRadialImpulseFalloff;
  68905. /**
  68906. * Sphere options for the radial explosion.
  68907. */
  68908. sphere: {
  68909. segments: number;
  68910. diameter: number;
  68911. };
  68912. /**
  68913. * Sphere options for the radial explosion.
  68914. */
  68915. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  68916. }
  68917. /**
  68918. * Options fot the updraft event
  68919. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68920. */
  68921. export class PhysicsUpdraftEventOptions {
  68922. /**
  68923. * The radius of the cylinder for the vortex
  68924. */
  68925. radius: number;
  68926. /**
  68927. * The strenth of the updraft.
  68928. */
  68929. strength: number;
  68930. /**
  68931. * The height of the cylinder for the updraft.
  68932. */
  68933. height: number;
  68934. /**
  68935. * The mode for the the updraft.
  68936. */
  68937. updraftMode: PhysicsUpdraftMode;
  68938. }
  68939. /**
  68940. * Options fot the vortex event
  68941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68942. */
  68943. export class PhysicsVortexEventOptions {
  68944. /**
  68945. * The radius of the cylinder for the vortex
  68946. */
  68947. radius: number;
  68948. /**
  68949. * The strenth of the vortex.
  68950. */
  68951. strength: number;
  68952. /**
  68953. * The height of the cylinder for the vortex.
  68954. */
  68955. height: number;
  68956. /**
  68957. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  68958. */
  68959. centripetalForceThreshold: number;
  68960. /**
  68961. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  68962. */
  68963. centripetalForceMultiplier: number;
  68964. /**
  68965. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  68966. */
  68967. centrifugalForceMultiplier: number;
  68968. /**
  68969. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  68970. */
  68971. updraftForceMultiplier: number;
  68972. }
  68973. /**
  68974. * The strenght of the force in correspondence to the distance of the affected object
  68975. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68976. */
  68977. export enum PhysicsRadialImpulseFalloff {
  68978. /** Defines that impulse is constant in strength across it's whole radius */
  68979. Constant = 0,
  68980. /** Defines that impulse gets weaker if it's further from the origin */
  68981. Linear = 1
  68982. }
  68983. /**
  68984. * The strength of the force in correspondence to the distance of the affected object
  68985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68986. */
  68987. export enum PhysicsUpdraftMode {
  68988. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  68989. Center = 0,
  68990. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  68991. Perpendicular = 1
  68992. }
  68993. /**
  68994. * Interface for a physics hit data
  68995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68996. */
  68997. export interface PhysicsHitData {
  68998. /**
  68999. * The force applied at the contact point
  69000. */
  69001. force: Vector3;
  69002. /**
  69003. * The contact point
  69004. */
  69005. contactPoint: Vector3;
  69006. /**
  69007. * The distance from the origin to the contact point
  69008. */
  69009. distanceFromOrigin: number;
  69010. }
  69011. /**
  69012. * Interface for radial explosion event data
  69013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69014. */
  69015. export interface PhysicsRadialExplosionEventData {
  69016. /**
  69017. * A sphere used for the radial explosion event
  69018. */
  69019. sphere: Mesh;
  69020. }
  69021. /**
  69022. * Interface for gravitational field event data
  69023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69024. */
  69025. export interface PhysicsGravitationalFieldEventData {
  69026. /**
  69027. * A sphere mesh used for the gravitational field event
  69028. */
  69029. sphere: Mesh;
  69030. }
  69031. /**
  69032. * Interface for updraft event data
  69033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69034. */
  69035. export interface PhysicsUpdraftEventData {
  69036. /**
  69037. * A cylinder used for the updraft event
  69038. */
  69039. cylinder: Mesh;
  69040. }
  69041. /**
  69042. * Interface for vortex event data
  69043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69044. */
  69045. export interface PhysicsVortexEventData {
  69046. /**
  69047. * A cylinder used for the vortex event
  69048. */
  69049. cylinder: Mesh;
  69050. }
  69051. /**
  69052. * Interface for an affected physics impostor
  69053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69054. */
  69055. export interface PhysicsAffectedImpostorWithData {
  69056. /**
  69057. * The impostor affected by the effect
  69058. */
  69059. impostor: PhysicsImpostor;
  69060. /**
  69061. * The data about the hit/horce from the explosion
  69062. */
  69063. hitData: PhysicsHitData;
  69064. }
  69065. }
  69066. declare module BABYLON {
  69067. /** @hidden */
  69068. export var blackAndWhitePixelShader: {
  69069. name: string;
  69070. shader: string;
  69071. };
  69072. }
  69073. declare module BABYLON {
  69074. /**
  69075. * Post process used to render in black and white
  69076. */
  69077. export class BlackAndWhitePostProcess extends PostProcess {
  69078. /**
  69079. * Linear about to convert he result to black and white (default: 1)
  69080. */
  69081. degree: number;
  69082. /**
  69083. * Gets a string identifying the name of the class
  69084. * @returns "BlackAndWhitePostProcess" string
  69085. */
  69086. getClassName(): string;
  69087. /**
  69088. * Creates a black and white post process
  69089. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  69090. * @param name The name of the effect.
  69091. * @param options The required width/height ratio to downsize to before computing the render pass.
  69092. * @param camera The camera to apply the render pass to.
  69093. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69094. * @param engine The engine which the post process will be applied. (default: current engine)
  69095. * @param reusable If the post process can be reused on the same frame. (default: false)
  69096. */
  69097. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69098. /** @hidden */
  69099. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  69100. }
  69101. }
  69102. declare module BABYLON {
  69103. /**
  69104. * This represents a set of one or more post processes in Babylon.
  69105. * A post process can be used to apply a shader to a texture after it is rendered.
  69106. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69107. */
  69108. export class PostProcessRenderEffect {
  69109. private _postProcesses;
  69110. private _getPostProcesses;
  69111. private _singleInstance;
  69112. private _cameras;
  69113. private _indicesForCamera;
  69114. /**
  69115. * Name of the effect
  69116. * @hidden
  69117. */
  69118. _name: string;
  69119. /**
  69120. * Instantiates a post process render effect.
  69121. * A post process can be used to apply a shader to a texture after it is rendered.
  69122. * @param engine The engine the effect is tied to
  69123. * @param name The name of the effect
  69124. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  69125. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  69126. */
  69127. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  69128. /**
  69129. * Checks if all the post processes in the effect are supported.
  69130. */
  69131. get isSupported(): boolean;
  69132. /**
  69133. * Updates the current state of the effect
  69134. * @hidden
  69135. */
  69136. _update(): void;
  69137. /**
  69138. * Attaches the effect on cameras
  69139. * @param cameras The camera to attach to.
  69140. * @hidden
  69141. */
  69142. _attachCameras(cameras: Camera): void;
  69143. /**
  69144. * Attaches the effect on cameras
  69145. * @param cameras The camera to attach to.
  69146. * @hidden
  69147. */
  69148. _attachCameras(cameras: Camera[]): void;
  69149. /**
  69150. * Detaches the effect on cameras
  69151. * @param cameras The camera to detatch from.
  69152. * @hidden
  69153. */
  69154. _detachCameras(cameras: Camera): void;
  69155. /**
  69156. * Detatches the effect on cameras
  69157. * @param cameras The camera to detatch from.
  69158. * @hidden
  69159. */
  69160. _detachCameras(cameras: Camera[]): void;
  69161. /**
  69162. * Enables the effect on given cameras
  69163. * @param cameras The camera to enable.
  69164. * @hidden
  69165. */
  69166. _enable(cameras: Camera): void;
  69167. /**
  69168. * Enables the effect on given cameras
  69169. * @param cameras The camera to enable.
  69170. * @hidden
  69171. */
  69172. _enable(cameras: Nullable<Camera[]>): void;
  69173. /**
  69174. * Disables the effect on the given cameras
  69175. * @param cameras The camera to disable.
  69176. * @hidden
  69177. */
  69178. _disable(cameras: Camera): void;
  69179. /**
  69180. * Disables the effect on the given cameras
  69181. * @param cameras The camera to disable.
  69182. * @hidden
  69183. */
  69184. _disable(cameras: Nullable<Camera[]>): void;
  69185. /**
  69186. * Gets a list of the post processes contained in the effect.
  69187. * @param camera The camera to get the post processes on.
  69188. * @returns The list of the post processes in the effect.
  69189. */
  69190. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  69191. }
  69192. }
  69193. declare module BABYLON {
  69194. /** @hidden */
  69195. export var extractHighlightsPixelShader: {
  69196. name: string;
  69197. shader: string;
  69198. };
  69199. }
  69200. declare module BABYLON {
  69201. /**
  69202. * 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.
  69203. */
  69204. export class ExtractHighlightsPostProcess extends PostProcess {
  69205. /**
  69206. * The luminance threshold, pixels below this value will be set to black.
  69207. */
  69208. threshold: number;
  69209. /** @hidden */
  69210. _exposure: number;
  69211. /**
  69212. * Post process which has the input texture to be used when performing highlight extraction
  69213. * @hidden
  69214. */
  69215. _inputPostProcess: Nullable<PostProcess>;
  69216. /**
  69217. * Gets a string identifying the name of the class
  69218. * @returns "ExtractHighlightsPostProcess" string
  69219. */
  69220. getClassName(): string;
  69221. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69222. }
  69223. }
  69224. declare module BABYLON {
  69225. /** @hidden */
  69226. export var bloomMergePixelShader: {
  69227. name: string;
  69228. shader: string;
  69229. };
  69230. }
  69231. declare module BABYLON {
  69232. /**
  69233. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69234. */
  69235. export class BloomMergePostProcess extends PostProcess {
  69236. /** Weight of the bloom to be added to the original input. */
  69237. weight: number;
  69238. /**
  69239. * Gets a string identifying the name of the class
  69240. * @returns "BloomMergePostProcess" string
  69241. */
  69242. getClassName(): string;
  69243. /**
  69244. * Creates a new instance of @see BloomMergePostProcess
  69245. * @param name The name of the effect.
  69246. * @param originalFromInput Post process which's input will be used for the merge.
  69247. * @param blurred Blurred highlights post process which's output will be used.
  69248. * @param weight Weight of the bloom to be added to the original input.
  69249. * @param options The required width/height ratio to downsize to before computing the render pass.
  69250. * @param camera The camera to apply the render pass to.
  69251. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69252. * @param engine The engine which the post process will be applied. (default: current engine)
  69253. * @param reusable If the post process can be reused on the same frame. (default: false)
  69254. * @param textureType Type of textures used when performing the post process. (default: 0)
  69255. * @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)
  69256. */
  69257. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  69258. /** Weight of the bloom to be added to the original input. */
  69259. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69260. }
  69261. }
  69262. declare module BABYLON {
  69263. /**
  69264. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  69265. */
  69266. export class BloomEffect extends PostProcessRenderEffect {
  69267. private bloomScale;
  69268. /**
  69269. * @hidden Internal
  69270. */
  69271. _effects: Array<PostProcess>;
  69272. /**
  69273. * @hidden Internal
  69274. */
  69275. _downscale: ExtractHighlightsPostProcess;
  69276. private _blurX;
  69277. private _blurY;
  69278. private _merge;
  69279. /**
  69280. * The luminance threshold to find bright areas of the image to bloom.
  69281. */
  69282. get threshold(): number;
  69283. set threshold(value: number);
  69284. /**
  69285. * The strength of the bloom.
  69286. */
  69287. get weight(): number;
  69288. set weight(value: number);
  69289. /**
  69290. * Specifies the size of the bloom blur kernel, relative to the final output size
  69291. */
  69292. get kernel(): number;
  69293. set kernel(value: number);
  69294. /**
  69295. * Creates a new instance of @see BloomEffect
  69296. * @param scene The scene the effect belongs to.
  69297. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69298. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69299. * @param bloomWeight The the strength of bloom.
  69300. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69301. * @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)
  69302. */
  69303. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69304. /**
  69305. * Disposes each of the internal effects for a given camera.
  69306. * @param camera The camera to dispose the effect on.
  69307. */
  69308. disposeEffects(camera: Camera): void;
  69309. /**
  69310. * @hidden Internal
  69311. */
  69312. _updateEffects(): void;
  69313. /**
  69314. * Internal
  69315. * @returns if all the contained post processes are ready.
  69316. * @hidden
  69317. */
  69318. _isReady(): boolean;
  69319. }
  69320. }
  69321. declare module BABYLON {
  69322. /** @hidden */
  69323. export var chromaticAberrationPixelShader: {
  69324. name: string;
  69325. shader: string;
  69326. };
  69327. }
  69328. declare module BABYLON {
  69329. /**
  69330. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69331. */
  69332. export class ChromaticAberrationPostProcess extends PostProcess {
  69333. /**
  69334. * The amount of seperation of rgb channels (default: 30)
  69335. */
  69336. aberrationAmount: number;
  69337. /**
  69338. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69339. */
  69340. radialIntensity: number;
  69341. /**
  69342. * 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))
  69343. */
  69344. direction: Vector2;
  69345. /**
  69346. * 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))
  69347. */
  69348. centerPosition: Vector2;
  69349. /** The width of the screen to apply the effect on */
  69350. screenWidth: number;
  69351. /** The height of the screen to apply the effect on */
  69352. screenHeight: number;
  69353. /**
  69354. * Gets a string identifying the name of the class
  69355. * @returns "ChromaticAberrationPostProcess" string
  69356. */
  69357. getClassName(): string;
  69358. /**
  69359. * Creates a new instance ChromaticAberrationPostProcess
  69360. * @param name The name of the effect.
  69361. * @param screenWidth The width of the screen to apply the effect on.
  69362. * @param screenHeight The height of the screen to apply the effect on.
  69363. * @param options The required width/height ratio to downsize to before computing the render pass.
  69364. * @param camera The camera to apply the render pass to.
  69365. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69366. * @param engine The engine which the post process will be applied. (default: current engine)
  69367. * @param reusable If the post process can be reused on the same frame. (default: false)
  69368. * @param textureType Type of textures used when performing the post process. (default: 0)
  69369. * @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)
  69370. */
  69371. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69372. /** @hidden */
  69373. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  69374. }
  69375. }
  69376. declare module BABYLON {
  69377. /** @hidden */
  69378. export var circleOfConfusionPixelShader: {
  69379. name: string;
  69380. shader: string;
  69381. };
  69382. }
  69383. declare module BABYLON {
  69384. /**
  69385. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69386. */
  69387. export class CircleOfConfusionPostProcess extends PostProcess {
  69388. /**
  69389. * 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.
  69390. */
  69391. lensSize: number;
  69392. /**
  69393. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69394. */
  69395. fStop: number;
  69396. /**
  69397. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69398. */
  69399. focusDistance: number;
  69400. /**
  69401. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  69402. */
  69403. focalLength: number;
  69404. /**
  69405. * Gets a string identifying the name of the class
  69406. * @returns "CircleOfConfusionPostProcess" string
  69407. */
  69408. getClassName(): string;
  69409. private _depthTexture;
  69410. /**
  69411. * Creates a new instance CircleOfConfusionPostProcess
  69412. * @param name The name of the effect.
  69413. * @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.
  69414. * @param options The required width/height ratio to downsize to before computing the render pass.
  69415. * @param camera The camera to apply the render pass to.
  69416. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69417. * @param engine The engine which the post process will be applied. (default: current engine)
  69418. * @param reusable If the post process can be reused on the same frame. (default: false)
  69419. * @param textureType Type of textures used when performing the post process. (default: 0)
  69420. * @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)
  69421. */
  69422. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69423. /**
  69424. * 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.
  69425. */
  69426. set depthTexture(value: RenderTargetTexture);
  69427. }
  69428. }
  69429. declare module BABYLON {
  69430. /** @hidden */
  69431. export var colorCorrectionPixelShader: {
  69432. name: string;
  69433. shader: string;
  69434. };
  69435. }
  69436. declare module BABYLON {
  69437. /**
  69438. *
  69439. * This post-process allows the modification of rendered colors by using
  69440. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69441. *
  69442. * The object needs to be provided an url to a texture containing the color
  69443. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69444. * Use an image editing software to tweak the LUT to match your needs.
  69445. *
  69446. * For an example of a color LUT, see here:
  69447. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  69448. * For explanations on color grading, see here:
  69449. * @see http://udn.epicgames.com/Three/ColorGrading.html
  69450. *
  69451. */
  69452. export class ColorCorrectionPostProcess extends PostProcess {
  69453. private _colorTableTexture;
  69454. /**
  69455. * Gets the color table url used to create the LUT texture
  69456. */
  69457. colorTableUrl: string;
  69458. /**
  69459. * Gets a string identifying the name of the class
  69460. * @returns "ColorCorrectionPostProcess" string
  69461. */
  69462. getClassName(): string;
  69463. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69464. /** @hidden */
  69465. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  69466. }
  69467. }
  69468. declare module BABYLON {
  69469. /** @hidden */
  69470. export var convolutionPixelShader: {
  69471. name: string;
  69472. shader: string;
  69473. };
  69474. }
  69475. declare module BABYLON {
  69476. /**
  69477. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  69478. * input texture to perform effects such as edge detection or sharpening
  69479. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69480. */
  69481. export class ConvolutionPostProcess extends PostProcess {
  69482. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69483. kernel: number[];
  69484. /**
  69485. * Gets a string identifying the name of the class
  69486. * @returns "ConvolutionPostProcess" string
  69487. */
  69488. getClassName(): string;
  69489. /**
  69490. * Creates a new instance ConvolutionPostProcess
  69491. * @param name The name of the effect.
  69492. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  69493. * @param options The required width/height ratio to downsize to before computing the render pass.
  69494. * @param camera The camera to apply the render pass to.
  69495. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69496. * @param engine The engine which the post process will be applied. (default: current engine)
  69497. * @param reusable If the post process can be reused on the same frame. (default: false)
  69498. * @param textureType Type of textures used when performing the post process. (default: 0)
  69499. */
  69500. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69501. /** @hidden */
  69502. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  69503. /**
  69504. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69505. */
  69506. static EdgeDetect0Kernel: number[];
  69507. /**
  69508. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69509. */
  69510. static EdgeDetect1Kernel: number[];
  69511. /**
  69512. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69513. */
  69514. static EdgeDetect2Kernel: number[];
  69515. /**
  69516. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69517. */
  69518. static SharpenKernel: number[];
  69519. /**
  69520. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69521. */
  69522. static EmbossKernel: number[];
  69523. /**
  69524. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69525. */
  69526. static GaussianKernel: number[];
  69527. }
  69528. }
  69529. declare module BABYLON {
  69530. /**
  69531. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  69532. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  69533. * based on samples that have a large difference in distance than the center pixel.
  69534. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  69535. */
  69536. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  69537. /**
  69538. * The direction the blur should be applied
  69539. */
  69540. direction: Vector2;
  69541. /**
  69542. * Gets a string identifying the name of the class
  69543. * @returns "DepthOfFieldBlurPostProcess" string
  69544. */
  69545. getClassName(): string;
  69546. /**
  69547. * Creates a new instance CircleOfConfusionPostProcess
  69548. * @param name The name of the effect.
  69549. * @param scene The scene the effect belongs to.
  69550. * @param direction The direction the blur should be applied.
  69551. * @param kernel The size of the kernel used to blur.
  69552. * @param options The required width/height ratio to downsize to before computing the render pass.
  69553. * @param camera The camera to apply the render pass to.
  69554. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  69555. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  69556. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69557. * @param engine The engine which the post process will be applied. (default: current engine)
  69558. * @param reusable If the post process can be reused on the same frame. (default: false)
  69559. * @param textureType Type of textures used when performing the post process. (default: 0)
  69560. * @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)
  69561. */
  69562. 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);
  69563. }
  69564. }
  69565. declare module BABYLON {
  69566. /** @hidden */
  69567. export var depthOfFieldMergePixelShader: {
  69568. name: string;
  69569. shader: string;
  69570. };
  69571. }
  69572. declare module BABYLON {
  69573. /**
  69574. * Options to be set when merging outputs from the default pipeline.
  69575. */
  69576. export class DepthOfFieldMergePostProcessOptions {
  69577. /**
  69578. * The original image to merge on top of
  69579. */
  69580. originalFromInput: PostProcess;
  69581. /**
  69582. * Parameters to perform the merge of the depth of field effect
  69583. */
  69584. depthOfField?: {
  69585. circleOfConfusion: PostProcess;
  69586. blurSteps: Array<PostProcess>;
  69587. };
  69588. /**
  69589. * Parameters to perform the merge of bloom effect
  69590. */
  69591. bloom?: {
  69592. blurred: PostProcess;
  69593. weight: number;
  69594. };
  69595. }
  69596. /**
  69597. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69598. */
  69599. export class DepthOfFieldMergePostProcess extends PostProcess {
  69600. private blurSteps;
  69601. /**
  69602. * Gets a string identifying the name of the class
  69603. * @returns "DepthOfFieldMergePostProcess" string
  69604. */
  69605. getClassName(): string;
  69606. /**
  69607. * Creates a new instance of DepthOfFieldMergePostProcess
  69608. * @param name The name of the effect.
  69609. * @param originalFromInput Post process which's input will be used for the merge.
  69610. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  69611. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  69612. * @param options The required width/height ratio to downsize to before computing the render pass.
  69613. * @param camera The camera to apply the render pass to.
  69614. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69615. * @param engine The engine which the post process will be applied. (default: current engine)
  69616. * @param reusable If the post process can be reused on the same frame. (default: false)
  69617. * @param textureType Type of textures used when performing the post process. (default: 0)
  69618. * @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)
  69619. */
  69620. 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);
  69621. /**
  69622. * Updates the effect with the current post process compile time values and recompiles the shader.
  69623. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69624. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69625. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69626. * @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
  69627. * @param onCompiled Called when the shader has been compiled.
  69628. * @param onError Called if there is an error when compiling a shader.
  69629. */
  69630. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69631. }
  69632. }
  69633. declare module BABYLON {
  69634. /**
  69635. * Specifies the level of max blur that should be applied when using the depth of field effect
  69636. */
  69637. export enum DepthOfFieldEffectBlurLevel {
  69638. /**
  69639. * Subtle blur
  69640. */
  69641. Low = 0,
  69642. /**
  69643. * Medium blur
  69644. */
  69645. Medium = 1,
  69646. /**
  69647. * Large blur
  69648. */
  69649. High = 2
  69650. }
  69651. /**
  69652. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  69653. */
  69654. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  69655. private _circleOfConfusion;
  69656. /**
  69657. * @hidden Internal, blurs from high to low
  69658. */
  69659. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  69660. private _depthOfFieldBlurY;
  69661. private _dofMerge;
  69662. /**
  69663. * @hidden Internal post processes in depth of field effect
  69664. */
  69665. _effects: Array<PostProcess>;
  69666. /**
  69667. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  69668. */
  69669. set focalLength(value: number);
  69670. get focalLength(): number;
  69671. /**
  69672. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69673. */
  69674. set fStop(value: number);
  69675. get fStop(): number;
  69676. /**
  69677. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69678. */
  69679. set focusDistance(value: number);
  69680. get focusDistance(): number;
  69681. /**
  69682. * 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.
  69683. */
  69684. set lensSize(value: number);
  69685. get lensSize(): number;
  69686. /**
  69687. * Creates a new instance DepthOfFieldEffect
  69688. * @param scene The scene the effect belongs to.
  69689. * @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.
  69690. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69691. * @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)
  69692. */
  69693. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  69694. /**
  69695. * Get the current class name of the current effet
  69696. * @returns "DepthOfFieldEffect"
  69697. */
  69698. getClassName(): string;
  69699. /**
  69700. * 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.
  69701. */
  69702. set depthTexture(value: RenderTargetTexture);
  69703. /**
  69704. * Disposes each of the internal effects for a given camera.
  69705. * @param camera The camera to dispose the effect on.
  69706. */
  69707. disposeEffects(camera: Camera): void;
  69708. /**
  69709. * @hidden Internal
  69710. */
  69711. _updateEffects(): void;
  69712. /**
  69713. * Internal
  69714. * @returns if all the contained post processes are ready.
  69715. * @hidden
  69716. */
  69717. _isReady(): boolean;
  69718. }
  69719. }
  69720. declare module BABYLON {
  69721. /** @hidden */
  69722. export var displayPassPixelShader: {
  69723. name: string;
  69724. shader: string;
  69725. };
  69726. }
  69727. declare module BABYLON {
  69728. /**
  69729. * DisplayPassPostProcess which produces an output the same as it's input
  69730. */
  69731. export class DisplayPassPostProcess extends PostProcess {
  69732. /**
  69733. * Gets a string identifying the name of the class
  69734. * @returns "DisplayPassPostProcess" string
  69735. */
  69736. getClassName(): string;
  69737. /**
  69738. * Creates the DisplayPassPostProcess
  69739. * @param name The name of the effect.
  69740. * @param options The required width/height ratio to downsize to before computing the render pass.
  69741. * @param camera The camera to apply the render pass to.
  69742. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69743. * @param engine The engine which the post process will be applied. (default: current engine)
  69744. * @param reusable If the post process can be reused on the same frame. (default: false)
  69745. */
  69746. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69747. /** @hidden */
  69748. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  69749. }
  69750. }
  69751. declare module BABYLON {
  69752. /** @hidden */
  69753. export var filterPixelShader: {
  69754. name: string;
  69755. shader: string;
  69756. };
  69757. }
  69758. declare module BABYLON {
  69759. /**
  69760. * Applies a kernel filter to the image
  69761. */
  69762. export class FilterPostProcess extends PostProcess {
  69763. /** The matrix to be applied to the image */
  69764. kernelMatrix: Matrix;
  69765. /**
  69766. * Gets a string identifying the name of the class
  69767. * @returns "FilterPostProcess" string
  69768. */
  69769. getClassName(): string;
  69770. /**
  69771. *
  69772. * @param name The name of the effect.
  69773. * @param kernelMatrix The matrix to be applied to the image
  69774. * @param options The required width/height ratio to downsize to before computing the render pass.
  69775. * @param camera The camera to apply the render pass to.
  69776. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69777. * @param engine The engine which the post process will be applied. (default: current engine)
  69778. * @param reusable If the post process can be reused on the same frame. (default: false)
  69779. */
  69780. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69781. /** @hidden */
  69782. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  69783. }
  69784. }
  69785. declare module BABYLON {
  69786. /** @hidden */
  69787. export var fxaaPixelShader: {
  69788. name: string;
  69789. shader: string;
  69790. };
  69791. }
  69792. declare module BABYLON {
  69793. /** @hidden */
  69794. export var fxaaVertexShader: {
  69795. name: string;
  69796. shader: string;
  69797. };
  69798. }
  69799. declare module BABYLON {
  69800. /**
  69801. * Fxaa post process
  69802. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  69803. */
  69804. export class FxaaPostProcess extends PostProcess {
  69805. /**
  69806. * Gets a string identifying the name of the class
  69807. * @returns "FxaaPostProcess" string
  69808. */
  69809. getClassName(): string;
  69810. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69811. private _getDefines;
  69812. /** @hidden */
  69813. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  69814. }
  69815. }
  69816. declare module BABYLON {
  69817. /** @hidden */
  69818. export var grainPixelShader: {
  69819. name: string;
  69820. shader: string;
  69821. };
  69822. }
  69823. declare module BABYLON {
  69824. /**
  69825. * The GrainPostProcess adds noise to the image at mid luminance levels
  69826. */
  69827. export class GrainPostProcess extends PostProcess {
  69828. /**
  69829. * The intensity of the grain added (default: 30)
  69830. */
  69831. intensity: number;
  69832. /**
  69833. * If the grain should be randomized on every frame
  69834. */
  69835. animated: boolean;
  69836. /**
  69837. * Gets a string identifying the name of the class
  69838. * @returns "GrainPostProcess" string
  69839. */
  69840. getClassName(): string;
  69841. /**
  69842. * Creates a new instance of @see GrainPostProcess
  69843. * @param name The name of the effect.
  69844. * @param options The required width/height ratio to downsize to before computing the render pass.
  69845. * @param camera The camera to apply the render pass to.
  69846. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69847. * @param engine The engine which the post process will be applied. (default: current engine)
  69848. * @param reusable If the post process can be reused on the same frame. (default: false)
  69849. * @param textureType Type of textures used when performing the post process. (default: 0)
  69850. * @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)
  69851. */
  69852. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69853. /** @hidden */
  69854. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  69855. }
  69856. }
  69857. declare module BABYLON {
  69858. /** @hidden */
  69859. export var highlightsPixelShader: {
  69860. name: string;
  69861. shader: string;
  69862. };
  69863. }
  69864. declare module BABYLON {
  69865. /**
  69866. * Extracts highlights from the image
  69867. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69868. */
  69869. export class HighlightsPostProcess extends PostProcess {
  69870. /**
  69871. * Gets a string identifying the name of the class
  69872. * @returns "HighlightsPostProcess" string
  69873. */
  69874. getClassName(): string;
  69875. /**
  69876. * Extracts highlights from the image
  69877. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69878. * @param name The name of the effect.
  69879. * @param options The required width/height ratio to downsize to before computing the render pass.
  69880. * @param camera The camera to apply the render pass to.
  69881. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69882. * @param engine The engine which the post process will be applied. (default: current engine)
  69883. * @param reusable If the post process can be reused on the same frame. (default: false)
  69884. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  69885. */
  69886. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69887. }
  69888. }
  69889. declare module BABYLON {
  69890. /** @hidden */
  69891. export var mrtFragmentDeclaration: {
  69892. name: string;
  69893. shader: string;
  69894. };
  69895. }
  69896. declare module BABYLON {
  69897. /** @hidden */
  69898. export var geometryPixelShader: {
  69899. name: string;
  69900. shader: string;
  69901. };
  69902. }
  69903. declare module BABYLON {
  69904. /** @hidden */
  69905. export var geometryVertexShader: {
  69906. name: string;
  69907. shader: string;
  69908. };
  69909. }
  69910. declare module BABYLON {
  69911. /** @hidden */
  69912. interface ISavedTransformationMatrix {
  69913. world: Matrix;
  69914. viewProjection: Matrix;
  69915. }
  69916. /**
  69917. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  69918. */
  69919. export class GeometryBufferRenderer {
  69920. /**
  69921. * Constant used to retrieve the position texture index in the G-Buffer textures array
  69922. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  69923. */
  69924. static readonly POSITION_TEXTURE_TYPE: number;
  69925. /**
  69926. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  69927. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  69928. */
  69929. static readonly VELOCITY_TEXTURE_TYPE: number;
  69930. /**
  69931. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  69932. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  69933. */
  69934. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  69935. /**
  69936. * Dictionary used to store the previous transformation matrices of each rendered mesh
  69937. * in order to compute objects velocities when enableVelocity is set to "true"
  69938. * @hidden
  69939. */
  69940. _previousTransformationMatrices: {
  69941. [index: number]: ISavedTransformationMatrix;
  69942. };
  69943. /**
  69944. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  69945. * in order to compute objects velocities when enableVelocity is set to "true"
  69946. * @hidden
  69947. */
  69948. _previousBonesTransformationMatrices: {
  69949. [index: number]: Float32Array;
  69950. };
  69951. /**
  69952. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  69953. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  69954. */
  69955. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  69956. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  69957. renderTransparentMeshes: boolean;
  69958. private _scene;
  69959. private _resizeObserver;
  69960. private _multiRenderTarget;
  69961. private _ratio;
  69962. private _enablePosition;
  69963. private _enableVelocity;
  69964. private _enableReflectivity;
  69965. private _positionIndex;
  69966. private _velocityIndex;
  69967. private _reflectivityIndex;
  69968. protected _effect: Effect;
  69969. protected _cachedDefines: string;
  69970. /**
  69971. * Set the render list (meshes to be rendered) used in the G buffer.
  69972. */
  69973. set renderList(meshes: Mesh[]);
  69974. /**
  69975. * Gets wether or not G buffer are supported by the running hardware.
  69976. * This requires draw buffer supports
  69977. */
  69978. get isSupported(): boolean;
  69979. /**
  69980. * Returns the index of the given texture type in the G-Buffer textures array
  69981. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  69982. * @returns the index of the given texture type in the G-Buffer textures array
  69983. */
  69984. getTextureIndex(textureType: number): number;
  69985. /**
  69986. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  69987. */
  69988. get enablePosition(): boolean;
  69989. /**
  69990. * Sets whether or not objects positions are enabled for the G buffer.
  69991. */
  69992. set enablePosition(enable: boolean);
  69993. /**
  69994. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  69995. */
  69996. get enableVelocity(): boolean;
  69997. /**
  69998. * Sets wether or not objects velocities are enabled for the G buffer.
  69999. */
  70000. set enableVelocity(enable: boolean);
  70001. /**
  70002. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  70003. */
  70004. get enableReflectivity(): boolean;
  70005. /**
  70006. * Sets wether or not objects roughness are enabled for the G buffer.
  70007. */
  70008. set enableReflectivity(enable: boolean);
  70009. /**
  70010. * Gets the scene associated with the buffer.
  70011. */
  70012. get scene(): Scene;
  70013. /**
  70014. * Gets the ratio used by the buffer during its creation.
  70015. * How big is the buffer related to the main canvas.
  70016. */
  70017. get ratio(): number;
  70018. /** @hidden */
  70019. static _SceneComponentInitialization: (scene: Scene) => void;
  70020. /**
  70021. * Creates a new G Buffer for the scene
  70022. * @param scene The scene the buffer belongs to
  70023. * @param ratio How big is the buffer related to the main canvas.
  70024. */
  70025. constructor(scene: Scene, ratio?: number);
  70026. /**
  70027. * Checks wether everything is ready to render a submesh to the G buffer.
  70028. * @param subMesh the submesh to check readiness for
  70029. * @param useInstances is the mesh drawn using instance or not
  70030. * @returns true if ready otherwise false
  70031. */
  70032. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70033. /**
  70034. * Gets the current underlying G Buffer.
  70035. * @returns the buffer
  70036. */
  70037. getGBuffer(): MultiRenderTarget;
  70038. /**
  70039. * Gets the number of samples used to render the buffer (anti aliasing).
  70040. */
  70041. get samples(): number;
  70042. /**
  70043. * Sets the number of samples used to render the buffer (anti aliasing).
  70044. */
  70045. set samples(value: number);
  70046. /**
  70047. * Disposes the renderer and frees up associated resources.
  70048. */
  70049. dispose(): void;
  70050. protected _createRenderTargets(): void;
  70051. private _copyBonesTransformationMatrices;
  70052. }
  70053. }
  70054. declare module BABYLON {
  70055. interface Scene {
  70056. /** @hidden (Backing field) */
  70057. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70058. /**
  70059. * Gets or Sets the current geometry buffer associated to the scene.
  70060. */
  70061. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70062. /**
  70063. * Enables a GeometryBufferRender and associates it with the scene
  70064. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70065. * @returns the GeometryBufferRenderer
  70066. */
  70067. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70068. /**
  70069. * Disables the GeometryBufferRender associated with the scene
  70070. */
  70071. disableGeometryBufferRenderer(): void;
  70072. }
  70073. /**
  70074. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70075. * in several rendering techniques.
  70076. */
  70077. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70078. /**
  70079. * The component name helpful to identify the component in the list of scene components.
  70080. */
  70081. readonly name: string;
  70082. /**
  70083. * The scene the component belongs to.
  70084. */
  70085. scene: Scene;
  70086. /**
  70087. * Creates a new instance of the component for the given scene
  70088. * @param scene Defines the scene to register the component in
  70089. */
  70090. constructor(scene: Scene);
  70091. /**
  70092. * Registers the component in a given scene
  70093. */
  70094. register(): void;
  70095. /**
  70096. * Rebuilds the elements related to this component in case of
  70097. * context lost for instance.
  70098. */
  70099. rebuild(): void;
  70100. /**
  70101. * Disposes the component and the associated ressources
  70102. */
  70103. dispose(): void;
  70104. private _gatherRenderTargets;
  70105. }
  70106. }
  70107. declare module BABYLON {
  70108. /** @hidden */
  70109. export var motionBlurPixelShader: {
  70110. name: string;
  70111. shader: string;
  70112. };
  70113. }
  70114. declare module BABYLON {
  70115. /**
  70116. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70117. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70118. * As an example, all you have to do is to create the post-process:
  70119. * var mb = new BABYLON.MotionBlurPostProcess(
  70120. * 'mb', // The name of the effect.
  70121. * scene, // The scene containing the objects to blur according to their velocity.
  70122. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70123. * camera // The camera to apply the render pass to.
  70124. * );
  70125. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70126. */
  70127. export class MotionBlurPostProcess extends PostProcess {
  70128. /**
  70129. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70130. */
  70131. motionStrength: number;
  70132. /**
  70133. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70134. */
  70135. get motionBlurSamples(): number;
  70136. /**
  70137. * Sets the number of iterations to be used for motion blur quality
  70138. */
  70139. set motionBlurSamples(samples: number);
  70140. private _motionBlurSamples;
  70141. private _geometryBufferRenderer;
  70142. /**
  70143. * Gets a string identifying the name of the class
  70144. * @returns "MotionBlurPostProcess" string
  70145. */
  70146. getClassName(): string;
  70147. /**
  70148. * Creates a new instance MotionBlurPostProcess
  70149. * @param name The name of the effect.
  70150. * @param scene The scene containing the objects to blur according to their velocity.
  70151. * @param options The required width/height ratio to downsize to before computing the render pass.
  70152. * @param camera The camera to apply the render pass to.
  70153. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70154. * @param engine The engine which the post process will be applied. (default: current engine)
  70155. * @param reusable If the post process can be reused on the same frame. (default: false)
  70156. * @param textureType Type of textures used when performing the post process. (default: 0)
  70157. * @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)
  70158. */
  70159. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70160. /**
  70161. * Excludes the given skinned mesh from computing bones velocities.
  70162. * 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.
  70163. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70164. */
  70165. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70166. /**
  70167. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70168. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70169. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70170. */
  70171. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70172. /**
  70173. * Disposes the post process.
  70174. * @param camera The camera to dispose the post process on.
  70175. */
  70176. dispose(camera?: Camera): void;
  70177. /** @hidden */
  70178. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  70179. }
  70180. }
  70181. declare module BABYLON {
  70182. /** @hidden */
  70183. export var refractionPixelShader: {
  70184. name: string;
  70185. shader: string;
  70186. };
  70187. }
  70188. declare module BABYLON {
  70189. /**
  70190. * Post process which applies a refractin texture
  70191. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70192. */
  70193. export class RefractionPostProcess extends PostProcess {
  70194. private _refTexture;
  70195. private _ownRefractionTexture;
  70196. /** the base color of the refraction (used to taint the rendering) */
  70197. color: Color3;
  70198. /** simulated refraction depth */
  70199. depth: number;
  70200. /** the coefficient of the base color (0 to remove base color tainting) */
  70201. colorLevel: number;
  70202. /** Gets the url used to load the refraction texture */
  70203. refractionTextureUrl: string;
  70204. /**
  70205. * Gets or sets the refraction texture
  70206. * Please note that you are responsible for disposing the texture if you set it manually
  70207. */
  70208. get refractionTexture(): Texture;
  70209. set refractionTexture(value: Texture);
  70210. /**
  70211. * Gets a string identifying the name of the class
  70212. * @returns "RefractionPostProcess" string
  70213. */
  70214. getClassName(): string;
  70215. /**
  70216. * Initializes the RefractionPostProcess
  70217. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70218. * @param name The name of the effect.
  70219. * @param refractionTextureUrl Url of the refraction texture to use
  70220. * @param color the base color of the refraction (used to taint the rendering)
  70221. * @param depth simulated refraction depth
  70222. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  70223. * @param camera The camera to apply the render pass to.
  70224. * @param options The required width/height ratio to downsize to before computing the render pass.
  70225. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70226. * @param engine The engine which the post process will be applied. (default: current engine)
  70227. * @param reusable If the post process can be reused on the same frame. (default: false)
  70228. */
  70229. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70230. /**
  70231. * Disposes of the post process
  70232. * @param camera Camera to dispose post process on
  70233. */
  70234. dispose(camera: Camera): void;
  70235. /** @hidden */
  70236. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  70237. }
  70238. }
  70239. declare module BABYLON {
  70240. /** @hidden */
  70241. export var sharpenPixelShader: {
  70242. name: string;
  70243. shader: string;
  70244. };
  70245. }
  70246. declare module BABYLON {
  70247. /**
  70248. * The SharpenPostProcess applies a sharpen kernel to every pixel
  70249. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70250. */
  70251. export class SharpenPostProcess extends PostProcess {
  70252. /**
  70253. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  70254. */
  70255. colorAmount: number;
  70256. /**
  70257. * How much sharpness should be applied (default: 0.3)
  70258. */
  70259. edgeAmount: number;
  70260. /**
  70261. * Gets a string identifying the name of the class
  70262. * @returns "SharpenPostProcess" string
  70263. */
  70264. getClassName(): string;
  70265. /**
  70266. * Creates a new instance ConvolutionPostProcess
  70267. * @param name The name of the effect.
  70268. * @param options The required width/height ratio to downsize to before computing the render pass.
  70269. * @param camera The camera to apply the render pass to.
  70270. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70271. * @param engine The engine which the post process will be applied. (default: current engine)
  70272. * @param reusable If the post process can be reused on the same frame. (default: false)
  70273. * @param textureType Type of textures used when performing the post process. (default: 0)
  70274. * @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)
  70275. */
  70276. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70277. /** @hidden */
  70278. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  70279. }
  70280. }
  70281. declare module BABYLON {
  70282. /**
  70283. * PostProcessRenderPipeline
  70284. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70285. */
  70286. export class PostProcessRenderPipeline {
  70287. private engine;
  70288. private _renderEffects;
  70289. private _renderEffectsForIsolatedPass;
  70290. /**
  70291. * List of inspectable custom properties (used by the Inspector)
  70292. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70293. */
  70294. inspectableCustomProperties: IInspectable[];
  70295. /**
  70296. * @hidden
  70297. */
  70298. protected _cameras: Camera[];
  70299. /** @hidden */
  70300. _name: string;
  70301. /**
  70302. * Gets pipeline name
  70303. */
  70304. get name(): string;
  70305. /** Gets the list of attached cameras */
  70306. get cameras(): Camera[];
  70307. /**
  70308. * Initializes a PostProcessRenderPipeline
  70309. * @param engine engine to add the pipeline to
  70310. * @param name name of the pipeline
  70311. */
  70312. constructor(engine: Engine, name: string);
  70313. /**
  70314. * Gets the class name
  70315. * @returns "PostProcessRenderPipeline"
  70316. */
  70317. getClassName(): string;
  70318. /**
  70319. * If all the render effects in the pipeline are supported
  70320. */
  70321. get isSupported(): boolean;
  70322. /**
  70323. * Adds an effect to the pipeline
  70324. * @param renderEffect the effect to add
  70325. */
  70326. addEffect(renderEffect: PostProcessRenderEffect): void;
  70327. /** @hidden */
  70328. _rebuild(): void;
  70329. /** @hidden */
  70330. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70331. /** @hidden */
  70332. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70333. /** @hidden */
  70334. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70335. /** @hidden */
  70336. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70337. /** @hidden */
  70338. _attachCameras(cameras: Camera, unique: boolean): void;
  70339. /** @hidden */
  70340. _attachCameras(cameras: Camera[], unique: boolean): void;
  70341. /** @hidden */
  70342. _detachCameras(cameras: Camera): void;
  70343. /** @hidden */
  70344. _detachCameras(cameras: Nullable<Camera[]>): void;
  70345. /** @hidden */
  70346. _update(): void;
  70347. /** @hidden */
  70348. _reset(): void;
  70349. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70350. /**
  70351. * Sets the required values to the prepass renderer.
  70352. * @param prePassRenderer defines the prepass renderer to setup.
  70353. * @returns true if the pre pass is needed.
  70354. */
  70355. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70356. /**
  70357. * Disposes of the pipeline
  70358. */
  70359. dispose(): void;
  70360. }
  70361. }
  70362. declare module BABYLON {
  70363. /**
  70364. * PostProcessRenderPipelineManager class
  70365. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70366. */
  70367. export class PostProcessRenderPipelineManager {
  70368. private _renderPipelines;
  70369. /**
  70370. * Initializes a PostProcessRenderPipelineManager
  70371. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70372. */
  70373. constructor();
  70374. /**
  70375. * Gets the list of supported render pipelines
  70376. */
  70377. get supportedPipelines(): PostProcessRenderPipeline[];
  70378. /**
  70379. * Adds a pipeline to the manager
  70380. * @param renderPipeline The pipeline to add
  70381. */
  70382. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70383. /**
  70384. * Attaches a camera to the pipeline
  70385. * @param renderPipelineName The name of the pipeline to attach to
  70386. * @param cameras the camera to attach
  70387. * @param unique if the camera can be attached multiple times to the pipeline
  70388. */
  70389. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70390. /**
  70391. * Detaches a camera from the pipeline
  70392. * @param renderPipelineName The name of the pipeline to detach from
  70393. * @param cameras the camera to detach
  70394. */
  70395. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70396. /**
  70397. * Enables an effect by name on a pipeline
  70398. * @param renderPipelineName the name of the pipeline to enable the effect in
  70399. * @param renderEffectName the name of the effect to enable
  70400. * @param cameras the cameras that the effect should be enabled on
  70401. */
  70402. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70403. /**
  70404. * Disables an effect by name on a pipeline
  70405. * @param renderPipelineName the name of the pipeline to disable the effect in
  70406. * @param renderEffectName the name of the effect to disable
  70407. * @param cameras the cameras that the effect should be disabled on
  70408. */
  70409. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70410. /**
  70411. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70412. */
  70413. update(): void;
  70414. /** @hidden */
  70415. _rebuild(): void;
  70416. /**
  70417. * Disposes of the manager and pipelines
  70418. */
  70419. dispose(): void;
  70420. }
  70421. }
  70422. declare module BABYLON {
  70423. interface Scene {
  70424. /** @hidden (Backing field) */
  70425. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70426. /**
  70427. * Gets the postprocess render pipeline manager
  70428. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70429. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70430. */
  70431. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70432. }
  70433. /**
  70434. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70435. */
  70436. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70437. /**
  70438. * The component name helpfull to identify the component in the list of scene components.
  70439. */
  70440. readonly name: string;
  70441. /**
  70442. * The scene the component belongs to.
  70443. */
  70444. scene: Scene;
  70445. /**
  70446. * Creates a new instance of the component for the given scene
  70447. * @param scene Defines the scene to register the component in
  70448. */
  70449. constructor(scene: Scene);
  70450. /**
  70451. * Registers the component in a given scene
  70452. */
  70453. register(): void;
  70454. /**
  70455. * Rebuilds the elements related to this component in case of
  70456. * context lost for instance.
  70457. */
  70458. rebuild(): void;
  70459. /**
  70460. * Disposes the component and the associated ressources
  70461. */
  70462. dispose(): void;
  70463. private _gatherRenderTargets;
  70464. }
  70465. }
  70466. declare module BABYLON {
  70467. /**
  70468. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  70469. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70470. */
  70471. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70472. private _scene;
  70473. private _camerasToBeAttached;
  70474. /**
  70475. * ID of the sharpen post process,
  70476. */
  70477. private readonly SharpenPostProcessId;
  70478. /**
  70479. * @ignore
  70480. * ID of the image processing post process;
  70481. */
  70482. readonly ImageProcessingPostProcessId: string;
  70483. /**
  70484. * @ignore
  70485. * ID of the Fast Approximate Anti-Aliasing post process;
  70486. */
  70487. readonly FxaaPostProcessId: string;
  70488. /**
  70489. * ID of the chromatic aberration post process,
  70490. */
  70491. private readonly ChromaticAberrationPostProcessId;
  70492. /**
  70493. * ID of the grain post process
  70494. */
  70495. private readonly GrainPostProcessId;
  70496. /**
  70497. * Sharpen post process which will apply a sharpen convolution to enhance edges
  70498. */
  70499. sharpen: SharpenPostProcess;
  70500. private _sharpenEffect;
  70501. private bloom;
  70502. /**
  70503. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  70504. */
  70505. depthOfField: DepthOfFieldEffect;
  70506. /**
  70507. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70508. */
  70509. fxaa: FxaaPostProcess;
  70510. /**
  70511. * Image post processing pass used to perform operations such as tone mapping or color grading.
  70512. */
  70513. imageProcessing: ImageProcessingPostProcess;
  70514. /**
  70515. * Chromatic aberration post process which will shift rgb colors in the image
  70516. */
  70517. chromaticAberration: ChromaticAberrationPostProcess;
  70518. private _chromaticAberrationEffect;
  70519. /**
  70520. * Grain post process which add noise to the image
  70521. */
  70522. grain: GrainPostProcess;
  70523. private _grainEffect;
  70524. /**
  70525. * Glow post process which adds a glow to emissive areas of the image
  70526. */
  70527. private _glowLayer;
  70528. /**
  70529. * Animations which can be used to tweak settings over a period of time
  70530. */
  70531. animations: Animation[];
  70532. private _imageProcessingConfigurationObserver;
  70533. private _sharpenEnabled;
  70534. private _bloomEnabled;
  70535. private _depthOfFieldEnabled;
  70536. private _depthOfFieldBlurLevel;
  70537. private _fxaaEnabled;
  70538. private _imageProcessingEnabled;
  70539. private _defaultPipelineTextureType;
  70540. private _bloomScale;
  70541. private _chromaticAberrationEnabled;
  70542. private _grainEnabled;
  70543. private _buildAllowed;
  70544. /**
  70545. * Gets active scene
  70546. */
  70547. get scene(): Scene;
  70548. /**
  70549. * Enable or disable the sharpen process from the pipeline
  70550. */
  70551. set sharpenEnabled(enabled: boolean);
  70552. get sharpenEnabled(): boolean;
  70553. private _resizeObserver;
  70554. private _hardwareScaleLevel;
  70555. private _bloomKernel;
  70556. /**
  70557. * Specifies the size of the bloom blur kernel, relative to the final output size
  70558. */
  70559. get bloomKernel(): number;
  70560. set bloomKernel(value: number);
  70561. /**
  70562. * Specifies the weight of the bloom in the final rendering
  70563. */
  70564. private _bloomWeight;
  70565. /**
  70566. * Specifies the luma threshold for the area that will be blurred by the bloom
  70567. */
  70568. private _bloomThreshold;
  70569. private _hdr;
  70570. /**
  70571. * The strength of the bloom.
  70572. */
  70573. set bloomWeight(value: number);
  70574. get bloomWeight(): number;
  70575. /**
  70576. * The strength of the bloom.
  70577. */
  70578. set bloomThreshold(value: number);
  70579. get bloomThreshold(): number;
  70580. /**
  70581. * The scale of the bloom, lower value will provide better performance.
  70582. */
  70583. set bloomScale(value: number);
  70584. get bloomScale(): number;
  70585. /**
  70586. * Enable or disable the bloom from the pipeline
  70587. */
  70588. set bloomEnabled(enabled: boolean);
  70589. get bloomEnabled(): boolean;
  70590. private _rebuildBloom;
  70591. /**
  70592. * If the depth of field is enabled.
  70593. */
  70594. get depthOfFieldEnabled(): boolean;
  70595. set depthOfFieldEnabled(enabled: boolean);
  70596. /**
  70597. * Blur level of the depth of field effect. (Higher blur will effect performance)
  70598. */
  70599. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  70600. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  70601. /**
  70602. * If the anti aliasing is enabled.
  70603. */
  70604. set fxaaEnabled(enabled: boolean);
  70605. get fxaaEnabled(): boolean;
  70606. private _samples;
  70607. /**
  70608. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70609. */
  70610. set samples(sampleCount: number);
  70611. get samples(): number;
  70612. /**
  70613. * If image processing is enabled.
  70614. */
  70615. set imageProcessingEnabled(enabled: boolean);
  70616. get imageProcessingEnabled(): boolean;
  70617. /**
  70618. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  70619. */
  70620. set glowLayerEnabled(enabled: boolean);
  70621. get glowLayerEnabled(): boolean;
  70622. /**
  70623. * Gets the glow layer (or null if not defined)
  70624. */
  70625. get glowLayer(): Nullable<GlowLayer>;
  70626. /**
  70627. * Enable or disable the chromaticAberration process from the pipeline
  70628. */
  70629. set chromaticAberrationEnabled(enabled: boolean);
  70630. get chromaticAberrationEnabled(): boolean;
  70631. /**
  70632. * Enable or disable the grain process from the pipeline
  70633. */
  70634. set grainEnabled(enabled: boolean);
  70635. get grainEnabled(): boolean;
  70636. /**
  70637. * @constructor
  70638. * @param name - The rendering pipeline name (default: "")
  70639. * @param hdr - If high dynamic range textures should be used (default: true)
  70640. * @param scene - The scene linked to this pipeline (default: the last created scene)
  70641. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  70642. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  70643. */
  70644. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  70645. /**
  70646. * Get the class name
  70647. * @returns "DefaultRenderingPipeline"
  70648. */
  70649. getClassName(): string;
  70650. /**
  70651. * Force the compilation of the entire pipeline.
  70652. */
  70653. prepare(): void;
  70654. private _hasCleared;
  70655. private _prevPostProcess;
  70656. private _prevPrevPostProcess;
  70657. private _setAutoClearAndTextureSharing;
  70658. private _depthOfFieldSceneObserver;
  70659. private _buildPipeline;
  70660. private _disposePostProcesses;
  70661. /**
  70662. * Adds a camera to the pipeline
  70663. * @param camera the camera to be added
  70664. */
  70665. addCamera(camera: Camera): void;
  70666. /**
  70667. * Removes a camera from the pipeline
  70668. * @param camera the camera to remove
  70669. */
  70670. removeCamera(camera: Camera): void;
  70671. /**
  70672. * Dispose of the pipeline and stop all post processes
  70673. */
  70674. dispose(): void;
  70675. /**
  70676. * Serialize the rendering pipeline (Used when exporting)
  70677. * @returns the serialized object
  70678. */
  70679. serialize(): any;
  70680. /**
  70681. * Parse the serialized pipeline
  70682. * @param source Source pipeline.
  70683. * @param scene The scene to load the pipeline to.
  70684. * @param rootUrl The URL of the serialized pipeline.
  70685. * @returns An instantiated pipeline from the serialized object.
  70686. */
  70687. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  70688. }
  70689. }
  70690. declare module BABYLON {
  70691. /** @hidden */
  70692. export var lensHighlightsPixelShader: {
  70693. name: string;
  70694. shader: string;
  70695. };
  70696. }
  70697. declare module BABYLON {
  70698. /** @hidden */
  70699. export var depthOfFieldPixelShader: {
  70700. name: string;
  70701. shader: string;
  70702. };
  70703. }
  70704. declare module BABYLON {
  70705. /**
  70706. * BABYLON.JS Chromatic Aberration GLSL Shader
  70707. * Author: Olivier Guyot
  70708. * Separates very slightly R, G and B colors on the edges of the screen
  70709. * Inspired by Francois Tarlier & Martins Upitis
  70710. */
  70711. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  70712. /**
  70713. * @ignore
  70714. * The chromatic aberration PostProcess id in the pipeline
  70715. */
  70716. LensChromaticAberrationEffect: string;
  70717. /**
  70718. * @ignore
  70719. * The highlights enhancing PostProcess id in the pipeline
  70720. */
  70721. HighlightsEnhancingEffect: string;
  70722. /**
  70723. * @ignore
  70724. * The depth-of-field PostProcess id in the pipeline
  70725. */
  70726. LensDepthOfFieldEffect: string;
  70727. private _scene;
  70728. private _depthTexture;
  70729. private _grainTexture;
  70730. private _chromaticAberrationPostProcess;
  70731. private _highlightsPostProcess;
  70732. private _depthOfFieldPostProcess;
  70733. private _edgeBlur;
  70734. private _grainAmount;
  70735. private _chromaticAberration;
  70736. private _distortion;
  70737. private _highlightsGain;
  70738. private _highlightsThreshold;
  70739. private _dofDistance;
  70740. private _dofAperture;
  70741. private _dofDarken;
  70742. private _dofPentagon;
  70743. private _blurNoise;
  70744. /**
  70745. * @constructor
  70746. *
  70747. * Effect parameters are as follow:
  70748. * {
  70749. * chromatic_aberration: number; // from 0 to x (1 for realism)
  70750. * edge_blur: number; // from 0 to x (1 for realism)
  70751. * distortion: number; // from 0 to x (1 for realism)
  70752. * grain_amount: number; // from 0 to 1
  70753. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  70754. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  70755. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  70756. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  70757. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  70758. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  70759. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  70760. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  70761. * }
  70762. * Note: if an effect parameter is unset, effect is disabled
  70763. *
  70764. * @param name The rendering pipeline name
  70765. * @param parameters - An object containing all parameters (see above)
  70766. * @param scene The scene linked to this pipeline
  70767. * @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)
  70768. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70769. */
  70770. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  70771. /**
  70772. * Get the class name
  70773. * @returns "LensRenderingPipeline"
  70774. */
  70775. getClassName(): string;
  70776. /**
  70777. * Gets associated scene
  70778. */
  70779. get scene(): Scene;
  70780. /**
  70781. * Gets or sets the edge blur
  70782. */
  70783. get edgeBlur(): number;
  70784. set edgeBlur(value: number);
  70785. /**
  70786. * Gets or sets the grain amount
  70787. */
  70788. get grainAmount(): number;
  70789. set grainAmount(value: number);
  70790. /**
  70791. * Gets or sets the chromatic aberration amount
  70792. */
  70793. get chromaticAberration(): number;
  70794. set chromaticAberration(value: number);
  70795. /**
  70796. * Gets or sets the depth of field aperture
  70797. */
  70798. get dofAperture(): number;
  70799. set dofAperture(value: number);
  70800. /**
  70801. * Gets or sets the edge distortion
  70802. */
  70803. get edgeDistortion(): number;
  70804. set edgeDistortion(value: number);
  70805. /**
  70806. * Gets or sets the depth of field distortion
  70807. */
  70808. get dofDistortion(): number;
  70809. set dofDistortion(value: number);
  70810. /**
  70811. * Gets or sets the darken out of focus amount
  70812. */
  70813. get darkenOutOfFocus(): number;
  70814. set darkenOutOfFocus(value: number);
  70815. /**
  70816. * Gets or sets a boolean indicating if blur noise is enabled
  70817. */
  70818. get blurNoise(): boolean;
  70819. set blurNoise(value: boolean);
  70820. /**
  70821. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  70822. */
  70823. get pentagonBokeh(): boolean;
  70824. set pentagonBokeh(value: boolean);
  70825. /**
  70826. * Gets or sets the highlight grain amount
  70827. */
  70828. get highlightsGain(): number;
  70829. set highlightsGain(value: number);
  70830. /**
  70831. * Gets or sets the highlight threshold
  70832. */
  70833. get highlightsThreshold(): number;
  70834. set highlightsThreshold(value: number);
  70835. /**
  70836. * Sets the amount of blur at the edges
  70837. * @param amount blur amount
  70838. */
  70839. setEdgeBlur(amount: number): void;
  70840. /**
  70841. * Sets edge blur to 0
  70842. */
  70843. disableEdgeBlur(): void;
  70844. /**
  70845. * Sets the amout of grain
  70846. * @param amount Amount of grain
  70847. */
  70848. setGrainAmount(amount: number): void;
  70849. /**
  70850. * Set grain amount to 0
  70851. */
  70852. disableGrain(): void;
  70853. /**
  70854. * Sets the chromatic aberration amount
  70855. * @param amount amount of chromatic aberration
  70856. */
  70857. setChromaticAberration(amount: number): void;
  70858. /**
  70859. * Sets chromatic aberration amount to 0
  70860. */
  70861. disableChromaticAberration(): void;
  70862. /**
  70863. * Sets the EdgeDistortion amount
  70864. * @param amount amount of EdgeDistortion
  70865. */
  70866. setEdgeDistortion(amount: number): void;
  70867. /**
  70868. * Sets edge distortion to 0
  70869. */
  70870. disableEdgeDistortion(): void;
  70871. /**
  70872. * Sets the FocusDistance amount
  70873. * @param amount amount of FocusDistance
  70874. */
  70875. setFocusDistance(amount: number): void;
  70876. /**
  70877. * Disables depth of field
  70878. */
  70879. disableDepthOfField(): void;
  70880. /**
  70881. * Sets the Aperture amount
  70882. * @param amount amount of Aperture
  70883. */
  70884. setAperture(amount: number): void;
  70885. /**
  70886. * Sets the DarkenOutOfFocus amount
  70887. * @param amount amount of DarkenOutOfFocus
  70888. */
  70889. setDarkenOutOfFocus(amount: number): void;
  70890. private _pentagonBokehIsEnabled;
  70891. /**
  70892. * Creates a pentagon bokeh effect
  70893. */
  70894. enablePentagonBokeh(): void;
  70895. /**
  70896. * Disables the pentagon bokeh effect
  70897. */
  70898. disablePentagonBokeh(): void;
  70899. /**
  70900. * Enables noise blur
  70901. */
  70902. enableNoiseBlur(): void;
  70903. /**
  70904. * Disables noise blur
  70905. */
  70906. disableNoiseBlur(): void;
  70907. /**
  70908. * Sets the HighlightsGain amount
  70909. * @param amount amount of HighlightsGain
  70910. */
  70911. setHighlightsGain(amount: number): void;
  70912. /**
  70913. * Sets the HighlightsThreshold amount
  70914. * @param amount amount of HighlightsThreshold
  70915. */
  70916. setHighlightsThreshold(amount: number): void;
  70917. /**
  70918. * Disables highlights
  70919. */
  70920. disableHighlights(): void;
  70921. /**
  70922. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  70923. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  70924. */
  70925. dispose(disableDepthRender?: boolean): void;
  70926. private _createChromaticAberrationPostProcess;
  70927. private _createHighlightsPostProcess;
  70928. private _createDepthOfFieldPostProcess;
  70929. private _createGrainTexture;
  70930. }
  70931. }
  70932. declare module BABYLON {
  70933. /**
  70934. * Contains all parameters needed for the prepass to perform
  70935. * screen space subsurface scattering
  70936. */
  70937. export class SSAO2Configuration implements PrePassEffectConfiguration {
  70938. /**
  70939. * Is subsurface enabled
  70940. */
  70941. enabled: boolean;
  70942. /**
  70943. * Name of the configuration
  70944. */
  70945. name: string;
  70946. /**
  70947. * Textures that should be present in the MRT for this effect to work
  70948. */
  70949. readonly texturesRequired: number[];
  70950. /**
  70951. * Builds a ssao2 configuration object
  70952. * @param scene The scene
  70953. */
  70954. constructor();
  70955. /**
  70956. * Disposes the configuration
  70957. */
  70958. dispose(): void;
  70959. }
  70960. }
  70961. declare module BABYLON {
  70962. /** @hidden */
  70963. export var ssao2PixelShader: {
  70964. name: string;
  70965. shader: string;
  70966. };
  70967. }
  70968. declare module BABYLON {
  70969. /** @hidden */
  70970. export var ssaoCombinePixelShader: {
  70971. name: string;
  70972. shader: string;
  70973. };
  70974. }
  70975. declare module BABYLON {
  70976. /**
  70977. * Render pipeline to produce ssao effect
  70978. */
  70979. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  70980. /**
  70981. * @ignore
  70982. * The PassPostProcess id in the pipeline that contains the original scene color
  70983. */
  70984. SSAOOriginalSceneColorEffect: string;
  70985. /**
  70986. * @ignore
  70987. * The SSAO PostProcess id in the pipeline
  70988. */
  70989. SSAORenderEffect: string;
  70990. /**
  70991. * @ignore
  70992. * The horizontal blur PostProcess id in the pipeline
  70993. */
  70994. SSAOBlurHRenderEffect: string;
  70995. /**
  70996. * @ignore
  70997. * The vertical blur PostProcess id in the pipeline
  70998. */
  70999. SSAOBlurVRenderEffect: string;
  71000. /**
  71001. * @ignore
  71002. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71003. */
  71004. SSAOCombineRenderEffect: string;
  71005. /**
  71006. * The output strength of the SSAO post-process. Default value is 1.0.
  71007. */
  71008. totalStrength: number;
  71009. /**
  71010. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  71011. */
  71012. maxZ: number;
  71013. /**
  71014. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  71015. */
  71016. minZAspect: number;
  71017. private _samples;
  71018. /**
  71019. * Number of samples used for the SSAO calculations. Default value is 8
  71020. */
  71021. set samples(n: number);
  71022. get samples(): number;
  71023. private _textureSamples;
  71024. /**
  71025. * Number of samples to use for antialiasing
  71026. */
  71027. set textureSamples(n: number);
  71028. get textureSamples(): number;
  71029. /**
  71030. * Force rendering the geometry through geometry buffer
  71031. */
  71032. private _forceGeometryBuffer;
  71033. /**
  71034. * Ratio object used for SSAO ratio and blur ratio
  71035. */
  71036. private _ratio;
  71037. /**
  71038. * Dynamically generated sphere sampler.
  71039. */
  71040. private _sampleSphere;
  71041. private _ssao2PrePassConfiguration;
  71042. /**
  71043. * Blur filter offsets
  71044. */
  71045. private _samplerOffsets;
  71046. private _expensiveBlur;
  71047. /**
  71048. * If bilateral blur should be used
  71049. */
  71050. set expensiveBlur(b: boolean);
  71051. get expensiveBlur(): boolean;
  71052. /**
  71053. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  71054. */
  71055. radius: number;
  71056. /**
  71057. * The base color of the SSAO post-process
  71058. * The final result is "base + ssao" between [0, 1]
  71059. */
  71060. base: number;
  71061. /**
  71062. * Support test.
  71063. */
  71064. static get IsSupported(): boolean;
  71065. private _scene;
  71066. private _randomTexture;
  71067. private _originalColorPostProcess;
  71068. private _ssaoPostProcess;
  71069. private _blurHPostProcess;
  71070. private _blurVPostProcess;
  71071. private _ssaoCombinePostProcess;
  71072. private _prePassRenderer;
  71073. /**
  71074. * Gets active scene
  71075. */
  71076. get scene(): Scene;
  71077. /**
  71078. * @constructor
  71079. * @param name The rendering pipeline name
  71080. * @param scene The scene linked to this pipeline
  71081. * @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 }
  71082. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71083. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  71084. */
  71085. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  71086. /**
  71087. * Get the class name
  71088. * @returns "SSAO2RenderingPipeline"
  71089. */
  71090. getClassName(): string;
  71091. /**
  71092. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71093. */
  71094. dispose(disableGeometryBufferRenderer?: boolean): void;
  71095. private _createBlurPostProcess;
  71096. /** @hidden */
  71097. _rebuild(): void;
  71098. private _bits;
  71099. private _radicalInverse_VdC;
  71100. private _hammersley;
  71101. private _hemisphereSample_uniform;
  71102. private _generateHemisphere;
  71103. private _getDefinesForSSAO;
  71104. private _createSSAOPostProcess;
  71105. private _createSSAOCombinePostProcess;
  71106. private _createRandomTexture;
  71107. /**
  71108. * Serialize the rendering pipeline (Used when exporting)
  71109. * @returns the serialized object
  71110. */
  71111. serialize(): any;
  71112. /**
  71113. * Parse the serialized pipeline
  71114. * @param source Source pipeline.
  71115. * @param scene The scene to load the pipeline to.
  71116. * @param rootUrl The URL of the serialized pipeline.
  71117. * @returns An instantiated pipeline from the serialized object.
  71118. */
  71119. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71120. /**
  71121. * Sets the required values to the prepass renderer.
  71122. * @param prePassRenderer defines the prepass renderer to setup
  71123. * @returns true if the pre pass is needed.
  71124. */
  71125. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  71126. }
  71127. }
  71128. declare module BABYLON {
  71129. /** @hidden */
  71130. export var ssaoPixelShader: {
  71131. name: string;
  71132. shader: string;
  71133. };
  71134. }
  71135. declare module BABYLON {
  71136. /**
  71137. * Render pipeline to produce ssao effect
  71138. */
  71139. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71140. /**
  71141. * @ignore
  71142. * The PassPostProcess id in the pipeline that contains the original scene color
  71143. */
  71144. SSAOOriginalSceneColorEffect: string;
  71145. /**
  71146. * @ignore
  71147. * The SSAO PostProcess id in the pipeline
  71148. */
  71149. SSAORenderEffect: string;
  71150. /**
  71151. * @ignore
  71152. * The horizontal blur PostProcess id in the pipeline
  71153. */
  71154. SSAOBlurHRenderEffect: string;
  71155. /**
  71156. * @ignore
  71157. * The vertical blur PostProcess id in the pipeline
  71158. */
  71159. SSAOBlurVRenderEffect: string;
  71160. /**
  71161. * @ignore
  71162. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71163. */
  71164. SSAOCombineRenderEffect: string;
  71165. /**
  71166. * The output strength of the SSAO post-process. Default value is 1.0.
  71167. */
  71168. totalStrength: number;
  71169. /**
  71170. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71171. */
  71172. radius: number;
  71173. /**
  71174. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71175. * Must not be equal to fallOff and superior to fallOff.
  71176. * Default value is 0.0075
  71177. */
  71178. area: number;
  71179. /**
  71180. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71181. * Must not be equal to area and inferior to area.
  71182. * Default value is 0.000001
  71183. */
  71184. fallOff: number;
  71185. /**
  71186. * The base color of the SSAO post-process
  71187. * The final result is "base + ssao" between [0, 1]
  71188. */
  71189. base: number;
  71190. private _scene;
  71191. private _depthTexture;
  71192. private _randomTexture;
  71193. private _originalColorPostProcess;
  71194. private _ssaoPostProcess;
  71195. private _blurHPostProcess;
  71196. private _blurVPostProcess;
  71197. private _ssaoCombinePostProcess;
  71198. private _firstUpdate;
  71199. /**
  71200. * Gets active scene
  71201. */
  71202. get scene(): Scene;
  71203. /**
  71204. * @constructor
  71205. * @param name - The rendering pipeline name
  71206. * @param scene - The scene linked to this pipeline
  71207. * @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 }
  71208. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  71209. */
  71210. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71211. /**
  71212. * Get the class name
  71213. * @returns "SSAORenderingPipeline"
  71214. */
  71215. getClassName(): string;
  71216. /**
  71217. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71218. */
  71219. dispose(disableDepthRender?: boolean): void;
  71220. private _createBlurPostProcess;
  71221. /** @hidden */
  71222. _rebuild(): void;
  71223. private _createSSAOPostProcess;
  71224. private _createSSAOCombinePostProcess;
  71225. private _createRandomTexture;
  71226. }
  71227. }
  71228. declare module BABYLON {
  71229. /** @hidden */
  71230. export var screenSpaceReflectionPixelShader: {
  71231. name: string;
  71232. shader: string;
  71233. };
  71234. }
  71235. declare module BABYLON {
  71236. /**
  71237. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  71238. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  71239. */
  71240. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  71241. /**
  71242. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  71243. */
  71244. threshold: number;
  71245. /**
  71246. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  71247. */
  71248. strength: number;
  71249. /**
  71250. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  71251. */
  71252. reflectionSpecularFalloffExponent: number;
  71253. /**
  71254. * 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]
  71255. */
  71256. step: number;
  71257. /**
  71258. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  71259. */
  71260. roughnessFactor: number;
  71261. private _geometryBufferRenderer;
  71262. private _enableSmoothReflections;
  71263. private _reflectionSamples;
  71264. private _smoothSteps;
  71265. /**
  71266. * Gets a string identifying the name of the class
  71267. * @returns "ScreenSpaceReflectionPostProcess" string
  71268. */
  71269. getClassName(): string;
  71270. /**
  71271. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  71272. * @param name The name of the effect.
  71273. * @param scene The scene containing the objects to calculate reflections.
  71274. * @param options The required width/height ratio to downsize to before computing the render pass.
  71275. * @param camera The camera to apply the render pass to.
  71276. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71277. * @param engine The engine which the post process will be applied. (default: current engine)
  71278. * @param reusable If the post process can be reused on the same frame. (default: false)
  71279. * @param textureType Type of textures used when performing the post process. (default: 0)
  71280. * @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)
  71281. */
  71282. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71283. /**
  71284. * Gets wether or not smoothing reflections is enabled.
  71285. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71286. */
  71287. get enableSmoothReflections(): boolean;
  71288. /**
  71289. * Sets wether or not smoothing reflections is enabled.
  71290. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71291. */
  71292. set enableSmoothReflections(enabled: boolean);
  71293. /**
  71294. * Gets the number of samples taken while computing reflections. More samples count is high,
  71295. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71296. */
  71297. get reflectionSamples(): number;
  71298. /**
  71299. * Sets the number of samples taken while computing reflections. More samples count is high,
  71300. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71301. */
  71302. set reflectionSamples(samples: number);
  71303. /**
  71304. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  71305. * more the post-process will require GPU power and can generate a drop in FPS.
  71306. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71307. */
  71308. get smoothSteps(): number;
  71309. set smoothSteps(steps: number);
  71310. private _updateEffectDefines;
  71311. /** @hidden */
  71312. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  71313. }
  71314. }
  71315. declare module BABYLON {
  71316. /** @hidden */
  71317. export var standardPixelShader: {
  71318. name: string;
  71319. shader: string;
  71320. };
  71321. }
  71322. declare module BABYLON {
  71323. /**
  71324. * Standard rendering pipeline
  71325. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71326. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71327. */
  71328. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71329. /**
  71330. * Public members
  71331. */
  71332. /**
  71333. * Post-process which contains the original scene color before the pipeline applies all the effects
  71334. */
  71335. originalPostProcess: Nullable<PostProcess>;
  71336. /**
  71337. * Post-process used to down scale an image x4
  71338. */
  71339. downSampleX4PostProcess: Nullable<PostProcess>;
  71340. /**
  71341. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71342. */
  71343. brightPassPostProcess: Nullable<PostProcess>;
  71344. /**
  71345. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71346. */
  71347. blurHPostProcesses: PostProcess[];
  71348. /**
  71349. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71350. */
  71351. blurVPostProcesses: PostProcess[];
  71352. /**
  71353. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71354. */
  71355. textureAdderPostProcess: Nullable<PostProcess>;
  71356. /**
  71357. * Post-process used to create volumetric lighting effect
  71358. */
  71359. volumetricLightPostProcess: Nullable<PostProcess>;
  71360. /**
  71361. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71362. */
  71363. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71364. /**
  71365. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71366. */
  71367. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71368. /**
  71369. * Post-process used to merge the volumetric light effect and the real scene color
  71370. */
  71371. volumetricLightMergePostProces: Nullable<PostProcess>;
  71372. /**
  71373. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71374. */
  71375. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71376. /**
  71377. * Base post-process used to calculate the average luminance of the final image for HDR
  71378. */
  71379. luminancePostProcess: Nullable<PostProcess>;
  71380. /**
  71381. * Post-processes used to create down sample post-processes in order to get
  71382. * the average luminance of the final image for HDR
  71383. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71384. */
  71385. luminanceDownSamplePostProcesses: PostProcess[];
  71386. /**
  71387. * Post-process used to create a HDR effect (light adaptation)
  71388. */
  71389. hdrPostProcess: Nullable<PostProcess>;
  71390. /**
  71391. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71392. */
  71393. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71394. /**
  71395. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71396. */
  71397. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71398. /**
  71399. * Post-process used to merge the final HDR post-process and the real scene color
  71400. */
  71401. hdrFinalPostProcess: Nullable<PostProcess>;
  71402. /**
  71403. * Post-process used to create a lens flare effect
  71404. */
  71405. lensFlarePostProcess: Nullable<PostProcess>;
  71406. /**
  71407. * Post-process that merges the result of the lens flare post-process and the real scene color
  71408. */
  71409. lensFlareComposePostProcess: Nullable<PostProcess>;
  71410. /**
  71411. * Post-process used to create a motion blur effect
  71412. */
  71413. motionBlurPostProcess: Nullable<PostProcess>;
  71414. /**
  71415. * Post-process used to create a depth of field effect
  71416. */
  71417. depthOfFieldPostProcess: Nullable<PostProcess>;
  71418. /**
  71419. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71420. */
  71421. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71422. /**
  71423. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71424. */
  71425. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71426. /**
  71427. * Represents the brightness threshold in order to configure the illuminated surfaces
  71428. */
  71429. brightThreshold: number;
  71430. /**
  71431. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71432. */
  71433. blurWidth: number;
  71434. /**
  71435. * Sets if the blur for highlighted surfaces must be only horizontal
  71436. */
  71437. horizontalBlur: boolean;
  71438. /**
  71439. * Gets the overall exposure used by the pipeline
  71440. */
  71441. get exposure(): number;
  71442. /**
  71443. * Sets the overall exposure used by the pipeline
  71444. */
  71445. set exposure(value: number);
  71446. /**
  71447. * Texture used typically to simulate "dirty" on camera lens
  71448. */
  71449. lensTexture: Nullable<Texture>;
  71450. /**
  71451. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71452. */
  71453. volumetricLightCoefficient: number;
  71454. /**
  71455. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71456. */
  71457. volumetricLightPower: number;
  71458. /**
  71459. * Used the set the blur intensity to smooth the volumetric lights
  71460. */
  71461. volumetricLightBlurScale: number;
  71462. /**
  71463. * Light (spot or directional) used to generate the volumetric lights rays
  71464. * The source light must have a shadow generate so the pipeline can get its
  71465. * depth map
  71466. */
  71467. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71468. /**
  71469. * For eye adaptation, represents the minimum luminance the eye can see
  71470. */
  71471. hdrMinimumLuminance: number;
  71472. /**
  71473. * For eye adaptation, represents the decrease luminance speed
  71474. */
  71475. hdrDecreaseRate: number;
  71476. /**
  71477. * For eye adaptation, represents the increase luminance speed
  71478. */
  71479. hdrIncreaseRate: number;
  71480. /**
  71481. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71482. */
  71483. get hdrAutoExposure(): boolean;
  71484. /**
  71485. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71486. */
  71487. set hdrAutoExposure(value: boolean);
  71488. /**
  71489. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  71490. */
  71491. lensColorTexture: Nullable<Texture>;
  71492. /**
  71493. * The overall strengh for the lens flare effect
  71494. */
  71495. lensFlareStrength: number;
  71496. /**
  71497. * Dispersion coefficient for lens flare ghosts
  71498. */
  71499. lensFlareGhostDispersal: number;
  71500. /**
  71501. * Main lens flare halo width
  71502. */
  71503. lensFlareHaloWidth: number;
  71504. /**
  71505. * Based on the lens distortion effect, defines how much the lens flare result
  71506. * is distorted
  71507. */
  71508. lensFlareDistortionStrength: number;
  71509. /**
  71510. * Configures the blur intensity used for for lens flare (halo)
  71511. */
  71512. lensFlareBlurWidth: number;
  71513. /**
  71514. * Lens star texture must be used to simulate rays on the flares and is available
  71515. * in the documentation
  71516. */
  71517. lensStarTexture: Nullable<Texture>;
  71518. /**
  71519. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  71520. * flare effect by taking account of the dirt texture
  71521. */
  71522. lensFlareDirtTexture: Nullable<Texture>;
  71523. /**
  71524. * Represents the focal length for the depth of field effect
  71525. */
  71526. depthOfFieldDistance: number;
  71527. /**
  71528. * Represents the blur intensity for the blurred part of the depth of field effect
  71529. */
  71530. depthOfFieldBlurWidth: number;
  71531. /**
  71532. * Gets how much the image is blurred by the movement while using the motion blur post-process
  71533. */
  71534. get motionStrength(): number;
  71535. /**
  71536. * Sets how much the image is blurred by the movement while using the motion blur post-process
  71537. */
  71538. set motionStrength(strength: number);
  71539. /**
  71540. * Gets wether or not the motion blur post-process is object based or screen based.
  71541. */
  71542. get objectBasedMotionBlur(): boolean;
  71543. /**
  71544. * Sets wether or not the motion blur post-process should be object based or screen based
  71545. */
  71546. set objectBasedMotionBlur(value: boolean);
  71547. /**
  71548. * List of animations for the pipeline (IAnimatable implementation)
  71549. */
  71550. animations: Animation[];
  71551. /**
  71552. * Private members
  71553. */
  71554. private _scene;
  71555. private _currentDepthOfFieldSource;
  71556. private _basePostProcess;
  71557. private _fixedExposure;
  71558. private _currentExposure;
  71559. private _hdrAutoExposure;
  71560. private _hdrCurrentLuminance;
  71561. private _motionStrength;
  71562. private _isObjectBasedMotionBlur;
  71563. private _floatTextureType;
  71564. private _camerasToBeAttached;
  71565. private _ratio;
  71566. private _bloomEnabled;
  71567. private _depthOfFieldEnabled;
  71568. private _vlsEnabled;
  71569. private _lensFlareEnabled;
  71570. private _hdrEnabled;
  71571. private _motionBlurEnabled;
  71572. private _fxaaEnabled;
  71573. private _screenSpaceReflectionsEnabled;
  71574. private _motionBlurSamples;
  71575. private _volumetricLightStepsCount;
  71576. private _samples;
  71577. /**
  71578. * @ignore
  71579. * Specifies if the bloom pipeline is enabled
  71580. */
  71581. get BloomEnabled(): boolean;
  71582. set BloomEnabled(enabled: boolean);
  71583. /**
  71584. * @ignore
  71585. * Specifies if the depth of field pipeline is enabed
  71586. */
  71587. get DepthOfFieldEnabled(): boolean;
  71588. set DepthOfFieldEnabled(enabled: boolean);
  71589. /**
  71590. * @ignore
  71591. * Specifies if the lens flare pipeline is enabed
  71592. */
  71593. get LensFlareEnabled(): boolean;
  71594. set LensFlareEnabled(enabled: boolean);
  71595. /**
  71596. * @ignore
  71597. * Specifies if the HDR pipeline is enabled
  71598. */
  71599. get HDREnabled(): boolean;
  71600. set HDREnabled(enabled: boolean);
  71601. /**
  71602. * @ignore
  71603. * Specifies if the volumetric lights scattering effect is enabled
  71604. */
  71605. get VLSEnabled(): boolean;
  71606. set VLSEnabled(enabled: boolean);
  71607. /**
  71608. * @ignore
  71609. * Specifies if the motion blur effect is enabled
  71610. */
  71611. get MotionBlurEnabled(): boolean;
  71612. set MotionBlurEnabled(enabled: boolean);
  71613. /**
  71614. * Specifies if anti-aliasing is enabled
  71615. */
  71616. get fxaaEnabled(): boolean;
  71617. set fxaaEnabled(enabled: boolean);
  71618. /**
  71619. * Specifies if screen space reflections are enabled.
  71620. */
  71621. get screenSpaceReflectionsEnabled(): boolean;
  71622. set screenSpaceReflectionsEnabled(enabled: boolean);
  71623. /**
  71624. * Specifies the number of steps used to calculate the volumetric lights
  71625. * Typically in interval [50, 200]
  71626. */
  71627. get volumetricLightStepsCount(): number;
  71628. set volumetricLightStepsCount(count: number);
  71629. /**
  71630. * Specifies the number of samples used for the motion blur effect
  71631. * Typically in interval [16, 64]
  71632. */
  71633. get motionBlurSamples(): number;
  71634. set motionBlurSamples(samples: number);
  71635. /**
  71636. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71637. */
  71638. get samples(): number;
  71639. set samples(sampleCount: number);
  71640. /**
  71641. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71642. * @constructor
  71643. * @param name The rendering pipeline name
  71644. * @param scene The scene linked to this pipeline
  71645. * @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)
  71646. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  71647. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71648. */
  71649. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  71650. private _buildPipeline;
  71651. private _createDownSampleX4PostProcess;
  71652. private _createBrightPassPostProcess;
  71653. private _createBlurPostProcesses;
  71654. private _createTextureAdderPostProcess;
  71655. private _createVolumetricLightPostProcess;
  71656. private _createLuminancePostProcesses;
  71657. private _createHdrPostProcess;
  71658. private _createLensFlarePostProcess;
  71659. private _createDepthOfFieldPostProcess;
  71660. private _createMotionBlurPostProcess;
  71661. private _getDepthTexture;
  71662. private _disposePostProcesses;
  71663. /**
  71664. * Dispose of the pipeline and stop all post processes
  71665. */
  71666. dispose(): void;
  71667. /**
  71668. * Serialize the rendering pipeline (Used when exporting)
  71669. * @returns the serialized object
  71670. */
  71671. serialize(): any;
  71672. /**
  71673. * Parse the serialized pipeline
  71674. * @param source Source pipeline.
  71675. * @param scene The scene to load the pipeline to.
  71676. * @param rootUrl The URL of the serialized pipeline.
  71677. * @returns An instantiated pipeline from the serialized object.
  71678. */
  71679. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  71680. /**
  71681. * Luminance steps
  71682. */
  71683. static LuminanceSteps: number;
  71684. }
  71685. }
  71686. declare module BABYLON {
  71687. /** @hidden */
  71688. export var stereoscopicInterlacePixelShader: {
  71689. name: string;
  71690. shader: string;
  71691. };
  71692. }
  71693. declare module BABYLON {
  71694. /**
  71695. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  71696. */
  71697. export class StereoscopicInterlacePostProcessI extends PostProcess {
  71698. private _stepSize;
  71699. private _passedProcess;
  71700. /**
  71701. * Gets a string identifying the name of the class
  71702. * @returns "StereoscopicInterlacePostProcessI" string
  71703. */
  71704. getClassName(): string;
  71705. /**
  71706. * Initializes a StereoscopicInterlacePostProcessI
  71707. * @param name The name of the effect.
  71708. * @param rigCameras The rig cameras to be appled to the post process
  71709. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  71710. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  71711. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71712. * @param engine The engine which the post process will be applied. (default: current engine)
  71713. * @param reusable If the post process can be reused on the same frame. (default: false)
  71714. */
  71715. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71716. }
  71717. /**
  71718. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  71719. */
  71720. export class StereoscopicInterlacePostProcess extends PostProcess {
  71721. private _stepSize;
  71722. private _passedProcess;
  71723. /**
  71724. * Gets a string identifying the name of the class
  71725. * @returns "StereoscopicInterlacePostProcess" string
  71726. */
  71727. getClassName(): string;
  71728. /**
  71729. * Initializes a StereoscopicInterlacePostProcess
  71730. * @param name The name of the effect.
  71731. * @param rigCameras The rig cameras to be appled to the post process
  71732. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  71733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71734. * @param engine The engine which the post process will be applied. (default: current engine)
  71735. * @param reusable If the post process can be reused on the same frame. (default: false)
  71736. */
  71737. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71738. }
  71739. }
  71740. declare module BABYLON {
  71741. /** @hidden */
  71742. export var tonemapPixelShader: {
  71743. name: string;
  71744. shader: string;
  71745. };
  71746. }
  71747. declare module BABYLON {
  71748. /** Defines operator used for tonemapping */
  71749. export enum TonemappingOperator {
  71750. /** Hable */
  71751. Hable = 0,
  71752. /** Reinhard */
  71753. Reinhard = 1,
  71754. /** HejiDawson */
  71755. HejiDawson = 2,
  71756. /** Photographic */
  71757. Photographic = 3
  71758. }
  71759. /**
  71760. * Defines a post process to apply tone mapping
  71761. */
  71762. export class TonemapPostProcess extends PostProcess {
  71763. private _operator;
  71764. /** Defines the required exposure adjustement */
  71765. exposureAdjustment: number;
  71766. /**
  71767. * Gets a string identifying the name of the class
  71768. * @returns "TonemapPostProcess" string
  71769. */
  71770. getClassName(): string;
  71771. /**
  71772. * Creates a new TonemapPostProcess
  71773. * @param name defines the name of the postprocess
  71774. * @param _operator defines the operator to use
  71775. * @param exposureAdjustment defines the required exposure adjustement
  71776. * @param camera defines the camera to use (can be null)
  71777. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  71778. * @param engine defines the hosting engine (can be ignore if camera is set)
  71779. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71780. */
  71781. constructor(name: string, _operator: TonemappingOperator,
  71782. /** Defines the required exposure adjustement */
  71783. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  71784. }
  71785. }
  71786. declare module BABYLON {
  71787. /** @hidden */
  71788. export var volumetricLightScatteringPixelShader: {
  71789. name: string;
  71790. shader: string;
  71791. };
  71792. }
  71793. declare module BABYLON {
  71794. /** @hidden */
  71795. export var volumetricLightScatteringPassVertexShader: {
  71796. name: string;
  71797. shader: string;
  71798. };
  71799. }
  71800. declare module BABYLON {
  71801. /** @hidden */
  71802. export var volumetricLightScatteringPassPixelShader: {
  71803. name: string;
  71804. shader: string;
  71805. };
  71806. }
  71807. declare module BABYLON {
  71808. /**
  71809. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  71810. */
  71811. export class VolumetricLightScatteringPostProcess extends PostProcess {
  71812. private _volumetricLightScatteringPass;
  71813. private _volumetricLightScatteringRTT;
  71814. private _viewPort;
  71815. private _screenCoordinates;
  71816. private _cachedDefines;
  71817. /**
  71818. * If not undefined, the mesh position is computed from the attached node position
  71819. */
  71820. attachedNode: {
  71821. position: Vector3;
  71822. };
  71823. /**
  71824. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  71825. */
  71826. customMeshPosition: Vector3;
  71827. /**
  71828. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  71829. */
  71830. useCustomMeshPosition: boolean;
  71831. /**
  71832. * If the post-process should inverse the light scattering direction
  71833. */
  71834. invert: boolean;
  71835. /**
  71836. * The internal mesh used by the post-process
  71837. */
  71838. mesh: Mesh;
  71839. /**
  71840. * @hidden
  71841. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  71842. */
  71843. get useDiffuseColor(): boolean;
  71844. set useDiffuseColor(useDiffuseColor: boolean);
  71845. /**
  71846. * Array containing the excluded meshes not rendered in the internal pass
  71847. */
  71848. excludedMeshes: AbstractMesh[];
  71849. /**
  71850. * Controls the overall intensity of the post-process
  71851. */
  71852. exposure: number;
  71853. /**
  71854. * Dissipates each sample's contribution in range [0, 1]
  71855. */
  71856. decay: number;
  71857. /**
  71858. * Controls the overall intensity of each sample
  71859. */
  71860. weight: number;
  71861. /**
  71862. * Controls the density of each sample
  71863. */
  71864. density: number;
  71865. /**
  71866. * @constructor
  71867. * @param name The post-process name
  71868. * @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)
  71869. * @param camera The camera that the post-process will be attached to
  71870. * @param mesh The mesh used to create the light scattering
  71871. * @param samples The post-process quality, default 100
  71872. * @param samplingModeThe post-process filtering mode
  71873. * @param engine The babylon engine
  71874. * @param reusable If the post-process is reusable
  71875. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  71876. */
  71877. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  71878. /**
  71879. * Returns the string "VolumetricLightScatteringPostProcess"
  71880. * @returns "VolumetricLightScatteringPostProcess"
  71881. */
  71882. getClassName(): string;
  71883. private _isReady;
  71884. /**
  71885. * Sets the new light position for light scattering effect
  71886. * @param position The new custom light position
  71887. */
  71888. setCustomMeshPosition(position: Vector3): void;
  71889. /**
  71890. * Returns the light position for light scattering effect
  71891. * @return Vector3 The custom light position
  71892. */
  71893. getCustomMeshPosition(): Vector3;
  71894. /**
  71895. * Disposes the internal assets and detaches the post-process from the camera
  71896. */
  71897. dispose(camera: Camera): void;
  71898. /**
  71899. * Returns the render target texture used by the post-process
  71900. * @return the render target texture used by the post-process
  71901. */
  71902. getPass(): RenderTargetTexture;
  71903. private _meshExcluded;
  71904. private _createPass;
  71905. private _updateMeshScreenCoordinates;
  71906. /**
  71907. * Creates a default mesh for the Volumeric Light Scattering post-process
  71908. * @param name The mesh name
  71909. * @param scene The scene where to create the mesh
  71910. * @return the default mesh
  71911. */
  71912. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  71913. }
  71914. }
  71915. declare module BABYLON {
  71916. /** @hidden */
  71917. export var screenSpaceCurvaturePixelShader: {
  71918. name: string;
  71919. shader: string;
  71920. };
  71921. }
  71922. declare module BABYLON {
  71923. /**
  71924. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  71925. */
  71926. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  71927. /**
  71928. * Defines how much ridge the curvature effect displays.
  71929. */
  71930. ridge: number;
  71931. /**
  71932. * Defines how much valley the curvature effect displays.
  71933. */
  71934. valley: number;
  71935. private _geometryBufferRenderer;
  71936. /**
  71937. * Gets a string identifying the name of the class
  71938. * @returns "ScreenSpaceCurvaturePostProcess" string
  71939. */
  71940. getClassName(): string;
  71941. /**
  71942. * Creates a new instance ScreenSpaceCurvaturePostProcess
  71943. * @param name The name of the effect.
  71944. * @param scene The scene containing the objects to blur according to their velocity.
  71945. * @param options The required width/height ratio to downsize to before computing the render pass.
  71946. * @param camera The camera to apply the render pass to.
  71947. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71948. * @param engine The engine which the post process will be applied. (default: current engine)
  71949. * @param reusable If the post process can be reused on the same frame. (default: false)
  71950. * @param textureType Type of textures used when performing the post process. (default: 0)
  71951. * @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)
  71952. */
  71953. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71954. /**
  71955. * Support test.
  71956. */
  71957. static get IsSupported(): boolean;
  71958. /** @hidden */
  71959. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  71960. }
  71961. }
  71962. declare module BABYLON {
  71963. interface Scene {
  71964. /** @hidden (Backing field) */
  71965. _boundingBoxRenderer: BoundingBoxRenderer;
  71966. /** @hidden (Backing field) */
  71967. _forceShowBoundingBoxes: boolean;
  71968. /**
  71969. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  71970. */
  71971. forceShowBoundingBoxes: boolean;
  71972. /**
  71973. * Gets the bounding box renderer associated with the scene
  71974. * @returns a BoundingBoxRenderer
  71975. */
  71976. getBoundingBoxRenderer(): BoundingBoxRenderer;
  71977. }
  71978. interface AbstractMesh {
  71979. /** @hidden (Backing field) */
  71980. _showBoundingBox: boolean;
  71981. /**
  71982. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  71983. */
  71984. showBoundingBox: boolean;
  71985. }
  71986. /**
  71987. * Component responsible of rendering the bounding box of the meshes in a scene.
  71988. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  71989. */
  71990. export class BoundingBoxRenderer implements ISceneComponent {
  71991. /**
  71992. * The component name helpfull to identify the component in the list of scene components.
  71993. */
  71994. readonly name: string;
  71995. /**
  71996. * The scene the component belongs to.
  71997. */
  71998. scene: Scene;
  71999. /**
  72000. * Color of the bounding box lines placed in front of an object
  72001. */
  72002. frontColor: Color3;
  72003. /**
  72004. * Color of the bounding box lines placed behind an object
  72005. */
  72006. backColor: Color3;
  72007. /**
  72008. * Defines if the renderer should show the back lines or not
  72009. */
  72010. showBackLines: boolean;
  72011. /**
  72012. * Observable raised before rendering a bounding box
  72013. */
  72014. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  72015. /**
  72016. * Observable raised after rendering a bounding box
  72017. */
  72018. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  72019. /**
  72020. * @hidden
  72021. */
  72022. renderList: SmartArray<BoundingBox>;
  72023. private _colorShader;
  72024. private _vertexBuffers;
  72025. private _indexBuffer;
  72026. private _fillIndexBuffer;
  72027. private _fillIndexData;
  72028. /**
  72029. * Instantiates a new bounding box renderer in a scene.
  72030. * @param scene the scene the renderer renders in
  72031. */
  72032. constructor(scene: Scene);
  72033. /**
  72034. * Registers the component in a given scene
  72035. */
  72036. register(): void;
  72037. private _evaluateSubMesh;
  72038. private _activeMesh;
  72039. private _prepareRessources;
  72040. private _createIndexBuffer;
  72041. /**
  72042. * Rebuilds the elements related to this component in case of
  72043. * context lost for instance.
  72044. */
  72045. rebuild(): void;
  72046. /**
  72047. * @hidden
  72048. */
  72049. reset(): void;
  72050. /**
  72051. * Render the bounding boxes of a specific rendering group
  72052. * @param renderingGroupId defines the rendering group to render
  72053. */
  72054. render(renderingGroupId: number): void;
  72055. /**
  72056. * In case of occlusion queries, we can render the occlusion bounding box through this method
  72057. * @param mesh Define the mesh to render the occlusion bounding box for
  72058. */
  72059. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72060. /**
  72061. * Dispose and release the resources attached to this renderer.
  72062. */
  72063. dispose(): void;
  72064. }
  72065. }
  72066. declare module BABYLON {
  72067. interface Scene {
  72068. /** @hidden (Backing field) */
  72069. _depthRenderer: {
  72070. [id: string]: DepthRenderer;
  72071. };
  72072. /**
  72073. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72074. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72075. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72076. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  72077. * @returns the created depth renderer
  72078. */
  72079. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  72080. /**
  72081. * Disables a depth renderer for a given camera
  72082. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72083. */
  72084. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72085. }
  72086. /**
  72087. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72088. * in several rendering techniques.
  72089. */
  72090. export class DepthRendererSceneComponent implements ISceneComponent {
  72091. /**
  72092. * The component name helpfull to identify the component in the list of scene components.
  72093. */
  72094. readonly name: string;
  72095. /**
  72096. * The scene the component belongs to.
  72097. */
  72098. scene: Scene;
  72099. /**
  72100. * Creates a new instance of the component for the given scene
  72101. * @param scene Defines the scene to register the component in
  72102. */
  72103. constructor(scene: Scene);
  72104. /**
  72105. * Registers the component in a given scene
  72106. */
  72107. register(): void;
  72108. /**
  72109. * Rebuilds the elements related to this component in case of
  72110. * context lost for instance.
  72111. */
  72112. rebuild(): void;
  72113. /**
  72114. * Disposes the component and the associated ressources
  72115. */
  72116. dispose(): void;
  72117. private _gatherRenderTargets;
  72118. private _gatherActiveCameraRenderTargets;
  72119. }
  72120. }
  72121. declare module BABYLON {
  72122. interface AbstractScene {
  72123. /** @hidden (Backing field) */
  72124. _prePassRenderer: Nullable<PrePassRenderer>;
  72125. /**
  72126. * Gets or Sets the current prepass renderer associated to the scene.
  72127. */
  72128. prePassRenderer: Nullable<PrePassRenderer>;
  72129. /**
  72130. * Enables the prepass and associates it with the scene
  72131. * @returns the PrePassRenderer
  72132. */
  72133. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  72134. /**
  72135. * Disables the prepass associated with the scene
  72136. */
  72137. disablePrePassRenderer(): void;
  72138. }
  72139. /**
  72140. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72141. * in several rendering techniques.
  72142. */
  72143. export class PrePassRendererSceneComponent implements ISceneComponent {
  72144. /**
  72145. * The component name helpful to identify the component in the list of scene components.
  72146. */
  72147. readonly name: string;
  72148. /**
  72149. * The scene the component belongs to.
  72150. */
  72151. scene: Scene;
  72152. /**
  72153. * Creates a new instance of the component for the given scene
  72154. * @param scene Defines the scene to register the component in
  72155. */
  72156. constructor(scene: Scene);
  72157. /**
  72158. * Registers the component in a given scene
  72159. */
  72160. register(): void;
  72161. private _beforeCameraDraw;
  72162. private _afterCameraDraw;
  72163. private _beforeClearStage;
  72164. /**
  72165. * Rebuilds the elements related to this component in case of
  72166. * context lost for instance.
  72167. */
  72168. rebuild(): void;
  72169. /**
  72170. * Disposes the component and the associated ressources
  72171. */
  72172. dispose(): void;
  72173. }
  72174. }
  72175. declare module BABYLON {
  72176. /** @hidden */
  72177. export var fibonacci: {
  72178. name: string;
  72179. shader: string;
  72180. };
  72181. }
  72182. declare module BABYLON {
  72183. /** @hidden */
  72184. export var diffusionProfile: {
  72185. name: string;
  72186. shader: string;
  72187. };
  72188. }
  72189. declare module BABYLON {
  72190. /** @hidden */
  72191. export var subSurfaceScatteringPixelShader: {
  72192. name: string;
  72193. shader: string;
  72194. };
  72195. }
  72196. declare module BABYLON {
  72197. /**
  72198. * Sub surface scattering post process
  72199. */
  72200. export class SubSurfaceScatteringPostProcess extends PostProcess {
  72201. /**
  72202. * Gets a string identifying the name of the class
  72203. * @returns "SubSurfaceScatteringPostProcess" string
  72204. */
  72205. getClassName(): string;
  72206. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72207. }
  72208. }
  72209. declare module BABYLON {
  72210. /**
  72211. * Contains all parameters needed for the prepass to perform
  72212. * screen space subsurface scattering
  72213. */
  72214. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  72215. /** @hidden */
  72216. static _SceneComponentInitialization: (scene: Scene) => void;
  72217. private _ssDiffusionS;
  72218. private _ssFilterRadii;
  72219. private _ssDiffusionD;
  72220. /**
  72221. * Post process to attach for screen space subsurface scattering
  72222. */
  72223. postProcess: SubSurfaceScatteringPostProcess;
  72224. /**
  72225. * Diffusion profile color for subsurface scattering
  72226. */
  72227. get ssDiffusionS(): number[];
  72228. /**
  72229. * Diffusion profile max color channel value for subsurface scattering
  72230. */
  72231. get ssDiffusionD(): number[];
  72232. /**
  72233. * Diffusion profile filter radius for subsurface scattering
  72234. */
  72235. get ssFilterRadii(): number[];
  72236. /**
  72237. * Is subsurface enabled
  72238. */
  72239. enabled: boolean;
  72240. /**
  72241. * Name of the configuration
  72242. */
  72243. name: string;
  72244. /**
  72245. * Diffusion profile colors for subsurface scattering
  72246. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  72247. * See ...
  72248. * Note that you can only store up to 5 of them
  72249. */
  72250. ssDiffusionProfileColors: Color3[];
  72251. /**
  72252. * Defines the ratio real world => scene units.
  72253. * Used for subsurface scattering
  72254. */
  72255. metersPerUnit: number;
  72256. /**
  72257. * Textures that should be present in the MRT for this effect to work
  72258. */
  72259. readonly texturesRequired: number[];
  72260. private _scene;
  72261. /**
  72262. * Builds a subsurface configuration object
  72263. * @param scene The scene
  72264. */
  72265. constructor(scene: Scene);
  72266. /**
  72267. * Adds a new diffusion profile.
  72268. * Useful for more realistic subsurface scattering on diverse materials.
  72269. * @param color The color of the diffusion profile. Should be the average color of the material.
  72270. * @return The index of the diffusion profile for the material subsurface configuration
  72271. */
  72272. addDiffusionProfile(color: Color3): number;
  72273. /**
  72274. * Creates the sss post process
  72275. * @return The created post process
  72276. */
  72277. createPostProcess(): SubSurfaceScatteringPostProcess;
  72278. /**
  72279. * Deletes all diffusion profiles.
  72280. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  72281. */
  72282. clearAllDiffusionProfiles(): void;
  72283. /**
  72284. * Disposes this object
  72285. */
  72286. dispose(): void;
  72287. /**
  72288. * @hidden
  72289. * https://zero-radiance.github.io/post/sampling-diffusion/
  72290. *
  72291. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  72292. * ------------------------------------------------------------------------------------
  72293. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  72294. * PDF[r, phi, s] = r * R[r, phi, s]
  72295. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  72296. * ------------------------------------------------------------------------------------
  72297. * We importance sample the color channel with the widest scattering distance.
  72298. */
  72299. getDiffusionProfileParameters(color: Color3): number;
  72300. /**
  72301. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  72302. * 'u' is the random number (the value of the CDF): [0, 1).
  72303. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  72304. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  72305. */
  72306. private _sampleBurleyDiffusionProfile;
  72307. }
  72308. }
  72309. declare module BABYLON {
  72310. interface AbstractScene {
  72311. /** @hidden (Backing field) */
  72312. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  72313. /**
  72314. * Gets or Sets the current prepass renderer associated to the scene.
  72315. */
  72316. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  72317. /**
  72318. * Enables the subsurface effect for prepass
  72319. * @returns the SubSurfaceConfiguration
  72320. */
  72321. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  72322. /**
  72323. * Disables the subsurface effect for prepass
  72324. */
  72325. disableSubSurfaceForPrePass(): void;
  72326. }
  72327. /**
  72328. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72329. * in several rendering techniques.
  72330. */
  72331. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  72332. /**
  72333. * The component name helpful to identify the component in the list of scene components.
  72334. */
  72335. readonly name: string;
  72336. /**
  72337. * The scene the component belongs to.
  72338. */
  72339. scene: Scene;
  72340. /**
  72341. * Creates a new instance of the component for the given scene
  72342. * @param scene Defines the scene to register the component in
  72343. */
  72344. constructor(scene: Scene);
  72345. /**
  72346. * Registers the component in a given scene
  72347. */
  72348. register(): void;
  72349. /**
  72350. * Serializes the component data to the specified json object
  72351. * @param serializationObject The object to serialize to
  72352. */
  72353. serialize(serializationObject: any): void;
  72354. /**
  72355. * Adds all the elements from the container to the scene
  72356. * @param container the container holding the elements
  72357. */
  72358. addFromContainer(container: AbstractScene): void;
  72359. /**
  72360. * Removes all the elements in the container from the scene
  72361. * @param container contains the elements to remove
  72362. * @param dispose if the removed element should be disposed (default: false)
  72363. */
  72364. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  72365. /**
  72366. * Rebuilds the elements related to this component in case of
  72367. * context lost for instance.
  72368. */
  72369. rebuild(): void;
  72370. /**
  72371. * Disposes the component and the associated ressources
  72372. */
  72373. dispose(): void;
  72374. }
  72375. }
  72376. declare module BABYLON {
  72377. /** @hidden */
  72378. export var outlinePixelShader: {
  72379. name: string;
  72380. shader: string;
  72381. };
  72382. }
  72383. declare module BABYLON {
  72384. /** @hidden */
  72385. export var outlineVertexShader: {
  72386. name: string;
  72387. shader: string;
  72388. };
  72389. }
  72390. declare module BABYLON {
  72391. interface Scene {
  72392. /** @hidden */
  72393. _outlineRenderer: OutlineRenderer;
  72394. /**
  72395. * Gets the outline renderer associated with the scene
  72396. * @returns a OutlineRenderer
  72397. */
  72398. getOutlineRenderer(): OutlineRenderer;
  72399. }
  72400. interface AbstractMesh {
  72401. /** @hidden (Backing field) */
  72402. _renderOutline: boolean;
  72403. /**
  72404. * Gets or sets a boolean indicating if the outline must be rendered as well
  72405. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  72406. */
  72407. renderOutline: boolean;
  72408. /** @hidden (Backing field) */
  72409. _renderOverlay: boolean;
  72410. /**
  72411. * Gets or sets a boolean indicating if the overlay must be rendered as well
  72412. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  72413. */
  72414. renderOverlay: boolean;
  72415. }
  72416. /**
  72417. * This class is responsible to draw bothe outline/overlay of meshes.
  72418. * It should not be used directly but through the available method on mesh.
  72419. */
  72420. export class OutlineRenderer implements ISceneComponent {
  72421. /**
  72422. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  72423. */
  72424. private static _StencilReference;
  72425. /**
  72426. * The name of the component. Each component must have a unique name.
  72427. */
  72428. name: string;
  72429. /**
  72430. * The scene the component belongs to.
  72431. */
  72432. scene: Scene;
  72433. /**
  72434. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  72435. */
  72436. zOffset: number;
  72437. private _engine;
  72438. private _effect;
  72439. private _cachedDefines;
  72440. private _savedDepthWrite;
  72441. /**
  72442. * Instantiates a new outline renderer. (There could be only one per scene).
  72443. * @param scene Defines the scene it belongs to
  72444. */
  72445. constructor(scene: Scene);
  72446. /**
  72447. * Register the component to one instance of a scene.
  72448. */
  72449. register(): void;
  72450. /**
  72451. * Rebuilds the elements related to this component in case of
  72452. * context lost for instance.
  72453. */
  72454. rebuild(): void;
  72455. /**
  72456. * Disposes the component and the associated ressources.
  72457. */
  72458. dispose(): void;
  72459. /**
  72460. * Renders the outline in the canvas.
  72461. * @param subMesh Defines the sumesh to render
  72462. * @param batch Defines the batch of meshes in case of instances
  72463. * @param useOverlay Defines if the rendering is for the overlay or the outline
  72464. */
  72465. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  72466. /**
  72467. * Returns whether or not the outline renderer is ready for a given submesh.
  72468. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  72469. * @param subMesh Defines the submesh to check readyness for
  72470. * @param useInstances Defines wheter wee are trying to render instances or not
  72471. * @returns true if ready otherwise false
  72472. */
  72473. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72474. private _beforeRenderingMesh;
  72475. private _afterRenderingMesh;
  72476. }
  72477. }
  72478. declare module BABYLON {
  72479. /**
  72480. * Defines the basic options interface of a Sprite Frame Source Size.
  72481. */
  72482. export interface ISpriteJSONSpriteSourceSize {
  72483. /**
  72484. * number of the original width of the Frame
  72485. */
  72486. w: number;
  72487. /**
  72488. * number of the original height of the Frame
  72489. */
  72490. h: number;
  72491. }
  72492. /**
  72493. * Defines the basic options interface of a Sprite Frame Data.
  72494. */
  72495. export interface ISpriteJSONSpriteFrameData {
  72496. /**
  72497. * number of the x offset of the Frame
  72498. */
  72499. x: number;
  72500. /**
  72501. * number of the y offset of the Frame
  72502. */
  72503. y: number;
  72504. /**
  72505. * number of the width of the Frame
  72506. */
  72507. w: number;
  72508. /**
  72509. * number of the height of the Frame
  72510. */
  72511. h: number;
  72512. }
  72513. /**
  72514. * Defines the basic options interface of a JSON Sprite.
  72515. */
  72516. export interface ISpriteJSONSprite {
  72517. /**
  72518. * string name of the Frame
  72519. */
  72520. filename: string;
  72521. /**
  72522. * ISpriteJSONSpriteFrame basic object of the frame data
  72523. */
  72524. frame: ISpriteJSONSpriteFrameData;
  72525. /**
  72526. * boolean to flag is the frame was rotated.
  72527. */
  72528. rotated: boolean;
  72529. /**
  72530. * boolean to flag is the frame was trimmed.
  72531. */
  72532. trimmed: boolean;
  72533. /**
  72534. * ISpriteJSONSpriteFrame basic object of the source data
  72535. */
  72536. spriteSourceSize: ISpriteJSONSpriteFrameData;
  72537. /**
  72538. * ISpriteJSONSpriteFrame basic object of the source data
  72539. */
  72540. sourceSize: ISpriteJSONSpriteSourceSize;
  72541. }
  72542. /**
  72543. * Defines the basic options interface of a JSON atlas.
  72544. */
  72545. export interface ISpriteJSONAtlas {
  72546. /**
  72547. * Array of objects that contain the frame data.
  72548. */
  72549. frames: Array<ISpriteJSONSprite>;
  72550. /**
  72551. * object basic object containing the sprite meta data.
  72552. */
  72553. meta?: object;
  72554. }
  72555. }
  72556. declare module BABYLON {
  72557. /** @hidden */
  72558. export var spriteMapPixelShader: {
  72559. name: string;
  72560. shader: string;
  72561. };
  72562. }
  72563. declare module BABYLON {
  72564. /** @hidden */
  72565. export var spriteMapVertexShader: {
  72566. name: string;
  72567. shader: string;
  72568. };
  72569. }
  72570. declare module BABYLON {
  72571. /**
  72572. * Defines the basic options interface of a SpriteMap
  72573. */
  72574. export interface ISpriteMapOptions {
  72575. /**
  72576. * Vector2 of the number of cells in the grid.
  72577. */
  72578. stageSize?: Vector2;
  72579. /**
  72580. * Vector2 of the size of the output plane in World Units.
  72581. */
  72582. outputSize?: Vector2;
  72583. /**
  72584. * Vector3 of the position of the output plane in World Units.
  72585. */
  72586. outputPosition?: Vector3;
  72587. /**
  72588. * Vector3 of the rotation of the output plane.
  72589. */
  72590. outputRotation?: Vector3;
  72591. /**
  72592. * number of layers that the system will reserve in resources.
  72593. */
  72594. layerCount?: number;
  72595. /**
  72596. * number of max animation frames a single cell will reserve in resources.
  72597. */
  72598. maxAnimationFrames?: number;
  72599. /**
  72600. * number cell index of the base tile when the system compiles.
  72601. */
  72602. baseTile?: number;
  72603. /**
  72604. * boolean flip the sprite after its been repositioned by the framing data.
  72605. */
  72606. flipU?: boolean;
  72607. /**
  72608. * Vector3 scalar of the global RGB values of the SpriteMap.
  72609. */
  72610. colorMultiply?: Vector3;
  72611. }
  72612. /**
  72613. * Defines the IDisposable interface in order to be cleanable from resources.
  72614. */
  72615. export interface ISpriteMap extends IDisposable {
  72616. /**
  72617. * String name of the SpriteMap.
  72618. */
  72619. name: string;
  72620. /**
  72621. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  72622. */
  72623. atlasJSON: ISpriteJSONAtlas;
  72624. /**
  72625. * Texture of the SpriteMap.
  72626. */
  72627. spriteSheet: Texture;
  72628. /**
  72629. * The parameters to initialize the SpriteMap with.
  72630. */
  72631. options: ISpriteMapOptions;
  72632. }
  72633. /**
  72634. * Class used to manage a grid restricted sprite deployment on an Output plane.
  72635. */
  72636. export class SpriteMap implements ISpriteMap {
  72637. /** The Name of the spriteMap */
  72638. name: string;
  72639. /** The JSON file with the frame and meta data */
  72640. atlasJSON: ISpriteJSONAtlas;
  72641. /** The systems Sprite Sheet Texture */
  72642. spriteSheet: Texture;
  72643. /** Arguments passed with the Constructor */
  72644. options: ISpriteMapOptions;
  72645. /** Public Sprite Storage array, parsed from atlasJSON */
  72646. sprites: Array<ISpriteJSONSprite>;
  72647. /** Returns the Number of Sprites in the System */
  72648. get spriteCount(): number;
  72649. /** Returns the Position of Output Plane*/
  72650. get position(): Vector3;
  72651. /** Returns the Position of Output Plane*/
  72652. set position(v: Vector3);
  72653. /** Returns the Rotation of Output Plane*/
  72654. get rotation(): Vector3;
  72655. /** Returns the Rotation of Output Plane*/
  72656. set rotation(v: Vector3);
  72657. /** Sets the AnimationMap*/
  72658. get animationMap(): RawTexture;
  72659. /** Sets the AnimationMap*/
  72660. set animationMap(v: RawTexture);
  72661. /** Scene that the SpriteMap was created in */
  72662. private _scene;
  72663. /** Texture Buffer of Float32 that holds tile frame data*/
  72664. private _frameMap;
  72665. /** Texture Buffers of Float32 that holds tileMap data*/
  72666. private _tileMaps;
  72667. /** Texture Buffer of Float32 that holds Animation Data*/
  72668. private _animationMap;
  72669. /** Custom ShaderMaterial Central to the System*/
  72670. private _material;
  72671. /** Custom ShaderMaterial Central to the System*/
  72672. private _output;
  72673. /** Systems Time Ticker*/
  72674. private _time;
  72675. /**
  72676. * Creates a new SpriteMap
  72677. * @param name defines the SpriteMaps Name
  72678. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  72679. * @param spriteSheet is the Texture that the Sprites are on.
  72680. * @param options a basic deployment configuration
  72681. * @param scene The Scene that the map is deployed on
  72682. */
  72683. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  72684. /**
  72685. * Returns tileID location
  72686. * @returns Vector2 the cell position ID
  72687. */
  72688. getTileID(): Vector2;
  72689. /**
  72690. * Gets the UV location of the mouse over the SpriteMap.
  72691. * @returns Vector2 the UV position of the mouse interaction
  72692. */
  72693. getMousePosition(): Vector2;
  72694. /**
  72695. * Creates the "frame" texture Buffer
  72696. * -------------------------------------
  72697. * Structure of frames
  72698. * "filename": "Falling-Water-2.png",
  72699. * "frame": {"x":69,"y":103,"w":24,"h":32},
  72700. * "rotated": true,
  72701. * "trimmed": true,
  72702. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  72703. * "sourceSize": {"w":32,"h":32}
  72704. * @returns RawTexture of the frameMap
  72705. */
  72706. private _createFrameBuffer;
  72707. /**
  72708. * Creates the tileMap texture Buffer
  72709. * @param buffer normally and array of numbers, or a false to generate from scratch
  72710. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  72711. * @returns RawTexture of the tileMap
  72712. */
  72713. private _createTileBuffer;
  72714. /**
  72715. * Modifies the data of the tileMaps
  72716. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  72717. * @param pos is the iVector2 Coordinates of the Tile
  72718. * @param tile The SpriteIndex of the new Tile
  72719. */
  72720. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  72721. /**
  72722. * Creates the animationMap texture Buffer
  72723. * @param buffer normally and array of numbers, or a false to generate from scratch
  72724. * @returns RawTexture of the animationMap
  72725. */
  72726. private _createTileAnimationBuffer;
  72727. /**
  72728. * Modifies the data of the animationMap
  72729. * @param cellID is the Index of the Sprite
  72730. * @param _frame is the target Animation frame
  72731. * @param toCell is the Target Index of the next frame of the animation
  72732. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  72733. * @param speed is a global scalar of the time variable on the map.
  72734. */
  72735. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  72736. /**
  72737. * Exports the .tilemaps file
  72738. */
  72739. saveTileMaps(): void;
  72740. /**
  72741. * Imports the .tilemaps file
  72742. * @param url of the .tilemaps file
  72743. */
  72744. loadTileMaps(url: string): void;
  72745. /**
  72746. * Release associated resources
  72747. */
  72748. dispose(): void;
  72749. }
  72750. }
  72751. declare module BABYLON {
  72752. /**
  72753. * Class used to manage multiple sprites of different sizes on the same spritesheet
  72754. * @see https://doc.babylonjs.com/babylon101/sprites
  72755. */
  72756. export class SpritePackedManager extends SpriteManager {
  72757. /** defines the packed manager's name */
  72758. name: string;
  72759. /**
  72760. * Creates a new sprite manager from a packed sprite sheet
  72761. * @param name defines the manager's name
  72762. * @param imgUrl defines the sprite sheet url
  72763. * @param capacity defines the maximum allowed number of sprites
  72764. * @param scene defines the hosting scene
  72765. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  72766. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  72767. * @param samplingMode defines the smapling mode to use with spritesheet
  72768. * @param fromPacked set to true; do not alter
  72769. */
  72770. constructor(
  72771. /** defines the packed manager's name */
  72772. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  72773. }
  72774. }
  72775. declare module BABYLON {
  72776. /**
  72777. * Defines the list of states available for a task inside a AssetsManager
  72778. */
  72779. export enum AssetTaskState {
  72780. /**
  72781. * Initialization
  72782. */
  72783. INIT = 0,
  72784. /**
  72785. * Running
  72786. */
  72787. RUNNING = 1,
  72788. /**
  72789. * Done
  72790. */
  72791. DONE = 2,
  72792. /**
  72793. * Error
  72794. */
  72795. ERROR = 3
  72796. }
  72797. /**
  72798. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  72799. */
  72800. export abstract class AbstractAssetTask {
  72801. /**
  72802. * Task name
  72803. */ name: string;
  72804. /**
  72805. * Callback called when the task is successful
  72806. */
  72807. onSuccess: (task: any) => void;
  72808. /**
  72809. * Callback called when the task is not successful
  72810. */
  72811. onError: (task: any, message?: string, exception?: any) => void;
  72812. /**
  72813. * Creates a new AssetsManager
  72814. * @param name defines the name of the task
  72815. */
  72816. constructor(
  72817. /**
  72818. * Task name
  72819. */ name: string);
  72820. private _isCompleted;
  72821. private _taskState;
  72822. private _errorObject;
  72823. /**
  72824. * Get if the task is completed
  72825. */
  72826. get isCompleted(): boolean;
  72827. /**
  72828. * Gets the current state of the task
  72829. */
  72830. get taskState(): AssetTaskState;
  72831. /**
  72832. * Gets the current error object (if task is in error)
  72833. */
  72834. get errorObject(): {
  72835. message?: string;
  72836. exception?: any;
  72837. };
  72838. /**
  72839. * Internal only
  72840. * @hidden
  72841. */
  72842. _setErrorObject(message?: string, exception?: any): void;
  72843. /**
  72844. * Execute the current task
  72845. * @param scene defines the scene where you want your assets to be loaded
  72846. * @param onSuccess is a callback called when the task is successfully executed
  72847. * @param onError is a callback called if an error occurs
  72848. */
  72849. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72850. /**
  72851. * Execute the current task
  72852. * @param scene defines the scene where you want your assets to be loaded
  72853. * @param onSuccess is a callback called when the task is successfully executed
  72854. * @param onError is a callback called if an error occurs
  72855. */
  72856. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72857. /**
  72858. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  72859. * This can be used with failed tasks that have the reason for failure fixed.
  72860. */
  72861. reset(): void;
  72862. private onErrorCallback;
  72863. private onDoneCallback;
  72864. }
  72865. /**
  72866. * Define the interface used by progress events raised during assets loading
  72867. */
  72868. export interface IAssetsProgressEvent {
  72869. /**
  72870. * Defines the number of remaining tasks to process
  72871. */
  72872. remainingCount: number;
  72873. /**
  72874. * Defines the total number of tasks
  72875. */
  72876. totalCount: number;
  72877. /**
  72878. * Defines the task that was just processed
  72879. */
  72880. task: AbstractAssetTask;
  72881. }
  72882. /**
  72883. * Class used to share progress information about assets loading
  72884. */
  72885. export class AssetsProgressEvent implements IAssetsProgressEvent {
  72886. /**
  72887. * Defines the number of remaining tasks to process
  72888. */
  72889. remainingCount: number;
  72890. /**
  72891. * Defines the total number of tasks
  72892. */
  72893. totalCount: number;
  72894. /**
  72895. * Defines the task that was just processed
  72896. */
  72897. task: AbstractAssetTask;
  72898. /**
  72899. * Creates a AssetsProgressEvent
  72900. * @param remainingCount defines the number of remaining tasks to process
  72901. * @param totalCount defines the total number of tasks
  72902. * @param task defines the task that was just processed
  72903. */
  72904. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  72905. }
  72906. /**
  72907. * Define a task used by AssetsManager to load assets into a container
  72908. */
  72909. export class ContainerAssetTask extends AbstractAssetTask {
  72910. /**
  72911. * Defines the name of the task
  72912. */
  72913. name: string;
  72914. /**
  72915. * Defines the list of mesh's names you want to load
  72916. */
  72917. meshesNames: any;
  72918. /**
  72919. * Defines the root url to use as a base to load your meshes and associated resources
  72920. */
  72921. rootUrl: string;
  72922. /**
  72923. * Defines the filename or File of the scene to load from
  72924. */
  72925. sceneFilename: string | File;
  72926. /**
  72927. * Get the loaded asset container
  72928. */
  72929. loadedContainer: AssetContainer;
  72930. /**
  72931. * Gets the list of loaded meshes
  72932. */
  72933. loadedMeshes: Array<AbstractMesh>;
  72934. /**
  72935. * Gets the list of loaded particle systems
  72936. */
  72937. loadedParticleSystems: Array<IParticleSystem>;
  72938. /**
  72939. * Gets the list of loaded skeletons
  72940. */
  72941. loadedSkeletons: Array<Skeleton>;
  72942. /**
  72943. * Gets the list of loaded animation groups
  72944. */
  72945. loadedAnimationGroups: Array<AnimationGroup>;
  72946. /**
  72947. * Callback called when the task is successful
  72948. */
  72949. onSuccess: (task: ContainerAssetTask) => void;
  72950. /**
  72951. * Callback called when the task is successful
  72952. */
  72953. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  72954. /**
  72955. * Creates a new ContainerAssetTask
  72956. * @param name defines the name of the task
  72957. * @param meshesNames defines the list of mesh's names you want to load
  72958. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72959. * @param sceneFilename defines the filename or File of the scene to load from
  72960. */
  72961. constructor(
  72962. /**
  72963. * Defines the name of the task
  72964. */
  72965. name: string,
  72966. /**
  72967. * Defines the list of mesh's names you want to load
  72968. */
  72969. meshesNames: any,
  72970. /**
  72971. * Defines the root url to use as a base to load your meshes and associated resources
  72972. */
  72973. rootUrl: string,
  72974. /**
  72975. * Defines the filename or File of the scene to load from
  72976. */
  72977. sceneFilename: string | File);
  72978. /**
  72979. * Execute the current task
  72980. * @param scene defines the scene where you want your assets to be loaded
  72981. * @param onSuccess is a callback called when the task is successfully executed
  72982. * @param onError is a callback called if an error occurs
  72983. */
  72984. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72985. }
  72986. /**
  72987. * Define a task used by AssetsManager to load meshes
  72988. */
  72989. export class MeshAssetTask extends AbstractAssetTask {
  72990. /**
  72991. * Defines the name of the task
  72992. */
  72993. name: string;
  72994. /**
  72995. * Defines the list of mesh's names you want to load
  72996. */
  72997. meshesNames: any;
  72998. /**
  72999. * Defines the root url to use as a base to load your meshes and associated resources
  73000. */
  73001. rootUrl: string;
  73002. /**
  73003. * Defines the filename or File of the scene to load from
  73004. */
  73005. sceneFilename: string | File;
  73006. /**
  73007. * Gets the list of loaded meshes
  73008. */
  73009. loadedMeshes: Array<AbstractMesh>;
  73010. /**
  73011. * Gets the list of loaded particle systems
  73012. */
  73013. loadedParticleSystems: Array<IParticleSystem>;
  73014. /**
  73015. * Gets the list of loaded skeletons
  73016. */
  73017. loadedSkeletons: Array<Skeleton>;
  73018. /**
  73019. * Gets the list of loaded animation groups
  73020. */
  73021. loadedAnimationGroups: Array<AnimationGroup>;
  73022. /**
  73023. * Callback called when the task is successful
  73024. */
  73025. onSuccess: (task: MeshAssetTask) => void;
  73026. /**
  73027. * Callback called when the task is successful
  73028. */
  73029. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  73030. /**
  73031. * Creates a new MeshAssetTask
  73032. * @param name defines the name of the task
  73033. * @param meshesNames defines the list of mesh's names you want to load
  73034. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73035. * @param sceneFilename defines the filename or File of the scene to load from
  73036. */
  73037. constructor(
  73038. /**
  73039. * Defines the name of the task
  73040. */
  73041. name: string,
  73042. /**
  73043. * Defines the list of mesh's names you want to load
  73044. */
  73045. meshesNames: any,
  73046. /**
  73047. * Defines the root url to use as a base to load your meshes and associated resources
  73048. */
  73049. rootUrl: string,
  73050. /**
  73051. * Defines the filename or File of the scene to load from
  73052. */
  73053. sceneFilename: string | File);
  73054. /**
  73055. * Execute the current task
  73056. * @param scene defines the scene where you want your assets to be loaded
  73057. * @param onSuccess is a callback called when the task is successfully executed
  73058. * @param onError is a callback called if an error occurs
  73059. */
  73060. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73061. }
  73062. /**
  73063. * Define a task used by AssetsManager to load text content
  73064. */
  73065. export class TextFileAssetTask extends AbstractAssetTask {
  73066. /**
  73067. * Defines the name of the task
  73068. */
  73069. name: string;
  73070. /**
  73071. * Defines the location of the file to load
  73072. */
  73073. url: string;
  73074. /**
  73075. * Gets the loaded text string
  73076. */
  73077. text: string;
  73078. /**
  73079. * Callback called when the task is successful
  73080. */
  73081. onSuccess: (task: TextFileAssetTask) => void;
  73082. /**
  73083. * Callback called when the task is successful
  73084. */
  73085. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  73086. /**
  73087. * Creates a new TextFileAssetTask object
  73088. * @param name defines the name of the task
  73089. * @param url defines the location of the file to load
  73090. */
  73091. constructor(
  73092. /**
  73093. * Defines the name of the task
  73094. */
  73095. name: string,
  73096. /**
  73097. * Defines the location of the file to load
  73098. */
  73099. url: string);
  73100. /**
  73101. * Execute the current task
  73102. * @param scene defines the scene where you want your assets to be loaded
  73103. * @param onSuccess is a callback called when the task is successfully executed
  73104. * @param onError is a callback called if an error occurs
  73105. */
  73106. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73107. }
  73108. /**
  73109. * Define a task used by AssetsManager to load binary data
  73110. */
  73111. export class BinaryFileAssetTask extends AbstractAssetTask {
  73112. /**
  73113. * Defines the name of the task
  73114. */
  73115. name: string;
  73116. /**
  73117. * Defines the location of the file to load
  73118. */
  73119. url: string;
  73120. /**
  73121. * Gets the lodaded data (as an array buffer)
  73122. */
  73123. data: ArrayBuffer;
  73124. /**
  73125. * Callback called when the task is successful
  73126. */
  73127. onSuccess: (task: BinaryFileAssetTask) => void;
  73128. /**
  73129. * Callback called when the task is successful
  73130. */
  73131. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  73132. /**
  73133. * Creates a new BinaryFileAssetTask object
  73134. * @param name defines the name of the new task
  73135. * @param url defines the location of the file to load
  73136. */
  73137. constructor(
  73138. /**
  73139. * Defines the name of the task
  73140. */
  73141. name: string,
  73142. /**
  73143. * Defines the location of the file to load
  73144. */
  73145. url: string);
  73146. /**
  73147. * Execute the current task
  73148. * @param scene defines the scene where you want your assets to be loaded
  73149. * @param onSuccess is a callback called when the task is successfully executed
  73150. * @param onError is a callback called if an error occurs
  73151. */
  73152. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73153. }
  73154. /**
  73155. * Define a task used by AssetsManager to load images
  73156. */
  73157. export class ImageAssetTask extends AbstractAssetTask {
  73158. /**
  73159. * Defines the name of the task
  73160. */
  73161. name: string;
  73162. /**
  73163. * Defines the location of the image to load
  73164. */
  73165. url: string;
  73166. /**
  73167. * Gets the loaded images
  73168. */
  73169. image: HTMLImageElement;
  73170. /**
  73171. * Callback called when the task is successful
  73172. */
  73173. onSuccess: (task: ImageAssetTask) => void;
  73174. /**
  73175. * Callback called when the task is successful
  73176. */
  73177. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  73178. /**
  73179. * Creates a new ImageAssetTask
  73180. * @param name defines the name of the task
  73181. * @param url defines the location of the image to load
  73182. */
  73183. constructor(
  73184. /**
  73185. * Defines the name of the task
  73186. */
  73187. name: string,
  73188. /**
  73189. * Defines the location of the image to load
  73190. */
  73191. url: string);
  73192. /**
  73193. * Execute the current task
  73194. * @param scene defines the scene where you want your assets to be loaded
  73195. * @param onSuccess is a callback called when the task is successfully executed
  73196. * @param onError is a callback called if an error occurs
  73197. */
  73198. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73199. }
  73200. /**
  73201. * Defines the interface used by texture loading tasks
  73202. */
  73203. export interface ITextureAssetTask<TEX extends BaseTexture> {
  73204. /**
  73205. * Gets the loaded texture
  73206. */
  73207. texture: TEX;
  73208. }
  73209. /**
  73210. * Define a task used by AssetsManager to load 2D textures
  73211. */
  73212. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  73213. /**
  73214. * Defines the name of the task
  73215. */
  73216. name: string;
  73217. /**
  73218. * Defines the location of the file to load
  73219. */
  73220. url: string;
  73221. /**
  73222. * Defines if mipmap should not be generated (default is false)
  73223. */
  73224. noMipmap?: boolean | undefined;
  73225. /**
  73226. * Defines if texture must be inverted on Y axis (default is true)
  73227. */
  73228. invertY: boolean;
  73229. /**
  73230. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73231. */
  73232. samplingMode: number;
  73233. /**
  73234. * Gets the loaded texture
  73235. */
  73236. texture: Texture;
  73237. /**
  73238. * Callback called when the task is successful
  73239. */
  73240. onSuccess: (task: TextureAssetTask) => void;
  73241. /**
  73242. * Callback called when the task is successful
  73243. */
  73244. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  73245. /**
  73246. * Creates a new TextureAssetTask object
  73247. * @param name defines the name of the task
  73248. * @param url defines the location of the file to load
  73249. * @param noMipmap defines if mipmap should not be generated (default is false)
  73250. * @param invertY defines if texture must be inverted on Y axis (default is true)
  73251. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73252. */
  73253. constructor(
  73254. /**
  73255. * Defines the name of the task
  73256. */
  73257. name: string,
  73258. /**
  73259. * Defines the location of the file to load
  73260. */
  73261. url: string,
  73262. /**
  73263. * Defines if mipmap should not be generated (default is false)
  73264. */
  73265. noMipmap?: boolean | undefined,
  73266. /**
  73267. * Defines if texture must be inverted on Y axis (default is true)
  73268. */
  73269. invertY?: boolean,
  73270. /**
  73271. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73272. */
  73273. samplingMode?: number);
  73274. /**
  73275. * Execute the current task
  73276. * @param scene defines the scene where you want your assets to be loaded
  73277. * @param onSuccess is a callback called when the task is successfully executed
  73278. * @param onError is a callback called if an error occurs
  73279. */
  73280. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73281. }
  73282. /**
  73283. * Define a task used by AssetsManager to load cube textures
  73284. */
  73285. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  73286. /**
  73287. * Defines the name of the task
  73288. */
  73289. name: string;
  73290. /**
  73291. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73292. */
  73293. url: string;
  73294. /**
  73295. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73296. */
  73297. extensions?: string[] | undefined;
  73298. /**
  73299. * Defines if mipmaps should not be generated (default is false)
  73300. */
  73301. noMipmap?: boolean | undefined;
  73302. /**
  73303. * Defines the explicit list of files (undefined by default)
  73304. */
  73305. files?: string[] | undefined;
  73306. /**
  73307. * Gets the loaded texture
  73308. */
  73309. texture: CubeTexture;
  73310. /**
  73311. * Callback called when the task is successful
  73312. */
  73313. onSuccess: (task: CubeTextureAssetTask) => void;
  73314. /**
  73315. * Callback called when the task is successful
  73316. */
  73317. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  73318. /**
  73319. * Creates a new CubeTextureAssetTask
  73320. * @param name defines the name of the task
  73321. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73322. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73323. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73324. * @param files defines the explicit list of files (undefined by default)
  73325. */
  73326. constructor(
  73327. /**
  73328. * Defines the name of the task
  73329. */
  73330. name: string,
  73331. /**
  73332. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73333. */
  73334. url: string,
  73335. /**
  73336. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73337. */
  73338. extensions?: string[] | undefined,
  73339. /**
  73340. * Defines if mipmaps should not be generated (default is false)
  73341. */
  73342. noMipmap?: boolean | undefined,
  73343. /**
  73344. * Defines the explicit list of files (undefined by default)
  73345. */
  73346. files?: string[] | undefined);
  73347. /**
  73348. * Execute the current task
  73349. * @param scene defines the scene where you want your assets to be loaded
  73350. * @param onSuccess is a callback called when the task is successfully executed
  73351. * @param onError is a callback called if an error occurs
  73352. */
  73353. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73354. }
  73355. /**
  73356. * Define a task used by AssetsManager to load HDR cube textures
  73357. */
  73358. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  73359. /**
  73360. * Defines the name of the task
  73361. */
  73362. name: string;
  73363. /**
  73364. * Defines the location of the file to load
  73365. */
  73366. url: string;
  73367. /**
  73368. * Defines the desired size (the more it increases the longer the generation will be)
  73369. */
  73370. size: number;
  73371. /**
  73372. * Defines if mipmaps should not be generated (default is false)
  73373. */
  73374. noMipmap: boolean;
  73375. /**
  73376. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73377. */
  73378. generateHarmonics: boolean;
  73379. /**
  73380. * 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)
  73381. */
  73382. gammaSpace: boolean;
  73383. /**
  73384. * Internal Use Only
  73385. */
  73386. reserved: boolean;
  73387. /**
  73388. * Gets the loaded texture
  73389. */
  73390. texture: HDRCubeTexture;
  73391. /**
  73392. * Callback called when the task is successful
  73393. */
  73394. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  73395. /**
  73396. * Callback called when the task is successful
  73397. */
  73398. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  73399. /**
  73400. * Creates a new HDRCubeTextureAssetTask object
  73401. * @param name defines the name of the task
  73402. * @param url defines the location of the file to load
  73403. * @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.
  73404. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73405. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73406. * @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)
  73407. * @param reserved Internal use only
  73408. */
  73409. constructor(
  73410. /**
  73411. * Defines the name of the task
  73412. */
  73413. name: string,
  73414. /**
  73415. * Defines the location of the file to load
  73416. */
  73417. url: string,
  73418. /**
  73419. * Defines the desired size (the more it increases the longer the generation will be)
  73420. */
  73421. size: number,
  73422. /**
  73423. * Defines if mipmaps should not be generated (default is false)
  73424. */
  73425. noMipmap?: boolean,
  73426. /**
  73427. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73428. */
  73429. generateHarmonics?: boolean,
  73430. /**
  73431. * 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)
  73432. */
  73433. gammaSpace?: boolean,
  73434. /**
  73435. * Internal Use Only
  73436. */
  73437. reserved?: boolean);
  73438. /**
  73439. * Execute the current task
  73440. * @param scene defines the scene where you want your assets to be loaded
  73441. * @param onSuccess is a callback called when the task is successfully executed
  73442. * @param onError is a callback called if an error occurs
  73443. */
  73444. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73445. }
  73446. /**
  73447. * Define a task used by AssetsManager to load Equirectangular cube textures
  73448. */
  73449. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  73450. /**
  73451. * Defines the name of the task
  73452. */
  73453. name: string;
  73454. /**
  73455. * Defines the location of the file to load
  73456. */
  73457. url: string;
  73458. /**
  73459. * Defines the desired size (the more it increases the longer the generation will be)
  73460. */
  73461. size: number;
  73462. /**
  73463. * Defines if mipmaps should not be generated (default is false)
  73464. */
  73465. noMipmap: boolean;
  73466. /**
  73467. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73468. * but the standard material would require them in Gamma space) (default is true)
  73469. */
  73470. gammaSpace: boolean;
  73471. /**
  73472. * Gets the loaded texture
  73473. */
  73474. texture: EquiRectangularCubeTexture;
  73475. /**
  73476. * Callback called when the task is successful
  73477. */
  73478. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  73479. /**
  73480. * Callback called when the task is successful
  73481. */
  73482. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  73483. /**
  73484. * Creates a new EquiRectangularCubeTextureAssetTask object
  73485. * @param name defines the name of the task
  73486. * @param url defines the location of the file to load
  73487. * @param size defines the desired size (the more it increases the longer the generation will be)
  73488. * If the size is omitted this implies you are using a preprocessed cubemap.
  73489. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73490. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  73491. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  73492. * (default is true)
  73493. */
  73494. constructor(
  73495. /**
  73496. * Defines the name of the task
  73497. */
  73498. name: string,
  73499. /**
  73500. * Defines the location of the file to load
  73501. */
  73502. url: string,
  73503. /**
  73504. * Defines the desired size (the more it increases the longer the generation will be)
  73505. */
  73506. size: number,
  73507. /**
  73508. * Defines if mipmaps should not be generated (default is false)
  73509. */
  73510. noMipmap?: boolean,
  73511. /**
  73512. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73513. * but the standard material would require them in Gamma space) (default is true)
  73514. */
  73515. gammaSpace?: boolean);
  73516. /**
  73517. * Execute the current task
  73518. * @param scene defines the scene where you want your assets to be loaded
  73519. * @param onSuccess is a callback called when the task is successfully executed
  73520. * @param onError is a callback called if an error occurs
  73521. */
  73522. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73523. }
  73524. /**
  73525. * This class can be used to easily import assets into a scene
  73526. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73527. */
  73528. export class AssetsManager {
  73529. private _scene;
  73530. private _isLoading;
  73531. protected _tasks: AbstractAssetTask[];
  73532. protected _waitingTasksCount: number;
  73533. protected _totalTasksCount: number;
  73534. /**
  73535. * Callback called when all tasks are processed
  73536. */
  73537. onFinish: (tasks: AbstractAssetTask[]) => void;
  73538. /**
  73539. * Callback called when a task is successful
  73540. */
  73541. onTaskSuccess: (task: AbstractAssetTask) => void;
  73542. /**
  73543. * Callback called when a task had an error
  73544. */
  73545. onTaskError: (task: AbstractAssetTask) => void;
  73546. /**
  73547. * Callback called when a task is done (whatever the result is)
  73548. */
  73549. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  73550. /**
  73551. * Observable called when all tasks are processed
  73552. */
  73553. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  73554. /**
  73555. * Observable called when a task had an error
  73556. */
  73557. onTaskErrorObservable: Observable<AbstractAssetTask>;
  73558. /**
  73559. * Observable called when all tasks were executed
  73560. */
  73561. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  73562. /**
  73563. * Observable called when a task is done (whatever the result is)
  73564. */
  73565. onProgressObservable: Observable<IAssetsProgressEvent>;
  73566. /**
  73567. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  73568. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  73569. */
  73570. useDefaultLoadingScreen: boolean;
  73571. /**
  73572. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  73573. * when all assets have been downloaded.
  73574. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  73575. */
  73576. autoHideLoadingUI: boolean;
  73577. /**
  73578. * Creates a new AssetsManager
  73579. * @param scene defines the scene to work on
  73580. */
  73581. constructor(scene: Scene);
  73582. /**
  73583. * Add a ContainerAssetTask to the list of active tasks
  73584. * @param taskName defines the name of the new task
  73585. * @param meshesNames defines the name of meshes to load
  73586. * @param rootUrl defines the root url to use to locate files
  73587. * @param sceneFilename defines the filename of the scene file
  73588. * @returns a new ContainerAssetTask object
  73589. */
  73590. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  73591. /**
  73592. * Add a MeshAssetTask 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 MeshAssetTask object
  73598. */
  73599. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  73600. /**
  73601. * Add a TextFileAssetTask to the list of active tasks
  73602. * @param taskName defines the name of the new task
  73603. * @param url defines the url of the file to load
  73604. * @returns a new TextFileAssetTask object
  73605. */
  73606. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  73607. /**
  73608. * Add a BinaryFileAssetTask to the list of active tasks
  73609. * @param taskName defines the name of the new task
  73610. * @param url defines the url of the file to load
  73611. * @returns a new BinaryFileAssetTask object
  73612. */
  73613. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  73614. /**
  73615. * Add a ImageAssetTask to the list of active tasks
  73616. * @param taskName defines the name of the new task
  73617. * @param url defines the url of the file to load
  73618. * @returns a new ImageAssetTask object
  73619. */
  73620. addImageTask(taskName: string, url: string): ImageAssetTask;
  73621. /**
  73622. * Add a TextureAssetTask to the list of active tasks
  73623. * @param taskName defines the name of the new task
  73624. * @param url defines the url of the file to load
  73625. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73626. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  73627. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  73628. * @returns a new TextureAssetTask object
  73629. */
  73630. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  73631. /**
  73632. * Add a CubeTextureAssetTask to the list of active tasks
  73633. * @param taskName defines the name of the new task
  73634. * @param url defines the url of the file to load
  73635. * @param extensions defines the extension to use to load the cube map (can be null)
  73636. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73637. * @param files defines the list of files to load (can be null)
  73638. * @returns a new CubeTextureAssetTask object
  73639. */
  73640. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  73641. /**
  73642. *
  73643. * Add a HDRCubeTextureAssetTask to the list of active tasks
  73644. * @param taskName defines the name of the new task
  73645. * @param url defines the url of the file to load
  73646. * @param size defines the size you want for the cubemap (can be null)
  73647. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73648. * @param generateHarmonics defines if you want to automatically generate (true by default)
  73649. * @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)
  73650. * @param reserved Internal use only
  73651. * @returns a new HDRCubeTextureAssetTask object
  73652. */
  73653. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  73654. /**
  73655. *
  73656. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  73657. * @param taskName defines the name of the new task
  73658. * @param url defines the url of the file to load
  73659. * @param size defines the size you want for the cubemap (can be null)
  73660. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73661. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  73662. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  73663. * @returns a new EquiRectangularCubeTextureAssetTask object
  73664. */
  73665. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  73666. /**
  73667. * Remove a task from the assets manager.
  73668. * @param task the task to remove
  73669. */
  73670. removeTask(task: AbstractAssetTask): void;
  73671. private _decreaseWaitingTasksCount;
  73672. private _runTask;
  73673. /**
  73674. * Reset the AssetsManager and remove all tasks
  73675. * @return the current instance of the AssetsManager
  73676. */
  73677. reset(): AssetsManager;
  73678. /**
  73679. * Start the loading process
  73680. * @return the current instance of the AssetsManager
  73681. */
  73682. load(): AssetsManager;
  73683. /**
  73684. * Start the loading process as an async operation
  73685. * @return a promise returning the list of failed tasks
  73686. */
  73687. loadAsync(): Promise<void>;
  73688. }
  73689. }
  73690. declare module BABYLON {
  73691. /**
  73692. * Wrapper class for promise with external resolve and reject.
  73693. */
  73694. export class Deferred<T> {
  73695. /**
  73696. * The promise associated with this deferred object.
  73697. */
  73698. readonly promise: Promise<T>;
  73699. private _resolve;
  73700. private _reject;
  73701. /**
  73702. * The resolve method of the promise associated with this deferred object.
  73703. */
  73704. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  73705. /**
  73706. * The reject method of the promise associated with this deferred object.
  73707. */
  73708. get reject(): (reason?: any) => void;
  73709. /**
  73710. * Constructor for this deferred object.
  73711. */
  73712. constructor();
  73713. }
  73714. }
  73715. declare module BABYLON {
  73716. /**
  73717. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  73718. */
  73719. export class MeshExploder {
  73720. private _centerMesh;
  73721. private _meshes;
  73722. private _meshesOrigins;
  73723. private _toCenterVectors;
  73724. private _scaledDirection;
  73725. private _newPosition;
  73726. private _centerPosition;
  73727. /**
  73728. * Explodes meshes from a center mesh.
  73729. * @param meshes The meshes to explode.
  73730. * @param centerMesh The mesh to be center of explosion.
  73731. */
  73732. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  73733. private _setCenterMesh;
  73734. /**
  73735. * Get class name
  73736. * @returns "MeshExploder"
  73737. */
  73738. getClassName(): string;
  73739. /**
  73740. * "Exploded meshes"
  73741. * @returns Array of meshes with the centerMesh at index 0.
  73742. */
  73743. getMeshes(): Array<Mesh>;
  73744. /**
  73745. * Explodes meshes giving a specific direction
  73746. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  73747. */
  73748. explode(direction?: number): void;
  73749. }
  73750. }
  73751. declare module BABYLON {
  73752. /**
  73753. * Class used to help managing file picking and drag'n'drop
  73754. */
  73755. export class FilesInput {
  73756. /**
  73757. * List of files ready to be loaded
  73758. */
  73759. static get FilesToLoad(): {
  73760. [key: string]: File;
  73761. };
  73762. /**
  73763. * Callback called when a file is processed
  73764. */
  73765. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  73766. private _engine;
  73767. private _currentScene;
  73768. private _sceneLoadedCallback;
  73769. private _progressCallback;
  73770. private _additionalRenderLoopLogicCallback;
  73771. private _textureLoadingCallback;
  73772. private _startingProcessingFilesCallback;
  73773. private _onReloadCallback;
  73774. private _errorCallback;
  73775. private _elementToMonitor;
  73776. private _sceneFileToLoad;
  73777. private _filesToLoad;
  73778. /**
  73779. * Creates a new FilesInput
  73780. * @param engine defines the rendering engine
  73781. * @param scene defines the hosting scene
  73782. * @param sceneLoadedCallback callback called when scene is loaded
  73783. * @param progressCallback callback called to track progress
  73784. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  73785. * @param textureLoadingCallback callback called when a texture is loading
  73786. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  73787. * @param onReloadCallback callback called when a reload is requested
  73788. * @param errorCallback callback call if an error occurs
  73789. */
  73790. 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>);
  73791. private _dragEnterHandler;
  73792. private _dragOverHandler;
  73793. private _dropHandler;
  73794. /**
  73795. * Calls this function to listen to drag'n'drop events on a specific DOM element
  73796. * @param elementToMonitor defines the DOM element to track
  73797. */
  73798. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  73799. /** Gets the current list of files to load */
  73800. get filesToLoad(): File[];
  73801. /**
  73802. * Release all associated resources
  73803. */
  73804. dispose(): void;
  73805. private renderFunction;
  73806. private drag;
  73807. private drop;
  73808. private _traverseFolder;
  73809. private _processFiles;
  73810. /**
  73811. * Load files from a drop event
  73812. * @param event defines the drop event to use as source
  73813. */
  73814. loadFiles(event: any): void;
  73815. private _processReload;
  73816. /**
  73817. * Reload the current scene from the loaded files
  73818. */
  73819. reload(): void;
  73820. }
  73821. }
  73822. declare module BABYLON {
  73823. /**
  73824. * Defines the root class used to create scene optimization to use with SceneOptimizer
  73825. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73826. */
  73827. export class SceneOptimization {
  73828. /**
  73829. * Defines the priority of this optimization (0 by default which means first in the list)
  73830. */
  73831. priority: number;
  73832. /**
  73833. * Gets a string describing the action executed by the current optimization
  73834. * @returns description string
  73835. */
  73836. getDescription(): string;
  73837. /**
  73838. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73839. * @param scene defines the current scene where to apply this optimization
  73840. * @param optimizer defines the current optimizer
  73841. * @returns true if everything that can be done was applied
  73842. */
  73843. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73844. /**
  73845. * Creates the SceneOptimization object
  73846. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73847. * @param desc defines the description associated with the optimization
  73848. */
  73849. constructor(
  73850. /**
  73851. * Defines the priority of this optimization (0 by default which means first in the list)
  73852. */
  73853. priority?: number);
  73854. }
  73855. /**
  73856. * Defines an optimization used to reduce the size of render target textures
  73857. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73858. */
  73859. export class TextureOptimization extends SceneOptimization {
  73860. /**
  73861. * Defines the priority of this optimization (0 by default which means first in the list)
  73862. */
  73863. priority: number;
  73864. /**
  73865. * 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
  73866. */
  73867. maximumSize: number;
  73868. /**
  73869. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73870. */
  73871. step: number;
  73872. /**
  73873. * Gets a string describing the action executed by the current optimization
  73874. * @returns description string
  73875. */
  73876. getDescription(): string;
  73877. /**
  73878. * Creates the TextureOptimization object
  73879. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73880. * @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
  73881. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73882. */
  73883. constructor(
  73884. /**
  73885. * Defines the priority of this optimization (0 by default which means first in the list)
  73886. */
  73887. priority?: number,
  73888. /**
  73889. * 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. */
  73891. maximumSize?: number,
  73892. /**
  73893. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73894. */
  73895. step?: number);
  73896. /**
  73897. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73898. * @param scene defines the current scene where to apply this optimization
  73899. * @param optimizer defines the current optimizer
  73900. * @returns true if everything that can be done was applied
  73901. */
  73902. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73903. }
  73904. /**
  73905. * Defines an optimization used to increase or decrease the rendering resolution
  73906. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73907. */
  73908. export class HardwareScalingOptimization extends SceneOptimization {
  73909. /**
  73910. * Defines the priority of this optimization (0 by default which means first in the list)
  73911. */
  73912. priority: number;
  73913. /**
  73914. * Defines the maximum scale to use (2 by default)
  73915. */
  73916. maximumScale: number;
  73917. /**
  73918. * Defines the step to use between two passes (0.5 by default)
  73919. */
  73920. step: number;
  73921. private _currentScale;
  73922. private _directionOffset;
  73923. /**
  73924. * Gets a string describing the action executed by the current optimization
  73925. * @return description string
  73926. */
  73927. getDescription(): string;
  73928. /**
  73929. * Creates the HardwareScalingOptimization object
  73930. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73931. * @param maximumScale defines the maximum scale to use (2 by default)
  73932. * @param step defines the step to use between two passes (0.5 by default)
  73933. */
  73934. constructor(
  73935. /**
  73936. * Defines the priority of this optimization (0 by default which means first in the list)
  73937. */
  73938. priority?: number,
  73939. /**
  73940. * Defines the maximum scale to use (2 by default)
  73941. */
  73942. maximumScale?: number,
  73943. /**
  73944. * Defines the step to use between two passes (0.5 by default)
  73945. */
  73946. step?: number);
  73947. /**
  73948. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73949. * @param scene defines the current scene where to apply this optimization
  73950. * @param optimizer defines the current optimizer
  73951. * @returns true if everything that can be done was applied
  73952. */
  73953. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73954. }
  73955. /**
  73956. * Defines an optimization used to remove shadows
  73957. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73958. */
  73959. export class ShadowsOptimization extends SceneOptimization {
  73960. /**
  73961. * Gets a string describing the action executed by the current optimization
  73962. * @return description string
  73963. */
  73964. getDescription(): string;
  73965. /**
  73966. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73967. * @param scene defines the current scene where to apply this optimization
  73968. * @param optimizer defines the current optimizer
  73969. * @returns true if everything that can be done was applied
  73970. */
  73971. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73972. }
  73973. /**
  73974. * Defines an optimization used to turn post-processes off
  73975. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73976. */
  73977. export class PostProcessesOptimization extends SceneOptimization {
  73978. /**
  73979. * Gets a string describing the action executed by the current optimization
  73980. * @return description string
  73981. */
  73982. getDescription(): string;
  73983. /**
  73984. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73985. * @param scene defines the current scene where to apply this optimization
  73986. * @param optimizer defines the current optimizer
  73987. * @returns true if everything that can be done was applied
  73988. */
  73989. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73990. }
  73991. /**
  73992. * Defines an optimization used to turn lens flares off
  73993. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73994. */
  73995. export class LensFlaresOptimization extends SceneOptimization {
  73996. /**
  73997. * Gets a string describing the action executed by the current optimization
  73998. * @return description string
  73999. */
  74000. getDescription(): string;
  74001. /**
  74002. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74003. * @param scene defines the current scene where to apply this optimization
  74004. * @param optimizer defines the current optimizer
  74005. * @returns true if everything that can be done was applied
  74006. */
  74007. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74008. }
  74009. /**
  74010. * Defines an optimization based on user defined callback.
  74011. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74012. */
  74013. export class CustomOptimization extends SceneOptimization {
  74014. /**
  74015. * Callback called to apply the custom optimization.
  74016. */
  74017. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  74018. /**
  74019. * Callback called to get custom description
  74020. */
  74021. onGetDescription: () => string;
  74022. /**
  74023. * Gets a string describing the action executed by the current optimization
  74024. * @returns description string
  74025. */
  74026. getDescription(): string;
  74027. /**
  74028. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74029. * @param scene defines the current scene where to apply this optimization
  74030. * @param optimizer defines the current optimizer
  74031. * @returns true if everything that can be done was applied
  74032. */
  74033. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74034. }
  74035. /**
  74036. * Defines an optimization used to turn particles off
  74037. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74038. */
  74039. export class ParticlesOptimization extends SceneOptimization {
  74040. /**
  74041. * Gets a string describing the action executed by the current optimization
  74042. * @return description string
  74043. */
  74044. getDescription(): string;
  74045. /**
  74046. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74047. * @param scene defines the current scene where to apply this optimization
  74048. * @param optimizer defines the current optimizer
  74049. * @returns true if everything that can be done was applied
  74050. */
  74051. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74052. }
  74053. /**
  74054. * Defines an optimization used to turn render targets off
  74055. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74056. */
  74057. export class RenderTargetsOptimization extends SceneOptimization {
  74058. /**
  74059. * Gets a string describing the action executed by the current optimization
  74060. * @return description string
  74061. */
  74062. getDescription(): string;
  74063. /**
  74064. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74065. * @param scene defines the current scene where to apply this optimization
  74066. * @param optimizer defines the current optimizer
  74067. * @returns true if everything that can be done was applied
  74068. */
  74069. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74070. }
  74071. /**
  74072. * Defines an optimization used to merge meshes with compatible materials
  74073. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74074. */
  74075. export class MergeMeshesOptimization extends SceneOptimization {
  74076. private static _UpdateSelectionTree;
  74077. /**
  74078. * Gets or sets a boolean which defines if optimization octree has to be updated
  74079. */
  74080. static get UpdateSelectionTree(): boolean;
  74081. /**
  74082. * Gets or sets a boolean which defines if optimization octree has to be updated
  74083. */
  74084. static set UpdateSelectionTree(value: boolean);
  74085. /**
  74086. * Gets a string describing the action executed by the current optimization
  74087. * @return description string
  74088. */
  74089. getDescription(): string;
  74090. private _canBeMerged;
  74091. /**
  74092. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74093. * @param scene defines the current scene where to apply this optimization
  74094. * @param optimizer defines the current optimizer
  74095. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  74096. * @returns true if everything that can be done was applied
  74097. */
  74098. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  74099. }
  74100. /**
  74101. * Defines a list of options used by SceneOptimizer
  74102. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74103. */
  74104. export class SceneOptimizerOptions {
  74105. /**
  74106. * Defines the target frame rate to reach (60 by default)
  74107. */
  74108. targetFrameRate: number;
  74109. /**
  74110. * Defines the interval between two checkes (2000ms by default)
  74111. */
  74112. trackerDuration: number;
  74113. /**
  74114. * Gets the list of optimizations to apply
  74115. */
  74116. optimizations: SceneOptimization[];
  74117. /**
  74118. * Creates a new list of options used by SceneOptimizer
  74119. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  74120. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  74121. */
  74122. constructor(
  74123. /**
  74124. * Defines the target frame rate to reach (60 by default)
  74125. */
  74126. targetFrameRate?: number,
  74127. /**
  74128. * Defines the interval between two checkes (2000ms by default)
  74129. */
  74130. trackerDuration?: number);
  74131. /**
  74132. * Add a new optimization
  74133. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  74134. * @returns the current SceneOptimizerOptions
  74135. */
  74136. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  74137. /**
  74138. * Add a new custom optimization
  74139. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  74140. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  74141. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74142. * @returns the current SceneOptimizerOptions
  74143. */
  74144. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  74145. /**
  74146. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  74147. * @param targetFrameRate defines the target frame rate (60 by default)
  74148. * @returns a SceneOptimizerOptions object
  74149. */
  74150. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74151. /**
  74152. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  74153. * @param targetFrameRate defines the target frame rate (60 by default)
  74154. * @returns a SceneOptimizerOptions object
  74155. */
  74156. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74157. /**
  74158. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  74159. * @param targetFrameRate defines the target frame rate (60 by default)
  74160. * @returns a SceneOptimizerOptions object
  74161. */
  74162. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74163. }
  74164. /**
  74165. * Class used to run optimizations in order to reach a target frame rate
  74166. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74167. */
  74168. export class SceneOptimizer implements IDisposable {
  74169. private _isRunning;
  74170. private _options;
  74171. private _scene;
  74172. private _currentPriorityLevel;
  74173. private _targetFrameRate;
  74174. private _trackerDuration;
  74175. private _currentFrameRate;
  74176. private _sceneDisposeObserver;
  74177. private _improvementMode;
  74178. /**
  74179. * Defines an observable called when the optimizer reaches the target frame rate
  74180. */
  74181. onSuccessObservable: Observable<SceneOptimizer>;
  74182. /**
  74183. * Defines an observable called when the optimizer enables an optimization
  74184. */
  74185. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  74186. /**
  74187. * Defines an observable called when the optimizer is not able to reach the target frame rate
  74188. */
  74189. onFailureObservable: Observable<SceneOptimizer>;
  74190. /**
  74191. * Gets a boolean indicating if the optimizer is in improvement mode
  74192. */
  74193. get isInImprovementMode(): boolean;
  74194. /**
  74195. * Gets the current priority level (0 at start)
  74196. */
  74197. get currentPriorityLevel(): number;
  74198. /**
  74199. * Gets the current frame rate checked by the SceneOptimizer
  74200. */
  74201. get currentFrameRate(): number;
  74202. /**
  74203. * Gets or sets the current target frame rate (60 by default)
  74204. */
  74205. get targetFrameRate(): number;
  74206. /**
  74207. * Gets or sets the current target frame rate (60 by default)
  74208. */
  74209. set targetFrameRate(value: number);
  74210. /**
  74211. * Gets or sets the current interval between two checks (every 2000ms by default)
  74212. */
  74213. get trackerDuration(): number;
  74214. /**
  74215. * Gets or sets the current interval between two checks (every 2000ms by default)
  74216. */
  74217. set trackerDuration(value: number);
  74218. /**
  74219. * Gets the list of active optimizations
  74220. */
  74221. get optimizations(): SceneOptimization[];
  74222. /**
  74223. * Creates a new SceneOptimizer
  74224. * @param scene defines the scene to work on
  74225. * @param options defines the options to use with the SceneOptimizer
  74226. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  74227. * @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)
  74228. */
  74229. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  74230. /**
  74231. * Stops the current optimizer
  74232. */
  74233. stop(): void;
  74234. /**
  74235. * Reset the optimizer to initial step (current priority level = 0)
  74236. */
  74237. reset(): void;
  74238. /**
  74239. * Start the optimizer. By default it will try to reach a specific framerate
  74240. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  74241. */
  74242. start(): void;
  74243. private _checkCurrentState;
  74244. /**
  74245. * Release all resources
  74246. */
  74247. dispose(): void;
  74248. /**
  74249. * Helper function to create a SceneOptimizer with one single line of code
  74250. * @param scene defines the scene to work on
  74251. * @param options defines the options to use with the SceneOptimizer
  74252. * @param onSuccess defines a callback to call on success
  74253. * @param onFailure defines a callback to call on failure
  74254. * @returns the new SceneOptimizer object
  74255. */
  74256. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  74257. }
  74258. }
  74259. declare module BABYLON {
  74260. /**
  74261. * Class used to serialize a scene into a string
  74262. */
  74263. export class SceneSerializer {
  74264. /**
  74265. * Clear cache used by a previous serialization
  74266. */
  74267. static ClearCache(): void;
  74268. /**
  74269. * Serialize a scene into a JSON compatible object
  74270. * @param scene defines the scene to serialize
  74271. * @returns a JSON compatible object
  74272. */
  74273. static Serialize(scene: Scene): any;
  74274. /**
  74275. * Serialize a mesh into a JSON compatible object
  74276. * @param toSerialize defines the mesh to serialize
  74277. * @param withParents defines if parents must be serialized as well
  74278. * @param withChildren defines if children must be serialized as well
  74279. * @returns a JSON compatible object
  74280. */
  74281. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  74282. }
  74283. }
  74284. declare module BABYLON {
  74285. /**
  74286. * Class used to host texture specific utilities
  74287. */
  74288. export class TextureTools {
  74289. /**
  74290. * Uses the GPU to create a copy texture rescaled at a given size
  74291. * @param texture Texture to copy from
  74292. * @param width defines the desired width
  74293. * @param height defines the desired height
  74294. * @param useBilinearMode defines if bilinear mode has to be used
  74295. * @return the generated texture
  74296. */
  74297. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  74298. }
  74299. }
  74300. declare module BABYLON {
  74301. /**
  74302. * This represents the different options available for the video capture.
  74303. */
  74304. export interface VideoRecorderOptions {
  74305. /** Defines the mime type of the video. */
  74306. mimeType: string;
  74307. /** Defines the FPS the video should be recorded at. */
  74308. fps: number;
  74309. /** Defines the chunk size for the recording data. */
  74310. recordChunckSize: number;
  74311. /** The audio tracks to attach to the recording. */
  74312. audioTracks?: MediaStreamTrack[];
  74313. }
  74314. /**
  74315. * This can help with recording videos from BabylonJS.
  74316. * This is based on the available WebRTC functionalities of the browser.
  74317. *
  74318. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  74319. */
  74320. export class VideoRecorder {
  74321. private static readonly _defaultOptions;
  74322. /**
  74323. * Returns whether or not the VideoRecorder is available in your browser.
  74324. * @param engine Defines the Babylon Engine.
  74325. * @returns true if supported otherwise false.
  74326. */
  74327. static IsSupported(engine: Engine): boolean;
  74328. private readonly _options;
  74329. private _canvas;
  74330. private _mediaRecorder;
  74331. private _recordedChunks;
  74332. private _fileName;
  74333. private _resolve;
  74334. private _reject;
  74335. /**
  74336. * True when a recording is already in progress.
  74337. */
  74338. get isRecording(): boolean;
  74339. /**
  74340. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  74341. * @param engine Defines the BabylonJS Engine you wish to record.
  74342. * @param options Defines options that can be used to customize the capture.
  74343. */
  74344. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  74345. /**
  74346. * Stops the current recording before the default capture timeout passed in the startRecording function.
  74347. */
  74348. stopRecording(): void;
  74349. /**
  74350. * Starts recording the canvas for a max duration specified in parameters.
  74351. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  74352. * If null no automatic download will start and you can rely on the promise to get the data back.
  74353. * @param maxDuration Defines the maximum recording time in seconds.
  74354. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  74355. * @return A promise callback at the end of the recording with the video data in Blob.
  74356. */
  74357. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  74358. /**
  74359. * Releases internal resources used during the recording.
  74360. */
  74361. dispose(): void;
  74362. private _handleDataAvailable;
  74363. private _handleError;
  74364. private _handleStop;
  74365. }
  74366. }
  74367. declare module BABYLON {
  74368. /**
  74369. * Class containing a set of static utilities functions for screenshots
  74370. */
  74371. export class ScreenshotTools {
  74372. /**
  74373. * Captures a screenshot of the current rendering
  74374. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74375. * @param engine defines the rendering engine
  74376. * @param camera defines the source camera
  74377. * @param size This parameter can be set to a single number or to an object with the
  74378. * following (optional) properties: precision, width, height. If a single number is passed,
  74379. * it will be used for both width and height. If an object is passed, the screenshot size
  74380. * will be derived from the parameters. The precision property is a multiplier allowing
  74381. * rendering at a higher or lower resolution
  74382. * @param successCallback defines the callback receives a single parameter which contains the
  74383. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74384. * src parameter of an <img> to display it
  74385. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74386. * Check your browser for supported MIME types
  74387. */
  74388. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  74389. /**
  74390. * Captures a screenshot of the current rendering
  74391. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74392. * @param engine defines the rendering engine
  74393. * @param camera defines the source camera
  74394. * @param size This parameter can be set to a single number or to an object with the
  74395. * following (optional) properties: precision, width, height. If a single number is passed,
  74396. * it will be used for both width and height. If an object is passed, the screenshot size
  74397. * will be derived from the parameters. The precision property is a multiplier allowing
  74398. * rendering at a higher or lower resolution
  74399. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74400. * Check your browser for supported MIME types
  74401. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74402. * to the src parameter of an <img> to display it
  74403. */
  74404. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  74405. /**
  74406. * Generates an image screenshot from the specified camera.
  74407. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74408. * @param engine The engine to use for rendering
  74409. * @param camera The camera to use for rendering
  74410. * @param size This parameter can be set to a single number or to an object with the
  74411. * following (optional) properties: precision, width, height. If a single number is passed,
  74412. * it will be used for both width and height. If an object is passed, the screenshot size
  74413. * will be derived from the parameters. The precision property is a multiplier allowing
  74414. * rendering at a higher or lower resolution
  74415. * @param successCallback The callback receives a single parameter which contains the
  74416. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74417. * src parameter of an <img> to display it
  74418. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74419. * Check your browser for supported MIME types
  74420. * @param samples Texture samples (default: 1)
  74421. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74422. * @param fileName A name for for the downloaded file.
  74423. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74424. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  74425. */
  74426. 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;
  74427. /**
  74428. * Generates an image screenshot from the specified camera.
  74429. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74430. * @param engine The engine to use for rendering
  74431. * @param camera The camera to use for rendering
  74432. * @param size This parameter can be set to a single number or to an object with the
  74433. * following (optional) properties: precision, width, height. If a single number is passed,
  74434. * it will be used for both width and height. If an object is passed, the screenshot size
  74435. * will be derived from the parameters. The precision property is a multiplier allowing
  74436. * rendering at a higher or lower resolution
  74437. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74438. * Check your browser for supported MIME types
  74439. * @param samples Texture samples (default: 1)
  74440. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74441. * @param fileName A name for for the downloaded file.
  74442. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74443. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74444. * to the src parameter of an <img> to display it
  74445. */
  74446. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  74447. /**
  74448. * Gets height and width for screenshot size
  74449. * @private
  74450. */
  74451. private static _getScreenshotSize;
  74452. }
  74453. }
  74454. declare module BABYLON {
  74455. /**
  74456. * Interface for a data buffer
  74457. */
  74458. export interface IDataBuffer {
  74459. /**
  74460. * Reads bytes from the data buffer.
  74461. * @param byteOffset The byte offset to read
  74462. * @param byteLength The byte length to read
  74463. * @returns A promise that resolves when the bytes are read
  74464. */
  74465. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  74466. /**
  74467. * The byte length of the buffer.
  74468. */
  74469. readonly byteLength: number;
  74470. }
  74471. /**
  74472. * Utility class for reading from a data buffer
  74473. */
  74474. export class DataReader {
  74475. /**
  74476. * The data buffer associated with this data reader.
  74477. */
  74478. readonly buffer: IDataBuffer;
  74479. /**
  74480. * The current byte offset from the beginning of the data buffer.
  74481. */
  74482. byteOffset: number;
  74483. private _dataView;
  74484. private _dataByteOffset;
  74485. /**
  74486. * Constructor
  74487. * @param buffer The buffer to read
  74488. */
  74489. constructor(buffer: IDataBuffer);
  74490. /**
  74491. * Loads the given byte length.
  74492. * @param byteLength The byte length to load
  74493. * @returns A promise that resolves when the load is complete
  74494. */
  74495. loadAsync(byteLength: number): Promise<void>;
  74496. /**
  74497. * Read a unsigned 32-bit integer from the currently loaded data range.
  74498. * @returns The 32-bit integer read
  74499. */
  74500. readUint32(): number;
  74501. /**
  74502. * Read a byte array from the currently loaded data range.
  74503. * @param byteLength The byte length to read
  74504. * @returns The byte array read
  74505. */
  74506. readUint8Array(byteLength: number): Uint8Array;
  74507. /**
  74508. * Read a string from the currently loaded data range.
  74509. * @param byteLength The byte length to read
  74510. * @returns The string read
  74511. */
  74512. readString(byteLength: number): string;
  74513. /**
  74514. * Skips the given byte length the currently loaded data range.
  74515. * @param byteLength The byte length to skip
  74516. */
  74517. skipBytes(byteLength: number): void;
  74518. }
  74519. }
  74520. declare module BABYLON {
  74521. /**
  74522. * Class for storing data to local storage if available or in-memory storage otherwise
  74523. */
  74524. export class DataStorage {
  74525. private static _Storage;
  74526. private static _GetStorage;
  74527. /**
  74528. * Reads a string from the data storage
  74529. * @param key The key to read
  74530. * @param defaultValue The value if the key doesn't exist
  74531. * @returns The string value
  74532. */
  74533. static ReadString(key: string, defaultValue: string): string;
  74534. /**
  74535. * Writes a string to the data storage
  74536. * @param key The key to write
  74537. * @param value The value to write
  74538. */
  74539. static WriteString(key: string, value: string): void;
  74540. /**
  74541. * Reads a boolean from the data storage
  74542. * @param key The key to read
  74543. * @param defaultValue The value if the key doesn't exist
  74544. * @returns The boolean value
  74545. */
  74546. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  74547. /**
  74548. * Writes a boolean to the data storage
  74549. * @param key The key to write
  74550. * @param value The value to write
  74551. */
  74552. static WriteBoolean(key: string, value: boolean): void;
  74553. /**
  74554. * Reads a number from the data storage
  74555. * @param key The key to read
  74556. * @param defaultValue The value if the key doesn't exist
  74557. * @returns The number value
  74558. */
  74559. static ReadNumber(key: string, defaultValue: number): number;
  74560. /**
  74561. * Writes a number to the data storage
  74562. * @param key The key to write
  74563. * @param value The value to write
  74564. */
  74565. static WriteNumber(key: string, value: number): void;
  74566. }
  74567. }
  74568. declare module BABYLON {
  74569. /**
  74570. * Class used to record delta files between 2 scene states
  74571. */
  74572. export class SceneRecorder {
  74573. private _trackedScene;
  74574. private _savedJSON;
  74575. /**
  74576. * Track a given scene. This means the current scene state will be considered the original state
  74577. * @param scene defines the scene to track
  74578. */
  74579. track(scene: Scene): void;
  74580. /**
  74581. * Get the delta between current state and original state
  74582. * @returns a string containing the delta
  74583. */
  74584. getDelta(): any;
  74585. private _compareArray;
  74586. private _compareObjects;
  74587. private _compareCollections;
  74588. private static GetShadowGeneratorById;
  74589. /**
  74590. * Apply a given delta to a given scene
  74591. * @param deltaJSON defines the JSON containing the delta
  74592. * @param scene defines the scene to apply the delta to
  74593. */
  74594. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  74595. private static _ApplyPropertiesToEntity;
  74596. private static _ApplyDeltaForEntity;
  74597. }
  74598. }
  74599. declare module BABYLON {
  74600. /**
  74601. * A 3D trajectory consisting of an order list of vectors describing a
  74602. * path of motion through 3D space.
  74603. */
  74604. export class Trajectory {
  74605. private _points;
  74606. private readonly _segmentLength;
  74607. /**
  74608. * Serialize to JSON.
  74609. * @returns serialized JSON string
  74610. */
  74611. serialize(): string;
  74612. /**
  74613. * Deserialize from JSON.
  74614. * @param json serialized JSON string
  74615. * @returns deserialized Trajectory
  74616. */
  74617. static Deserialize(json: string): Trajectory;
  74618. /**
  74619. * Create a new empty Trajectory.
  74620. * @param segmentLength radius of discretization for Trajectory points
  74621. */
  74622. constructor(segmentLength?: number);
  74623. /**
  74624. * Get the length of the Trajectory.
  74625. * @returns length of the Trajectory
  74626. */
  74627. getLength(): number;
  74628. /**
  74629. * Append a new point to the Trajectory.
  74630. * NOTE: This implementation has many allocations.
  74631. * @param point point to append to the Trajectory
  74632. */
  74633. add(point: DeepImmutable<Vector3>): void;
  74634. /**
  74635. * Create a new Trajectory with a segment length chosen to make it
  74636. * probable that the new Trajectory will have a specified number of
  74637. * segments. This operation is imprecise.
  74638. * @param targetResolution number of segments desired
  74639. * @returns new Trajectory with approximately the requested number of segments
  74640. */
  74641. resampleAtTargetResolution(targetResolution: number): Trajectory;
  74642. /**
  74643. * Convert Trajectory segments into tokenized representation. This
  74644. * representation is an array of numbers where each nth number is the
  74645. * index of the token which is most similar to the nth segment of the
  74646. * Trajectory.
  74647. * @param tokens list of vectors which serve as discrete tokens
  74648. * @returns list of indices of most similar token per segment
  74649. */
  74650. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  74651. private static _forwardDir;
  74652. private static _inverseFromVec;
  74653. private static _upDir;
  74654. private static _fromToVec;
  74655. private static _lookMatrix;
  74656. /**
  74657. * Transform the rotation (i.e., direction) of a segment to isolate
  74658. * the relative transformation represented by the segment. This operation
  74659. * may or may not succeed due to singularities in the equations that define
  74660. * motion relativity in this context.
  74661. * @param priorVec the origin of the prior segment
  74662. * @param fromVec the origin of the current segment
  74663. * @param toVec the destination of the current segment
  74664. * @param result reference to output variable
  74665. * @returns whether or not transformation was successful
  74666. */
  74667. private static _transformSegmentDirToRef;
  74668. private static _bestMatch;
  74669. private static _score;
  74670. private static _bestScore;
  74671. /**
  74672. * Determine which token vector is most similar to the
  74673. * segment vector.
  74674. * @param segment segment vector
  74675. * @param tokens token vector list
  74676. * @returns index of the most similar token to the segment
  74677. */
  74678. private static _tokenizeSegment;
  74679. }
  74680. /**
  74681. * Class representing a set of known, named trajectories to which Trajectories can be
  74682. * added and using which Trajectories can be recognized.
  74683. */
  74684. export class TrajectoryClassifier {
  74685. private _maximumAllowableMatchCost;
  74686. private _vector3Alphabet;
  74687. private _levenshteinAlphabet;
  74688. private _nameToDescribedTrajectory;
  74689. /**
  74690. * Serialize to JSON.
  74691. * @returns JSON serialization
  74692. */
  74693. serialize(): string;
  74694. /**
  74695. * Deserialize from JSON.
  74696. * @param json JSON serialization
  74697. * @returns deserialized TrajectorySet
  74698. */
  74699. static Deserialize(json: string): TrajectoryClassifier;
  74700. /**
  74701. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  74702. * VERY naive, need to be generating these things from known
  74703. * sets. Better version later, probably eliminating this one.
  74704. * @returns auto-generated TrajectorySet
  74705. */
  74706. static Generate(): TrajectoryClassifier;
  74707. private constructor();
  74708. /**
  74709. * Add a new Trajectory to the set with a given name.
  74710. * @param trajectory new Trajectory to be added
  74711. * @param classification name to which to add the Trajectory
  74712. */
  74713. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  74714. /**
  74715. * Remove a known named trajectory and all Trajectories associated with it.
  74716. * @param classification name to remove
  74717. * @returns whether anything was removed
  74718. */
  74719. deleteClassification(classification: string): boolean;
  74720. /**
  74721. * Attempt to recognize a Trajectory from among all the classifications
  74722. * already known to the classifier.
  74723. * @param trajectory Trajectory to be recognized
  74724. * @returns classification of Trajectory if recognized, null otherwise
  74725. */
  74726. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  74727. }
  74728. }
  74729. declare module BABYLON {
  74730. /**
  74731. * An interface for all Hit test features
  74732. */
  74733. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  74734. /**
  74735. * Triggered when new babylon (transformed) hit test results are available
  74736. */
  74737. onHitTestResultObservable: Observable<T[]>;
  74738. }
  74739. /**
  74740. * Options used for hit testing
  74741. */
  74742. export interface IWebXRLegacyHitTestOptions {
  74743. /**
  74744. * Only test when user interacted with the scene. Default - hit test every frame
  74745. */
  74746. testOnPointerDownOnly?: boolean;
  74747. /**
  74748. * The node to use to transform the local results to world coordinates
  74749. */
  74750. worldParentNode?: TransformNode;
  74751. }
  74752. /**
  74753. * Interface defining the babylon result of raycasting/hit-test
  74754. */
  74755. export interface IWebXRLegacyHitResult {
  74756. /**
  74757. * Transformation matrix that can be applied to a node that will put it in the hit point location
  74758. */
  74759. transformationMatrix: Matrix;
  74760. /**
  74761. * The native hit test result
  74762. */
  74763. xrHitResult: XRHitResult | XRHitTestResult;
  74764. }
  74765. /**
  74766. * The currently-working hit-test module.
  74767. * Hit test (or Ray-casting) is used to interact with the real world.
  74768. * For further information read here - https://github.com/immersive-web/hit-test
  74769. */
  74770. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  74771. /**
  74772. * options to use when constructing this feature
  74773. */
  74774. readonly options: IWebXRLegacyHitTestOptions;
  74775. private _direction;
  74776. private _mat;
  74777. private _onSelectEnabled;
  74778. private _origin;
  74779. /**
  74780. * The module's name
  74781. */
  74782. static readonly Name: string;
  74783. /**
  74784. * The (Babylon) version of this module.
  74785. * This is an integer representing the implementation version.
  74786. * This number does not correspond to the WebXR specs version
  74787. */
  74788. static readonly Version: number;
  74789. /**
  74790. * Populated with the last native XR Hit Results
  74791. */
  74792. lastNativeXRHitResults: XRHitResult[];
  74793. /**
  74794. * Triggered when new babylon (transformed) hit test results are available
  74795. */
  74796. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  74797. /**
  74798. * Creates a new instance of the (legacy version) hit test feature
  74799. * @param _xrSessionManager an instance of WebXRSessionManager
  74800. * @param options options to use when constructing this feature
  74801. */
  74802. constructor(_xrSessionManager: WebXRSessionManager,
  74803. /**
  74804. * options to use when constructing this feature
  74805. */
  74806. options?: IWebXRLegacyHitTestOptions);
  74807. /**
  74808. * execute a hit test with an XR Ray
  74809. *
  74810. * @param xrSession a native xrSession that will execute this hit test
  74811. * @param xrRay the ray (position and direction) to use for ray-casting
  74812. * @param referenceSpace native XR reference space to use for the hit-test
  74813. * @param filter filter function that will filter the results
  74814. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74815. */
  74816. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  74817. /**
  74818. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  74819. * @param event the (select) event to use to select with
  74820. * @param referenceSpace the reference space to use for this hit test
  74821. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74822. */
  74823. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74824. /**
  74825. * attach this feature
  74826. * Will usually be called by the features manager
  74827. *
  74828. * @returns true if successful.
  74829. */
  74830. attach(): boolean;
  74831. /**
  74832. * detach this feature.
  74833. * Will usually be called by the features manager
  74834. *
  74835. * @returns true if successful.
  74836. */
  74837. detach(): boolean;
  74838. /**
  74839. * Dispose this feature and all of the resources attached
  74840. */
  74841. dispose(): void;
  74842. protected _onXRFrame(frame: XRFrame): void;
  74843. private _onHitTestResults;
  74844. private _onSelect;
  74845. }
  74846. }
  74847. declare module BABYLON {
  74848. /**
  74849. * Options used for hit testing (version 2)
  74850. */
  74851. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  74852. /**
  74853. * Do not create a permanent hit test. Will usually be used when only
  74854. * transient inputs are needed.
  74855. */
  74856. disablePermanentHitTest?: boolean;
  74857. /**
  74858. * Enable transient (for example touch-based) hit test inspections
  74859. */
  74860. enableTransientHitTest?: boolean;
  74861. /**
  74862. * Offset ray for the permanent hit test
  74863. */
  74864. offsetRay?: Vector3;
  74865. /**
  74866. * Offset ray for the transient hit test
  74867. */
  74868. transientOffsetRay?: Vector3;
  74869. /**
  74870. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  74871. */
  74872. useReferenceSpace?: boolean;
  74873. /**
  74874. * Override the default entity type(s) of the hit-test result
  74875. */
  74876. entityTypes?: XRHitTestTrackableType[];
  74877. }
  74878. /**
  74879. * Interface defining the babylon result of hit-test
  74880. */
  74881. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  74882. /**
  74883. * The input source that generated this hit test (if transient)
  74884. */
  74885. inputSource?: XRInputSource;
  74886. /**
  74887. * Is this a transient hit test
  74888. */
  74889. isTransient?: boolean;
  74890. /**
  74891. * Position of the hit test result
  74892. */
  74893. position: Vector3;
  74894. /**
  74895. * Rotation of the hit test result
  74896. */
  74897. rotationQuaternion: Quaternion;
  74898. /**
  74899. * The native hit test result
  74900. */
  74901. xrHitResult: XRHitTestResult;
  74902. }
  74903. /**
  74904. * The currently-working hit-test module.
  74905. * Hit test (or Ray-casting) is used to interact with the real world.
  74906. * For further information read here - https://github.com/immersive-web/hit-test
  74907. *
  74908. * Tested on chrome (mobile) 80.
  74909. */
  74910. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  74911. /**
  74912. * options to use when constructing this feature
  74913. */
  74914. readonly options: IWebXRHitTestOptions;
  74915. private _tmpMat;
  74916. private _tmpPos;
  74917. private _tmpQuat;
  74918. private _transientXrHitTestSource;
  74919. private _xrHitTestSource;
  74920. private initHitTestSource;
  74921. /**
  74922. * The module's name
  74923. */
  74924. static readonly Name: string;
  74925. /**
  74926. * The (Babylon) version of this module.
  74927. * This is an integer representing the implementation version.
  74928. * This number does not correspond to the WebXR specs version
  74929. */
  74930. static readonly Version: number;
  74931. /**
  74932. * When set to true, each hit test will have its own position/rotation objects
  74933. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  74934. * the developers will clone them or copy them as they see fit.
  74935. */
  74936. autoCloneTransformation: boolean;
  74937. /**
  74938. * Triggered when new babylon (transformed) hit test results are available
  74939. * Note - this will be called when results come back from the device. It can be an empty array!!
  74940. */
  74941. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  74942. /**
  74943. * Use this to temporarily pause hit test checks.
  74944. */
  74945. paused: boolean;
  74946. /**
  74947. * Creates a new instance of the hit test feature
  74948. * @param _xrSessionManager an instance of WebXRSessionManager
  74949. * @param options options to use when constructing this feature
  74950. */
  74951. constructor(_xrSessionManager: WebXRSessionManager,
  74952. /**
  74953. * options to use when constructing this feature
  74954. */
  74955. options?: IWebXRHitTestOptions);
  74956. /**
  74957. * attach this feature
  74958. * Will usually be called by the features manager
  74959. *
  74960. * @returns true if successful.
  74961. */
  74962. attach(): boolean;
  74963. /**
  74964. * detach this feature.
  74965. * Will usually be called by the features manager
  74966. *
  74967. * @returns true if successful.
  74968. */
  74969. detach(): boolean;
  74970. /**
  74971. * Dispose this feature and all of the resources attached
  74972. */
  74973. dispose(): void;
  74974. protected _onXRFrame(frame: XRFrame): void;
  74975. private _processWebXRHitTestResult;
  74976. }
  74977. }
  74978. declare module BABYLON {
  74979. /**
  74980. * Configuration options of the anchor system
  74981. */
  74982. export interface IWebXRAnchorSystemOptions {
  74983. /**
  74984. * a node that will be used to convert local to world coordinates
  74985. */
  74986. worldParentNode?: TransformNode;
  74987. /**
  74988. * If set to true a reference of the created anchors will be kept until the next session starts
  74989. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  74990. */
  74991. doNotRemoveAnchorsOnSessionEnded?: boolean;
  74992. }
  74993. /**
  74994. * A babylon container for an XR Anchor
  74995. */
  74996. export interface IWebXRAnchor {
  74997. /**
  74998. * A babylon-assigned ID for this anchor
  74999. */
  75000. id: number;
  75001. /**
  75002. * Transformation matrix to apply to an object attached to this anchor
  75003. */
  75004. transformationMatrix: Matrix;
  75005. /**
  75006. * The native anchor object
  75007. */
  75008. xrAnchor: XRAnchor;
  75009. /**
  75010. * if defined, this object will be constantly updated by the anchor's position and rotation
  75011. */
  75012. attachedNode?: TransformNode;
  75013. }
  75014. /**
  75015. * An implementation of the anchor system for WebXR.
  75016. * For further information see https://github.com/immersive-web/anchors/
  75017. */
  75018. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  75019. private _options;
  75020. private _lastFrameDetected;
  75021. private _trackedAnchors;
  75022. private _referenceSpaceForFrameAnchors;
  75023. private _futureAnchors;
  75024. /**
  75025. * The module's name
  75026. */
  75027. static readonly Name: string;
  75028. /**
  75029. * The (Babylon) version of this module.
  75030. * This is an integer representing the implementation version.
  75031. * This number does not correspond to the WebXR specs version
  75032. */
  75033. static readonly Version: number;
  75034. /**
  75035. * Observers registered here will be executed when a new anchor was added to the session
  75036. */
  75037. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  75038. /**
  75039. * Observers registered here will be executed when an anchor was removed from the session
  75040. */
  75041. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  75042. /**
  75043. * Observers registered here will be executed when an existing anchor updates
  75044. * This can execute N times every frame
  75045. */
  75046. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  75047. /**
  75048. * Set the reference space to use for anchor creation, when not using a hit test.
  75049. * Will default to the session's reference space if not defined
  75050. */
  75051. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  75052. /**
  75053. * constructs a new anchor system
  75054. * @param _xrSessionManager an instance of WebXRSessionManager
  75055. * @param _options configuration object for this feature
  75056. */
  75057. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  75058. private _tmpVector;
  75059. private _tmpQuaternion;
  75060. private _populateTmpTransformation;
  75061. /**
  75062. * Create a new anchor point using a hit test result at a specific point in the scene
  75063. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75064. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75065. *
  75066. * @param hitTestResult The hit test result to use for this anchor creation
  75067. * @param position an optional position offset for this anchor
  75068. * @param rotationQuaternion an optional rotation offset for this anchor
  75069. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75070. */
  75071. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  75072. /**
  75073. * Add a new anchor at a specific position and rotation
  75074. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  75075. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  75076. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75077. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75078. *
  75079. * @param position the position in which to add an anchor
  75080. * @param rotationQuaternion an optional rotation for the anchor transformation
  75081. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  75082. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75083. */
  75084. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  75085. /**
  75086. * detach this feature.
  75087. * Will usually be called by the features manager
  75088. *
  75089. * @returns true if successful.
  75090. */
  75091. detach(): boolean;
  75092. /**
  75093. * Dispose this feature and all of the resources attached
  75094. */
  75095. dispose(): void;
  75096. protected _onXRFrame(frame: XRFrame): void;
  75097. /**
  75098. * avoiding using Array.find for global support.
  75099. * @param xrAnchor the plane to find in the array
  75100. */
  75101. private _findIndexInAnchorArray;
  75102. private _updateAnchorWithXRFrame;
  75103. private _createAnchorAtTransformation;
  75104. }
  75105. }
  75106. declare module BABYLON {
  75107. /**
  75108. * Options used in the plane detector module
  75109. */
  75110. export interface IWebXRPlaneDetectorOptions {
  75111. /**
  75112. * The node to use to transform the local results to world coordinates
  75113. */
  75114. worldParentNode?: TransformNode;
  75115. /**
  75116. * If set to true a reference of the created planes will be kept until the next session starts
  75117. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  75118. */
  75119. doNotRemovePlanesOnSessionEnded?: boolean;
  75120. }
  75121. /**
  75122. * A babylon interface for a WebXR plane.
  75123. * A Plane is actually a polygon, built from N points in space
  75124. *
  75125. * Supported in chrome 79, not supported in canary 81 ATM
  75126. */
  75127. export interface IWebXRPlane {
  75128. /**
  75129. * a babylon-assigned ID for this polygon
  75130. */
  75131. id: number;
  75132. /**
  75133. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  75134. */
  75135. polygonDefinition: Array<Vector3>;
  75136. /**
  75137. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  75138. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  75139. */
  75140. transformationMatrix: Matrix;
  75141. /**
  75142. * the native xr-plane object
  75143. */
  75144. xrPlane: XRPlane;
  75145. }
  75146. /**
  75147. * The plane detector is used to detect planes in the real world when in AR
  75148. * For more information see https://github.com/immersive-web/real-world-geometry/
  75149. */
  75150. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  75151. private _options;
  75152. private _detectedPlanes;
  75153. private _enabled;
  75154. private _lastFrameDetected;
  75155. /**
  75156. * The module's name
  75157. */
  75158. static readonly Name: string;
  75159. /**
  75160. * The (Babylon) version of this module.
  75161. * This is an integer representing the implementation version.
  75162. * This number does not correspond to the WebXR specs version
  75163. */
  75164. static readonly Version: number;
  75165. /**
  75166. * Observers registered here will be executed when a new plane was added to the session
  75167. */
  75168. onPlaneAddedObservable: Observable<IWebXRPlane>;
  75169. /**
  75170. * Observers registered here will be executed when a plane is no longer detected in the session
  75171. */
  75172. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  75173. /**
  75174. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  75175. * This can execute N times every frame
  75176. */
  75177. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  75178. /**
  75179. * construct a new Plane Detector
  75180. * @param _xrSessionManager an instance of xr Session manager
  75181. * @param _options configuration to use when constructing this feature
  75182. */
  75183. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  75184. /**
  75185. * detach this feature.
  75186. * Will usually be called by the features manager
  75187. *
  75188. * @returns true if successful.
  75189. */
  75190. detach(): boolean;
  75191. /**
  75192. * Dispose this feature and all of the resources attached
  75193. */
  75194. dispose(): void;
  75195. protected _onXRFrame(frame: XRFrame): void;
  75196. private _init;
  75197. private _updatePlaneWithXRPlane;
  75198. /**
  75199. * avoiding using Array.find for global support.
  75200. * @param xrPlane the plane to find in the array
  75201. */
  75202. private findIndexInPlaneArray;
  75203. }
  75204. }
  75205. declare module BABYLON {
  75206. /**
  75207. * Options interface for the background remover plugin
  75208. */
  75209. export interface IWebXRBackgroundRemoverOptions {
  75210. /**
  75211. * Further background meshes to disable when entering AR
  75212. */
  75213. backgroundMeshes?: AbstractMesh[];
  75214. /**
  75215. * flags to configure the removal of the environment helper.
  75216. * If not set, the entire background will be removed. If set, flags should be set as well.
  75217. */
  75218. environmentHelperRemovalFlags?: {
  75219. /**
  75220. * Should the skybox be removed (default false)
  75221. */
  75222. skyBox?: boolean;
  75223. /**
  75224. * Should the ground be removed (default false)
  75225. */
  75226. ground?: boolean;
  75227. };
  75228. /**
  75229. * don't disable the environment helper
  75230. */
  75231. ignoreEnvironmentHelper?: boolean;
  75232. }
  75233. /**
  75234. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  75235. */
  75236. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  75237. /**
  75238. * read-only options to be used in this module
  75239. */
  75240. readonly options: IWebXRBackgroundRemoverOptions;
  75241. /**
  75242. * The module's name
  75243. */
  75244. static readonly Name: string;
  75245. /**
  75246. * The (Babylon) version of this module.
  75247. * This is an integer representing the implementation version.
  75248. * This number does not correspond to the WebXR specs version
  75249. */
  75250. static readonly Version: number;
  75251. /**
  75252. * registered observers will be triggered when the background state changes
  75253. */
  75254. onBackgroundStateChangedObservable: Observable<boolean>;
  75255. /**
  75256. * constructs a new background remover module
  75257. * @param _xrSessionManager the session manager for this module
  75258. * @param options read-only options to be used in this module
  75259. */
  75260. constructor(_xrSessionManager: WebXRSessionManager,
  75261. /**
  75262. * read-only options to be used in this module
  75263. */
  75264. options?: IWebXRBackgroundRemoverOptions);
  75265. /**
  75266. * attach this feature
  75267. * Will usually be called by the features manager
  75268. *
  75269. * @returns true if successful.
  75270. */
  75271. attach(): boolean;
  75272. /**
  75273. * detach this feature.
  75274. * Will usually be called by the features manager
  75275. *
  75276. * @returns true if successful.
  75277. */
  75278. detach(): boolean;
  75279. /**
  75280. * Dispose this feature and all of the resources attached
  75281. */
  75282. dispose(): void;
  75283. protected _onXRFrame(_xrFrame: XRFrame): void;
  75284. private _setBackgroundState;
  75285. }
  75286. }
  75287. declare module BABYLON {
  75288. /**
  75289. * Options for the controller physics feature
  75290. */
  75291. export class IWebXRControllerPhysicsOptions {
  75292. /**
  75293. * Should the headset get its own impostor
  75294. */
  75295. enableHeadsetImpostor?: boolean;
  75296. /**
  75297. * Optional parameters for the headset impostor
  75298. */
  75299. headsetImpostorParams?: {
  75300. /**
  75301. * The type of impostor to create. Default is sphere
  75302. */
  75303. impostorType: number;
  75304. /**
  75305. * the size of the impostor. Defaults to 10cm
  75306. */
  75307. impostorSize?: number | {
  75308. width: number;
  75309. height: number;
  75310. depth: number;
  75311. };
  75312. /**
  75313. * Friction definitions
  75314. */
  75315. friction?: number;
  75316. /**
  75317. * Restitution
  75318. */
  75319. restitution?: number;
  75320. };
  75321. /**
  75322. * The physics properties of the future impostors
  75323. */
  75324. physicsProperties?: {
  75325. /**
  75326. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  75327. * Note that this requires a physics engine that supports mesh impostors!
  75328. */
  75329. useControllerMesh?: boolean;
  75330. /**
  75331. * The type of impostor to create. Default is sphere
  75332. */
  75333. impostorType?: number;
  75334. /**
  75335. * the size of the impostor. Defaults to 10cm
  75336. */
  75337. impostorSize?: number | {
  75338. width: number;
  75339. height: number;
  75340. depth: number;
  75341. };
  75342. /**
  75343. * Friction definitions
  75344. */
  75345. friction?: number;
  75346. /**
  75347. * Restitution
  75348. */
  75349. restitution?: number;
  75350. };
  75351. /**
  75352. * the xr input to use with this pointer selection
  75353. */
  75354. xrInput: WebXRInput;
  75355. }
  75356. /**
  75357. * Add physics impostor to your webxr controllers,
  75358. * including naive calculation of their linear and angular velocity
  75359. */
  75360. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  75361. private readonly _options;
  75362. private _attachController;
  75363. private _controllers;
  75364. private _debugMode;
  75365. private _delta;
  75366. private _headsetImpostor?;
  75367. private _headsetMesh?;
  75368. private _lastTimestamp;
  75369. private _tmpQuaternion;
  75370. private _tmpVector;
  75371. /**
  75372. * The module's name
  75373. */
  75374. static readonly Name: string;
  75375. /**
  75376. * The (Babylon) version of this module.
  75377. * This is an integer representing the implementation version.
  75378. * This number does not correspond to the webxr specs version
  75379. */
  75380. static readonly Version: number;
  75381. /**
  75382. * Construct a new Controller Physics Feature
  75383. * @param _xrSessionManager the corresponding xr session manager
  75384. * @param _options options to create this feature with
  75385. */
  75386. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  75387. /**
  75388. * @hidden
  75389. * enable debugging - will show console outputs and the impostor mesh
  75390. */
  75391. _enablePhysicsDebug(): void;
  75392. /**
  75393. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  75394. * @param xrController the controller to add
  75395. */
  75396. addController(xrController: WebXRInputSource): void;
  75397. /**
  75398. * attach this feature
  75399. * Will usually be called by the features manager
  75400. *
  75401. * @returns true if successful.
  75402. */
  75403. attach(): boolean;
  75404. /**
  75405. * detach this feature.
  75406. * Will usually be called by the features manager
  75407. *
  75408. * @returns true if successful.
  75409. */
  75410. detach(): boolean;
  75411. /**
  75412. * Get the headset impostor, if enabled
  75413. * @returns the impostor
  75414. */
  75415. getHeadsetImpostor(): PhysicsImpostor | undefined;
  75416. /**
  75417. * Get the physics impostor of a specific controller.
  75418. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  75419. * @param controller the controller or the controller id of which to get the impostor
  75420. * @returns the impostor or null
  75421. */
  75422. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  75423. /**
  75424. * Update the physics properties provided in the constructor
  75425. * @param newProperties the new properties object
  75426. */
  75427. setPhysicsProperties(newProperties: {
  75428. impostorType?: number;
  75429. impostorSize?: number | {
  75430. width: number;
  75431. height: number;
  75432. depth: number;
  75433. };
  75434. friction?: number;
  75435. restitution?: number;
  75436. }): void;
  75437. protected _onXRFrame(_xrFrame: any): void;
  75438. private _detachController;
  75439. }
  75440. }
  75441. declare module BABYLON {
  75442. /**
  75443. * A babylon interface for a "WebXR" feature point.
  75444. * Represents the position and confidence value of a given feature point.
  75445. */
  75446. export interface IWebXRFeaturePoint {
  75447. /**
  75448. * Represents the position of the feature point in world space.
  75449. */
  75450. position: Vector3;
  75451. /**
  75452. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  75453. */
  75454. confidenceValue: number;
  75455. }
  75456. /**
  75457. * The feature point system is used to detect feature points from real world geometry.
  75458. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  75459. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  75460. */
  75461. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  75462. private _enabled;
  75463. private _featurePointCloud;
  75464. /**
  75465. * The module's name
  75466. */
  75467. static readonly Name: string;
  75468. /**
  75469. * The (Babylon) version of this module.
  75470. * This is an integer representing the implementation version.
  75471. * This number does not correspond to the WebXR specs version
  75472. */
  75473. static readonly Version: number;
  75474. /**
  75475. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  75476. * Will notify the observers about which feature points have been added.
  75477. */
  75478. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  75479. /**
  75480. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  75481. * Will notify the observers about which feature points have been updated.
  75482. */
  75483. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  75484. /**
  75485. * The current feature point cloud maintained across frames.
  75486. */
  75487. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  75488. /**
  75489. * construct the feature point system
  75490. * @param _xrSessionManager an instance of xr Session manager
  75491. */
  75492. constructor(_xrSessionManager: WebXRSessionManager);
  75493. /**
  75494. * Detach this feature.
  75495. * Will usually be called by the features manager
  75496. *
  75497. * @returns true if successful.
  75498. */
  75499. detach(): boolean;
  75500. /**
  75501. * Dispose this feature and all of the resources attached
  75502. */
  75503. dispose(): void;
  75504. /**
  75505. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  75506. */
  75507. protected _onXRFrame(frame: XRFrame): void;
  75508. /**
  75509. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  75510. */
  75511. private _init;
  75512. }
  75513. }
  75514. declare module BABYLON {
  75515. /**
  75516. * Configuration interface for the hand tracking feature
  75517. */
  75518. export interface IWebXRHandTrackingOptions {
  75519. /**
  75520. * The xrInput that will be used as source for new hands
  75521. */
  75522. xrInput: WebXRInput;
  75523. /**
  75524. * Configuration object for the joint meshes
  75525. */
  75526. jointMeshes?: {
  75527. /**
  75528. * Should the meshes created be invisible (defaults to false)
  75529. */
  75530. invisible?: boolean;
  75531. /**
  75532. * A source mesh to be used to create instances. Defaults to a sphere.
  75533. * This mesh will be the source for all other (25) meshes.
  75534. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  75535. */
  75536. sourceMesh?: Mesh;
  75537. /**
  75538. * Should the source mesh stay visible. Defaults to false
  75539. */
  75540. keepOriginalVisible?: boolean;
  75541. /**
  75542. * Scale factor for all instances (defaults to 2)
  75543. */
  75544. scaleFactor?: number;
  75545. /**
  75546. * Should each instance have its own physics impostor
  75547. */
  75548. enablePhysics?: boolean;
  75549. /**
  75550. * If enabled, override default physics properties
  75551. */
  75552. physicsProps?: {
  75553. friction?: number;
  75554. restitution?: number;
  75555. impostorType?: number;
  75556. };
  75557. /**
  75558. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  75559. */
  75560. handMesh?: AbstractMesh;
  75561. };
  75562. }
  75563. /**
  75564. * Parts of the hands divided to writs and finger names
  75565. */
  75566. export const enum HandPart {
  75567. /**
  75568. * HandPart - Wrist
  75569. */
  75570. WRIST = "wrist",
  75571. /**
  75572. * HandPart - The THumb
  75573. */
  75574. THUMB = "thumb",
  75575. /**
  75576. * HandPart - Index finger
  75577. */
  75578. INDEX = "index",
  75579. /**
  75580. * HandPart - Middle finger
  75581. */
  75582. MIDDLE = "middle",
  75583. /**
  75584. * HandPart - Ring finger
  75585. */
  75586. RING = "ring",
  75587. /**
  75588. * HandPart - Little finger
  75589. */
  75590. LITTLE = "little"
  75591. }
  75592. /**
  75593. * Representing a single hand (with its corresponding native XRHand object)
  75594. */
  75595. export class WebXRHand implements IDisposable {
  75596. /** the controller to which the hand correlates */
  75597. readonly xrController: WebXRInputSource;
  75598. /** the meshes to be used to track the hand joints */
  75599. readonly trackedMeshes: AbstractMesh[];
  75600. /**
  75601. * Hand-parts definition (key is HandPart)
  75602. */
  75603. handPartsDefinition: {
  75604. [key: string]: number[];
  75605. };
  75606. /**
  75607. * Populate the HandPartsDefinition object.
  75608. * This is called as a side effect since certain browsers don't have XRHand defined.
  75609. */
  75610. private generateHandPartsDefinition;
  75611. /**
  75612. * Construct a new hand object
  75613. * @param xrController the controller to which the hand correlates
  75614. * @param trackedMeshes the meshes to be used to track the hand joints
  75615. */
  75616. constructor(
  75617. /** the controller to which the hand correlates */
  75618. xrController: WebXRInputSource,
  75619. /** the meshes to be used to track the hand joints */
  75620. trackedMeshes: AbstractMesh[]);
  75621. /**
  75622. * Update this hand from the latest xr frame
  75623. * @param xrFrame xrFrame to update from
  75624. * @param referenceSpace The current viewer reference space
  75625. * @param scaleFactor optional scale factor for the meshes
  75626. */
  75627. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  75628. /**
  75629. * Get meshes of part of the hand
  75630. * @param part the part of hand to get
  75631. * @returns An array of meshes that correlate to the hand part requested
  75632. */
  75633. getHandPartMeshes(part: HandPart): AbstractMesh[];
  75634. /**
  75635. * Dispose this Hand object
  75636. */
  75637. dispose(): void;
  75638. }
  75639. /**
  75640. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  75641. */
  75642. export class WebXRHandTracking extends WebXRAbstractFeature {
  75643. /**
  75644. * options to use when constructing this feature
  75645. */
  75646. readonly options: IWebXRHandTrackingOptions;
  75647. private static _idCounter;
  75648. /**
  75649. * The module's name
  75650. */
  75651. static readonly Name: string;
  75652. /**
  75653. * The (Babylon) version of this module.
  75654. * This is an integer representing the implementation version.
  75655. * This number does not correspond to the WebXR specs version
  75656. */
  75657. static readonly Version: number;
  75658. /**
  75659. * This observable will notify registered observers when a new hand object was added and initialized
  75660. */
  75661. onHandAddedObservable: Observable<WebXRHand>;
  75662. /**
  75663. * This observable will notify its observers right before the hand object is disposed
  75664. */
  75665. onHandRemovedObservable: Observable<WebXRHand>;
  75666. private _hands;
  75667. /**
  75668. * Creates a new instance of the hit test feature
  75669. * @param _xrSessionManager an instance of WebXRSessionManager
  75670. * @param options options to use when constructing this feature
  75671. */
  75672. constructor(_xrSessionManager: WebXRSessionManager,
  75673. /**
  75674. * options to use when constructing this feature
  75675. */
  75676. options: IWebXRHandTrackingOptions);
  75677. /**
  75678. * Check if the needed objects are defined.
  75679. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  75680. */
  75681. isCompatible(): boolean;
  75682. /**
  75683. * attach this feature
  75684. * Will usually be called by the features manager
  75685. *
  75686. * @returns true if successful.
  75687. */
  75688. attach(): boolean;
  75689. /**
  75690. * detach this feature.
  75691. * Will usually be called by the features manager
  75692. *
  75693. * @returns true if successful.
  75694. */
  75695. detach(): boolean;
  75696. /**
  75697. * Dispose this feature and all of the resources attached
  75698. */
  75699. dispose(): void;
  75700. /**
  75701. * Get the hand object according to the controller id
  75702. * @param controllerId the controller id to which we want to get the hand
  75703. * @returns null if not found or the WebXRHand object if found
  75704. */
  75705. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  75706. /**
  75707. * Get a hand object according to the requested handedness
  75708. * @param handedness the handedness to request
  75709. * @returns null if not found or the WebXRHand object if found
  75710. */
  75711. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  75712. protected _onXRFrame(_xrFrame: XRFrame): void;
  75713. private _attachHand;
  75714. private _detachHand;
  75715. }
  75716. }
  75717. declare module BABYLON {
  75718. /**
  75719. * The motion controller class for all microsoft mixed reality controllers
  75720. */
  75721. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  75722. protected readonly _mapping: {
  75723. defaultButton: {
  75724. valueNodeName: string;
  75725. unpressedNodeName: string;
  75726. pressedNodeName: string;
  75727. };
  75728. defaultAxis: {
  75729. valueNodeName: string;
  75730. minNodeName: string;
  75731. maxNodeName: string;
  75732. };
  75733. buttons: {
  75734. "xr-standard-trigger": {
  75735. rootNodeName: string;
  75736. componentProperty: string;
  75737. states: string[];
  75738. };
  75739. "xr-standard-squeeze": {
  75740. rootNodeName: string;
  75741. componentProperty: string;
  75742. states: string[];
  75743. };
  75744. "xr-standard-touchpad": {
  75745. rootNodeName: string;
  75746. labelAnchorNodeName: string;
  75747. touchPointNodeName: string;
  75748. };
  75749. "xr-standard-thumbstick": {
  75750. rootNodeName: string;
  75751. componentProperty: string;
  75752. states: string[];
  75753. };
  75754. };
  75755. axes: {
  75756. "xr-standard-touchpad": {
  75757. "x-axis": {
  75758. rootNodeName: string;
  75759. };
  75760. "y-axis": {
  75761. rootNodeName: string;
  75762. };
  75763. };
  75764. "xr-standard-thumbstick": {
  75765. "x-axis": {
  75766. rootNodeName: string;
  75767. };
  75768. "y-axis": {
  75769. rootNodeName: string;
  75770. };
  75771. };
  75772. };
  75773. };
  75774. /**
  75775. * The base url used to load the left and right controller models
  75776. */
  75777. static MODEL_BASE_URL: string;
  75778. /**
  75779. * The name of the left controller model file
  75780. */
  75781. static MODEL_LEFT_FILENAME: string;
  75782. /**
  75783. * The name of the right controller model file
  75784. */
  75785. static MODEL_RIGHT_FILENAME: string;
  75786. profileId: string;
  75787. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75788. protected _getFilenameAndPath(): {
  75789. filename: string;
  75790. path: string;
  75791. };
  75792. protected _getModelLoadingConstraints(): boolean;
  75793. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75794. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75795. protected _updateModel(): void;
  75796. }
  75797. }
  75798. declare module BABYLON {
  75799. /**
  75800. * The motion controller class for oculus touch (quest, rift).
  75801. * This class supports legacy mapping as well the standard xr mapping
  75802. */
  75803. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  75804. private _forceLegacyControllers;
  75805. private _modelRootNode;
  75806. /**
  75807. * The base url used to load the left and right controller models
  75808. */
  75809. static MODEL_BASE_URL: string;
  75810. /**
  75811. * The name of the left controller model file
  75812. */
  75813. static MODEL_LEFT_FILENAME: string;
  75814. /**
  75815. * The name of the right controller model file
  75816. */
  75817. static MODEL_RIGHT_FILENAME: string;
  75818. /**
  75819. * Base Url for the Quest controller model.
  75820. */
  75821. static QUEST_MODEL_BASE_URL: string;
  75822. profileId: string;
  75823. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  75824. protected _getFilenameAndPath(): {
  75825. filename: string;
  75826. path: string;
  75827. };
  75828. protected _getModelLoadingConstraints(): boolean;
  75829. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75830. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75831. protected _updateModel(): void;
  75832. /**
  75833. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  75834. * between the touch and touch 2.
  75835. */
  75836. private _isQuest;
  75837. }
  75838. }
  75839. declare module BABYLON {
  75840. /**
  75841. * The motion controller class for the standard HTC-Vive controllers
  75842. */
  75843. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  75844. private _modelRootNode;
  75845. /**
  75846. * The base url used to load the left and right controller models
  75847. */
  75848. static MODEL_BASE_URL: string;
  75849. /**
  75850. * File name for the controller model.
  75851. */
  75852. static MODEL_FILENAME: string;
  75853. profileId: string;
  75854. /**
  75855. * Create a new Vive motion controller object
  75856. * @param scene the scene to use to create this controller
  75857. * @param gamepadObject the corresponding gamepad object
  75858. * @param handedness the handedness of the controller
  75859. */
  75860. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75861. protected _getFilenameAndPath(): {
  75862. filename: string;
  75863. path: string;
  75864. };
  75865. protected _getModelLoadingConstraints(): boolean;
  75866. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75867. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75868. protected _updateModel(): void;
  75869. }
  75870. }
  75871. declare module BABYLON {
  75872. /**
  75873. * A cursor which tracks a point on a path
  75874. */
  75875. export class PathCursor {
  75876. private path;
  75877. /**
  75878. * Stores path cursor callbacks for when an onchange event is triggered
  75879. */
  75880. private _onchange;
  75881. /**
  75882. * The value of the path cursor
  75883. */
  75884. value: number;
  75885. /**
  75886. * The animation array of the path cursor
  75887. */
  75888. animations: Animation[];
  75889. /**
  75890. * Initializes the path cursor
  75891. * @param path The path to track
  75892. */
  75893. constructor(path: Path2);
  75894. /**
  75895. * Gets the cursor point on the path
  75896. * @returns A point on the path cursor at the cursor location
  75897. */
  75898. getPoint(): Vector3;
  75899. /**
  75900. * Moves the cursor ahead by the step amount
  75901. * @param step The amount to move the cursor forward
  75902. * @returns This path cursor
  75903. */
  75904. moveAhead(step?: number): PathCursor;
  75905. /**
  75906. * Moves the cursor behind by the step amount
  75907. * @param step The amount to move the cursor back
  75908. * @returns This path cursor
  75909. */
  75910. moveBack(step?: number): PathCursor;
  75911. /**
  75912. * Moves the cursor by the step amount
  75913. * If the step amount is greater than one, an exception is thrown
  75914. * @param step The amount to move the cursor
  75915. * @returns This path cursor
  75916. */
  75917. move(step: number): PathCursor;
  75918. /**
  75919. * Ensures that the value is limited between zero and one
  75920. * @returns This path cursor
  75921. */
  75922. private ensureLimits;
  75923. /**
  75924. * Runs onchange callbacks on change (used by the animation engine)
  75925. * @returns This path cursor
  75926. */
  75927. private raiseOnChange;
  75928. /**
  75929. * Executes a function on change
  75930. * @param f A path cursor onchange callback
  75931. * @returns This path cursor
  75932. */
  75933. onchange(f: (cursor: PathCursor) => void): PathCursor;
  75934. }
  75935. }
  75936. declare module BABYLON {
  75937. /** @hidden */
  75938. export var blurPixelShader: {
  75939. name: string;
  75940. shader: string;
  75941. };
  75942. }
  75943. declare module BABYLON {
  75944. /** @hidden */
  75945. export var pointCloudVertexDeclaration: {
  75946. name: string;
  75947. shader: string;
  75948. };
  75949. }
  75950. // Mixins
  75951. interface Window {
  75952. mozIndexedDB: IDBFactory;
  75953. webkitIndexedDB: IDBFactory;
  75954. msIndexedDB: IDBFactory;
  75955. webkitURL: typeof URL;
  75956. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  75957. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  75958. WebGLRenderingContext: WebGLRenderingContext;
  75959. MSGesture: MSGesture;
  75960. CANNON: any;
  75961. AudioContext: AudioContext;
  75962. webkitAudioContext: AudioContext;
  75963. PointerEvent: any;
  75964. Math: Math;
  75965. Uint8Array: Uint8ArrayConstructor;
  75966. Float32Array: Float32ArrayConstructor;
  75967. mozURL: typeof URL;
  75968. msURL: typeof URL;
  75969. VRFrameData: any; // WebVR, from specs 1.1
  75970. DracoDecoderModule: any;
  75971. setImmediate(handler: (...args: any[]) => void): number;
  75972. }
  75973. interface HTMLCanvasElement {
  75974. requestPointerLock(): void;
  75975. msRequestPointerLock?(): void;
  75976. mozRequestPointerLock?(): void;
  75977. webkitRequestPointerLock?(): void;
  75978. /** Track wether a record is in progress */
  75979. isRecording: boolean;
  75980. /** Capture Stream method defined by some browsers */
  75981. captureStream(fps?: number): MediaStream;
  75982. }
  75983. interface CanvasRenderingContext2D {
  75984. msImageSmoothingEnabled: boolean;
  75985. }
  75986. interface MouseEvent {
  75987. mozMovementX: number;
  75988. mozMovementY: number;
  75989. webkitMovementX: number;
  75990. webkitMovementY: number;
  75991. msMovementX: number;
  75992. msMovementY: number;
  75993. }
  75994. interface Navigator {
  75995. mozGetVRDevices: (any: any) => any;
  75996. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75997. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75998. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75999. webkitGetGamepads(): Gamepad[];
  76000. msGetGamepads(): Gamepad[];
  76001. webkitGamepads(): Gamepad[];
  76002. }
  76003. interface HTMLVideoElement {
  76004. mozSrcObject: any;
  76005. }
  76006. interface Math {
  76007. fround(x: number): number;
  76008. imul(a: number, b: number): number;
  76009. }
  76010. interface WebGLRenderingContext {
  76011. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  76012. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  76013. vertexAttribDivisor(index: number, divisor: number): void;
  76014. createVertexArray(): any;
  76015. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  76016. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  76017. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  76018. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  76019. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  76020. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  76021. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  76022. // Queries
  76023. createQuery(): WebGLQuery;
  76024. deleteQuery(query: WebGLQuery): void;
  76025. beginQuery(target: number, query: WebGLQuery): void;
  76026. endQuery(target: number): void;
  76027. getQueryParameter(query: WebGLQuery, pname: number): any;
  76028. getQuery(target: number, pname: number): any;
  76029. MAX_SAMPLES: number;
  76030. RGBA8: number;
  76031. READ_FRAMEBUFFER: number;
  76032. DRAW_FRAMEBUFFER: number;
  76033. UNIFORM_BUFFER: number;
  76034. HALF_FLOAT_OES: number;
  76035. RGBA16F: number;
  76036. RGBA32F: number;
  76037. R32F: number;
  76038. RG32F: number;
  76039. RGB32F: number;
  76040. R16F: number;
  76041. RG16F: number;
  76042. RGB16F: number;
  76043. RED: number;
  76044. RG: number;
  76045. R8: number;
  76046. RG8: number;
  76047. UNSIGNED_INT_24_8: number;
  76048. DEPTH24_STENCIL8: number;
  76049. MIN: number;
  76050. MAX: number;
  76051. /* Multiple Render Targets */
  76052. drawBuffers(buffers: number[]): void;
  76053. readBuffer(src: number): void;
  76054. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  76055. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  76056. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  76057. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  76058. // Occlusion Query
  76059. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  76060. ANY_SAMPLES_PASSED: number;
  76061. QUERY_RESULT_AVAILABLE: number;
  76062. QUERY_RESULT: number;
  76063. }
  76064. interface WebGLProgram {
  76065. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  76066. }
  76067. interface EXT_disjoint_timer_query {
  76068. QUERY_COUNTER_BITS_EXT: number;
  76069. TIME_ELAPSED_EXT: number;
  76070. TIMESTAMP_EXT: number;
  76071. GPU_DISJOINT_EXT: number;
  76072. QUERY_RESULT_EXT: number;
  76073. QUERY_RESULT_AVAILABLE_EXT: number;
  76074. queryCounterEXT(query: WebGLQuery, target: number): void;
  76075. createQueryEXT(): WebGLQuery;
  76076. beginQueryEXT(target: number, query: WebGLQuery): void;
  76077. endQueryEXT(target: number): void;
  76078. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  76079. deleteQueryEXT(query: WebGLQuery): void;
  76080. }
  76081. interface WebGLUniformLocation {
  76082. _currentState: any;
  76083. }
  76084. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  76085. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  76086. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  76087. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76088. interface WebGLRenderingContext {
  76089. readonly RASTERIZER_DISCARD: number;
  76090. readonly DEPTH_COMPONENT24: number;
  76091. readonly TEXTURE_3D: number;
  76092. readonly TEXTURE_2D_ARRAY: number;
  76093. readonly TEXTURE_COMPARE_FUNC: number;
  76094. readonly TEXTURE_COMPARE_MODE: number;
  76095. readonly COMPARE_REF_TO_TEXTURE: number;
  76096. readonly TEXTURE_WRAP_R: number;
  76097. readonly HALF_FLOAT: number;
  76098. readonly RGB8: number;
  76099. readonly RED_INTEGER: number;
  76100. readonly RG_INTEGER: number;
  76101. readonly RGB_INTEGER: number;
  76102. readonly RGBA_INTEGER: number;
  76103. readonly R8_SNORM: number;
  76104. readonly RG8_SNORM: number;
  76105. readonly RGB8_SNORM: number;
  76106. readonly RGBA8_SNORM: number;
  76107. readonly R8I: number;
  76108. readonly RG8I: number;
  76109. readonly RGB8I: number;
  76110. readonly RGBA8I: number;
  76111. readonly R8UI: number;
  76112. readonly RG8UI: number;
  76113. readonly RGB8UI: number;
  76114. readonly RGBA8UI: number;
  76115. readonly R16I: number;
  76116. readonly RG16I: number;
  76117. readonly RGB16I: number;
  76118. readonly RGBA16I: number;
  76119. readonly R16UI: number;
  76120. readonly RG16UI: number;
  76121. readonly RGB16UI: number;
  76122. readonly RGBA16UI: number;
  76123. readonly R32I: number;
  76124. readonly RG32I: number;
  76125. readonly RGB32I: number;
  76126. readonly RGBA32I: number;
  76127. readonly R32UI: number;
  76128. readonly RG32UI: number;
  76129. readonly RGB32UI: number;
  76130. readonly RGBA32UI: number;
  76131. readonly RGB10_A2UI: number;
  76132. readonly R11F_G11F_B10F: number;
  76133. readonly RGB9_E5: number;
  76134. readonly RGB10_A2: number;
  76135. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  76136. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  76137. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  76138. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  76139. readonly DEPTH_COMPONENT32F: number;
  76140. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  76141. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  76142. 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;
  76143. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  76144. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  76145. readonly TRANSFORM_FEEDBACK: number;
  76146. readonly INTERLEAVED_ATTRIBS: number;
  76147. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  76148. createTransformFeedback(): WebGLTransformFeedback;
  76149. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  76150. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  76151. beginTransformFeedback(primitiveMode: number): void;
  76152. endTransformFeedback(): void;
  76153. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  76154. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76155. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76156. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76157. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  76158. }
  76159. interface ImageBitmap {
  76160. readonly width: number;
  76161. readonly height: number;
  76162. close(): void;
  76163. }
  76164. interface WebGLQuery extends WebGLObject {
  76165. }
  76166. declare var WebGLQuery: {
  76167. prototype: WebGLQuery;
  76168. new(): WebGLQuery;
  76169. };
  76170. interface WebGLSampler extends WebGLObject {
  76171. }
  76172. declare var WebGLSampler: {
  76173. prototype: WebGLSampler;
  76174. new(): WebGLSampler;
  76175. };
  76176. interface WebGLSync extends WebGLObject {
  76177. }
  76178. declare var WebGLSync: {
  76179. prototype: WebGLSync;
  76180. new(): WebGLSync;
  76181. };
  76182. interface WebGLTransformFeedback extends WebGLObject {
  76183. }
  76184. declare var WebGLTransformFeedback: {
  76185. prototype: WebGLTransformFeedback;
  76186. new(): WebGLTransformFeedback;
  76187. };
  76188. interface WebGLVertexArrayObject extends WebGLObject {
  76189. }
  76190. declare var WebGLVertexArrayObject: {
  76191. prototype: WebGLVertexArrayObject;
  76192. new(): WebGLVertexArrayObject;
  76193. };
  76194. // Type definitions for WebVR API
  76195. // Project: https://w3c.github.io/webvr/
  76196. // Definitions by: six a <https://github.com/lostfictions>
  76197. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76198. interface VRDisplay extends EventTarget {
  76199. /**
  76200. * Dictionary of capabilities describing the VRDisplay.
  76201. */
  76202. readonly capabilities: VRDisplayCapabilities;
  76203. /**
  76204. * z-depth defining the far plane of the eye view frustum
  76205. * enables mapping of values in the render target depth
  76206. * attachment to scene coordinates. Initially set to 10000.0.
  76207. */
  76208. depthFar: number;
  76209. /**
  76210. * z-depth defining the near plane of the eye view frustum
  76211. * enables mapping of values in the render target depth
  76212. * attachment to scene coordinates. Initially set to 0.01.
  76213. */
  76214. depthNear: number;
  76215. /**
  76216. * An identifier for this distinct VRDisplay. Used as an
  76217. * association point in the Gamepad API.
  76218. */
  76219. readonly displayId: number;
  76220. /**
  76221. * A display name, a user-readable name identifying it.
  76222. */
  76223. readonly displayName: string;
  76224. readonly isConnected: boolean;
  76225. readonly isPresenting: boolean;
  76226. /**
  76227. * If this VRDisplay supports room-scale experiences, the optional
  76228. * stage attribute contains details on the room-scale parameters.
  76229. */
  76230. readonly stageParameters: VRStageParameters | null;
  76231. /**
  76232. * Passing the value returned by `requestAnimationFrame` to
  76233. * `cancelAnimationFrame` will unregister the callback.
  76234. * @param handle Define the hanle of the request to cancel
  76235. */
  76236. cancelAnimationFrame(handle: number): void;
  76237. /**
  76238. * Stops presenting to the VRDisplay.
  76239. * @returns a promise to know when it stopped
  76240. */
  76241. exitPresent(): Promise<void>;
  76242. /**
  76243. * Return the current VREyeParameters for the given eye.
  76244. * @param whichEye Define the eye we want the parameter for
  76245. * @returns the eye parameters
  76246. */
  76247. getEyeParameters(whichEye: string): VREyeParameters;
  76248. /**
  76249. * Populates the passed VRFrameData with the information required to render
  76250. * the current frame.
  76251. * @param frameData Define the data structure to populate
  76252. * @returns true if ok otherwise false
  76253. */
  76254. getFrameData(frameData: VRFrameData): boolean;
  76255. /**
  76256. * Get the layers currently being presented.
  76257. * @returns the list of VR layers
  76258. */
  76259. getLayers(): VRLayer[];
  76260. /**
  76261. * Return a VRPose containing the future predicted pose of the VRDisplay
  76262. * when the current frame will be presented. The value returned will not
  76263. * change until JavaScript has returned control to the browser.
  76264. *
  76265. * The VRPose will contain the position, orientation, velocity,
  76266. * and acceleration of each of these properties.
  76267. * @returns the pose object
  76268. */
  76269. getPose(): VRPose;
  76270. /**
  76271. * Return the current instantaneous pose of the VRDisplay, with no
  76272. * prediction applied.
  76273. * @returns the current instantaneous pose
  76274. */
  76275. getImmediatePose(): VRPose;
  76276. /**
  76277. * The callback passed to `requestAnimationFrame` will be called
  76278. * any time a new frame should be rendered. When the VRDisplay is
  76279. * presenting the callback will be called at the native refresh
  76280. * rate of the HMD. When not presenting this function acts
  76281. * identically to how window.requestAnimationFrame acts. Content should
  76282. * make no assumptions of frame rate or vsync behavior as the HMD runs
  76283. * asynchronously from other displays and at differing refresh rates.
  76284. * @param callback Define the eaction to run next frame
  76285. * @returns the request handle it
  76286. */
  76287. requestAnimationFrame(callback: FrameRequestCallback): number;
  76288. /**
  76289. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  76290. * Repeat calls while already presenting will update the VRLayers being displayed.
  76291. * @param layers Define the list of layer to present
  76292. * @returns a promise to know when the request has been fulfilled
  76293. */
  76294. requestPresent(layers: VRLayer[]): Promise<void>;
  76295. /**
  76296. * Reset the pose for this display, treating its current position and
  76297. * orientation as the "origin/zero" values. VRPose.position,
  76298. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  76299. * updated when calling resetPose(). This should be called in only
  76300. * sitting-space experiences.
  76301. */
  76302. resetPose(): void;
  76303. /**
  76304. * The VRLayer provided to the VRDisplay will be captured and presented
  76305. * in the HMD. Calling this function has the same effect on the source
  76306. * canvas as any other operation that uses its source image, and canvases
  76307. * created without preserveDrawingBuffer set to true will be cleared.
  76308. * @param pose Define the pose to submit
  76309. */
  76310. submitFrame(pose?: VRPose): void;
  76311. }
  76312. declare var VRDisplay: {
  76313. prototype: VRDisplay;
  76314. new(): VRDisplay;
  76315. };
  76316. interface VRLayer {
  76317. leftBounds?: number[] | Float32Array | null;
  76318. rightBounds?: number[] | Float32Array | null;
  76319. source?: HTMLCanvasElement | null;
  76320. }
  76321. interface VRDisplayCapabilities {
  76322. readonly canPresent: boolean;
  76323. readonly hasExternalDisplay: boolean;
  76324. readonly hasOrientation: boolean;
  76325. readonly hasPosition: boolean;
  76326. readonly maxLayers: number;
  76327. }
  76328. interface VREyeParameters {
  76329. /** @deprecated */
  76330. readonly fieldOfView: VRFieldOfView;
  76331. readonly offset: Float32Array;
  76332. readonly renderHeight: number;
  76333. readonly renderWidth: number;
  76334. }
  76335. interface VRFieldOfView {
  76336. readonly downDegrees: number;
  76337. readonly leftDegrees: number;
  76338. readonly rightDegrees: number;
  76339. readonly upDegrees: number;
  76340. }
  76341. interface VRFrameData {
  76342. readonly leftProjectionMatrix: Float32Array;
  76343. readonly leftViewMatrix: Float32Array;
  76344. readonly pose: VRPose;
  76345. readonly rightProjectionMatrix: Float32Array;
  76346. readonly rightViewMatrix: Float32Array;
  76347. readonly timestamp: number;
  76348. }
  76349. interface VRPose {
  76350. readonly angularAcceleration: Float32Array | null;
  76351. readonly angularVelocity: Float32Array | null;
  76352. readonly linearAcceleration: Float32Array | null;
  76353. readonly linearVelocity: Float32Array | null;
  76354. readonly orientation: Float32Array | null;
  76355. readonly position: Float32Array | null;
  76356. readonly timestamp: number;
  76357. }
  76358. interface VRStageParameters {
  76359. sittingToStandingTransform?: Float32Array;
  76360. sizeX?: number;
  76361. sizeY?: number;
  76362. }
  76363. interface Navigator {
  76364. getVRDisplays(): Promise<VRDisplay[]>;
  76365. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  76366. }
  76367. interface Window {
  76368. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  76369. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  76370. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  76371. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  76372. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  76373. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  76374. }
  76375. interface Gamepad {
  76376. readonly displayId: number;
  76377. }
  76378. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  76379. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  76380. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  76381. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  76382. type XRHandedness = "none" | "left" | "right";
  76383. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  76384. type XREye = "none" | "left" | "right";
  76385. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  76386. interface XRSpace extends EventTarget {}
  76387. interface XRRenderState {
  76388. depthNear?: number;
  76389. depthFar?: number;
  76390. inlineVerticalFieldOfView?: number;
  76391. baseLayer?: XRWebGLLayer;
  76392. }
  76393. interface XRInputSource {
  76394. handedness: XRHandedness;
  76395. targetRayMode: XRTargetRayMode;
  76396. targetRaySpace: XRSpace;
  76397. gripSpace: XRSpace | undefined;
  76398. gamepad: Gamepad | undefined;
  76399. profiles: Array<string>;
  76400. hand: XRHand | undefined;
  76401. }
  76402. interface XRSessionInit {
  76403. optionalFeatures?: string[];
  76404. requiredFeatures?: string[];
  76405. }
  76406. interface XRSession {
  76407. addEventListener: Function;
  76408. removeEventListener: Function;
  76409. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  76410. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  76411. requestAnimationFrame: Function;
  76412. end(): Promise<void>;
  76413. renderState: XRRenderState;
  76414. inputSources: Array<XRInputSource>;
  76415. // hit test
  76416. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  76417. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  76418. // legacy AR hit test
  76419. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76420. // legacy plane detection
  76421. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  76422. }
  76423. interface XRReferenceSpace extends XRSpace {
  76424. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  76425. onreset: any;
  76426. }
  76427. type XRPlaneSet = Set<XRPlane>;
  76428. type XRAnchorSet = Set<XRAnchor>;
  76429. interface XRFrame {
  76430. session: XRSession;
  76431. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  76432. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  76433. // AR
  76434. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  76435. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  76436. // Anchors
  76437. trackedAnchors?: XRAnchorSet;
  76438. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  76439. // Planes
  76440. worldInformation: {
  76441. detectedPlanes?: XRPlaneSet;
  76442. };
  76443. // Hand tracking
  76444. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  76445. }
  76446. interface XRViewerPose extends XRPose {
  76447. views: Array<XRView>;
  76448. }
  76449. interface XRPose {
  76450. transform: XRRigidTransform;
  76451. emulatedPosition: boolean;
  76452. }
  76453. interface XRWebGLLayerOptions {
  76454. antialias?: boolean;
  76455. depth?: boolean;
  76456. stencil?: boolean;
  76457. alpha?: boolean;
  76458. multiview?: boolean;
  76459. framebufferScaleFactor?: number;
  76460. }
  76461. declare var XRWebGLLayer: {
  76462. prototype: XRWebGLLayer;
  76463. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  76464. };
  76465. interface XRWebGLLayer {
  76466. framebuffer: WebGLFramebuffer;
  76467. framebufferWidth: number;
  76468. framebufferHeight: number;
  76469. getViewport: Function;
  76470. }
  76471. declare class XRRigidTransform {
  76472. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  76473. position: DOMPointReadOnly;
  76474. orientation: DOMPointReadOnly;
  76475. matrix: Float32Array;
  76476. inverse: XRRigidTransform;
  76477. }
  76478. interface XRView {
  76479. eye: XREye;
  76480. projectionMatrix: Float32Array;
  76481. transform: XRRigidTransform;
  76482. }
  76483. interface XRInputSourceChangeEvent {
  76484. session: XRSession;
  76485. removed: Array<XRInputSource>;
  76486. added: Array<XRInputSource>;
  76487. }
  76488. interface XRInputSourceEvent extends Event {
  76489. readonly frame: XRFrame;
  76490. readonly inputSource: XRInputSource;
  76491. }
  76492. // Experimental(er) features
  76493. declare class XRRay {
  76494. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  76495. origin: DOMPointReadOnly;
  76496. direction: DOMPointReadOnly;
  76497. matrix: Float32Array;
  76498. }
  76499. declare enum XRHitTestTrackableType {
  76500. "point",
  76501. "plane",
  76502. "mesh",
  76503. }
  76504. interface XRHitResult {
  76505. hitMatrix: Float32Array;
  76506. }
  76507. interface XRTransientInputHitTestResult {
  76508. readonly inputSource: XRInputSource;
  76509. readonly results: Array<XRHitTestResult>;
  76510. }
  76511. interface XRHitTestResult {
  76512. getPose(baseSpace: XRSpace): XRPose | undefined;
  76513. // When anchor system is enabled
  76514. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  76515. }
  76516. interface XRHitTestSource {
  76517. cancel(): void;
  76518. }
  76519. interface XRTransientInputHitTestSource {
  76520. cancel(): void;
  76521. }
  76522. interface XRHitTestOptionsInit {
  76523. space: XRSpace;
  76524. entityTypes?: Array<XRHitTestTrackableType>;
  76525. offsetRay?: XRRay;
  76526. }
  76527. interface XRTransientInputHitTestOptionsInit {
  76528. profile: string;
  76529. entityTypes?: Array<XRHitTestTrackableType>;
  76530. offsetRay?: XRRay;
  76531. }
  76532. interface XRAnchor {
  76533. anchorSpace: XRSpace;
  76534. delete(): void;
  76535. }
  76536. interface XRPlane {
  76537. orientation: "Horizontal" | "Vertical";
  76538. planeSpace: XRSpace;
  76539. polygon: Array<DOMPointReadOnly>;
  76540. lastChangedTime: number;
  76541. }
  76542. interface XRJointSpace extends XRSpace {}
  76543. interface XRJointPose extends XRPose {
  76544. radius: number | undefined;
  76545. }
  76546. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  76547. readonly length: number;
  76548. [index: number]: XRJointSpace;
  76549. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  76550. readonly WRIST: number;
  76551. readonly THUMB_METACARPAL: number;
  76552. readonly THUMB_PHALANX_PROXIMAL: number;
  76553. readonly THUMB_PHALANX_DISTAL: number;
  76554. readonly THUMB_PHALANX_TIP: number;
  76555. readonly INDEX_METACARPAL: number;
  76556. readonly INDEX_PHALANX_PROXIMAL: number;
  76557. readonly INDEX_PHALANX_INTERMEDIATE: number;
  76558. readonly INDEX_PHALANX_DISTAL: number;
  76559. readonly INDEX_PHALANX_TIP: number;
  76560. readonly MIDDLE_METACARPAL: number;
  76561. readonly MIDDLE_PHALANX_PROXIMAL: number;
  76562. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  76563. readonly MIDDLE_PHALANX_DISTAL: number;
  76564. readonly MIDDLE_PHALANX_TIP: number;
  76565. readonly RING_METACARPAL: number;
  76566. readonly RING_PHALANX_PROXIMAL: number;
  76567. readonly RING_PHALANX_INTERMEDIATE: number;
  76568. readonly RING_PHALANX_DISTAL: number;
  76569. readonly RING_PHALANX_TIP: number;
  76570. readonly LITTLE_METACARPAL: number;
  76571. readonly LITTLE_PHALANX_PROXIMAL: number;
  76572. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  76573. readonly LITTLE_PHALANX_DISTAL: number;
  76574. readonly LITTLE_PHALANX_TIP: number;
  76575. }
  76576. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  76577. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  76578. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  76579. interface XRSession {
  76580. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  76581. }
  76582. interface XRFrame {
  76583. featurePointCloud? : Array<number>;
  76584. }
  76585. /**
  76586. * @ignore
  76587. */
  76588. declare module BABYLON.GLTF2.Exporter {
  76589. }
  76590. /**
  76591. * @ignore
  76592. */
  76593. declare module BABYLON.GLTF1 {
  76594. }
  76595. declare module BABYLON.GUI {
  76596. /**
  76597. * Class used to specific a value and its associated unit
  76598. */
  76599. export class ValueAndUnit {
  76600. /** defines the unit to store */
  76601. unit: number;
  76602. /** defines a boolean indicating if the value can be negative */
  76603. negativeValueAllowed: boolean;
  76604. private _value;
  76605. private _originalUnit;
  76606. /**
  76607. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  76608. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76609. */
  76610. ignoreAdaptiveScaling: boolean;
  76611. /**
  76612. * Creates a new ValueAndUnit
  76613. * @param value defines the value to store
  76614. * @param unit defines the unit to store
  76615. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  76616. */
  76617. constructor(value: number,
  76618. /** defines the unit to store */
  76619. unit?: number,
  76620. /** defines a boolean indicating if the value can be negative */
  76621. negativeValueAllowed?: boolean);
  76622. /** Gets a boolean indicating if the value is a percentage */
  76623. get isPercentage(): boolean;
  76624. /** Gets a boolean indicating if the value is store as pixel */
  76625. get isPixel(): boolean;
  76626. /** Gets direct internal value */
  76627. get internalValue(): number;
  76628. /**
  76629. * Gets value as pixel
  76630. * @param host defines the root host
  76631. * @param refValue defines the reference value for percentages
  76632. * @returns the value as pixel
  76633. */
  76634. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  76635. /**
  76636. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  76637. * @param value defines the value to store
  76638. * @param unit defines the unit to store
  76639. * @returns the current ValueAndUnit
  76640. */
  76641. updateInPlace(value: number, unit?: number): ValueAndUnit;
  76642. /**
  76643. * Gets the value accordingly to its unit
  76644. * @param host defines the root host
  76645. * @returns the value
  76646. */
  76647. getValue(host: AdvancedDynamicTexture): number;
  76648. /**
  76649. * Gets a string representation of the value
  76650. * @param host defines the root host
  76651. * @param decimals defines an optional number of decimals to display
  76652. * @returns a string
  76653. */
  76654. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  76655. /**
  76656. * Store a value parsed from a string
  76657. * @param source defines the source string
  76658. * @returns true if the value was successfully parsed
  76659. */
  76660. fromString(source: string | number): boolean;
  76661. private static _Regex;
  76662. private static _UNITMODE_PERCENTAGE;
  76663. private static _UNITMODE_PIXEL;
  76664. /** UNITMODE_PERCENTAGE */
  76665. static get UNITMODE_PERCENTAGE(): number;
  76666. /** UNITMODE_PIXEL */
  76667. static get UNITMODE_PIXEL(): number;
  76668. }
  76669. }
  76670. declare module BABYLON.GUI {
  76671. /**
  76672. * Define a style used by control to automatically setup properties based on a template.
  76673. * Only support font related properties so far
  76674. */
  76675. export class Style implements BABYLON.IDisposable {
  76676. private _fontFamily;
  76677. private _fontStyle;
  76678. private _fontWeight;
  76679. /** @hidden */
  76680. _host: AdvancedDynamicTexture;
  76681. /** @hidden */
  76682. _fontSize: ValueAndUnit;
  76683. /**
  76684. * BABYLON.Observable raised when the style values are changed
  76685. */
  76686. onChangedObservable: BABYLON.Observable<Style>;
  76687. /**
  76688. * Creates a new style object
  76689. * @param host defines the AdvancedDynamicTexture which hosts this style
  76690. */
  76691. constructor(host: AdvancedDynamicTexture);
  76692. /**
  76693. * Gets or sets the font size
  76694. */
  76695. get fontSize(): string | number;
  76696. set fontSize(value: string | number);
  76697. /**
  76698. * Gets or sets the font family
  76699. */
  76700. get fontFamily(): string;
  76701. set fontFamily(value: string);
  76702. /**
  76703. * Gets or sets the font style
  76704. */
  76705. get fontStyle(): string;
  76706. set fontStyle(value: string);
  76707. /** Gets or sets font weight */
  76708. get fontWeight(): string;
  76709. set fontWeight(value: string);
  76710. /** Dispose all associated resources */
  76711. dispose(): void;
  76712. }
  76713. }
  76714. declare module BABYLON.GUI {
  76715. /**
  76716. * Class used to transport BABYLON.Vector2 information for pointer events
  76717. */
  76718. export class Vector2WithInfo extends BABYLON.Vector2 {
  76719. /** defines the current mouse button index */
  76720. buttonIndex: number;
  76721. /**
  76722. * Creates a new Vector2WithInfo
  76723. * @param source defines the vector2 data to transport
  76724. * @param buttonIndex defines the current mouse button index
  76725. */
  76726. constructor(source: BABYLON.Vector2,
  76727. /** defines the current mouse button index */
  76728. buttonIndex?: number);
  76729. }
  76730. /** Class used to provide 2D matrix features */
  76731. export class Matrix2D {
  76732. /** Gets the internal array of 6 floats used to store matrix data */
  76733. m: Float32Array;
  76734. /**
  76735. * Creates a new matrix
  76736. * @param m00 defines value for (0, 0)
  76737. * @param m01 defines value for (0, 1)
  76738. * @param m10 defines value for (1, 0)
  76739. * @param m11 defines value for (1, 1)
  76740. * @param m20 defines value for (2, 0)
  76741. * @param m21 defines value for (2, 1)
  76742. */
  76743. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  76744. /**
  76745. * Fills the matrix from direct values
  76746. * @param m00 defines value for (0, 0)
  76747. * @param m01 defines value for (0, 1)
  76748. * @param m10 defines value for (1, 0)
  76749. * @param m11 defines value for (1, 1)
  76750. * @param m20 defines value for (2, 0)
  76751. * @param m21 defines value for (2, 1)
  76752. * @returns the current modified matrix
  76753. */
  76754. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  76755. /**
  76756. * Gets matrix determinant
  76757. * @returns the determinant
  76758. */
  76759. determinant(): number;
  76760. /**
  76761. * Inverses the matrix and stores it in a target matrix
  76762. * @param result defines the target matrix
  76763. * @returns the current matrix
  76764. */
  76765. invertToRef(result: Matrix2D): Matrix2D;
  76766. /**
  76767. * Multiplies the current matrix with another one
  76768. * @param other defines the second operand
  76769. * @param result defines the target matrix
  76770. * @returns the current matrix
  76771. */
  76772. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  76773. /**
  76774. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  76775. * @param x defines the x coordinate to transform
  76776. * @param y defines the x coordinate to transform
  76777. * @param result defines the target vector2
  76778. * @returns the current matrix
  76779. */
  76780. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  76781. /**
  76782. * Creates an identity matrix
  76783. * @returns a new matrix
  76784. */
  76785. static Identity(): Matrix2D;
  76786. /**
  76787. * Creates a translation matrix and stores it in a target matrix
  76788. * @param x defines the x coordinate of the translation
  76789. * @param y defines the y coordinate of the translation
  76790. * @param result defines the target matrix
  76791. */
  76792. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  76793. /**
  76794. * Creates a scaling matrix and stores it in a target matrix
  76795. * @param x defines the x coordinate of the scaling
  76796. * @param y defines the y coordinate of the scaling
  76797. * @param result defines the target matrix
  76798. */
  76799. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  76800. /**
  76801. * Creates a rotation matrix and stores it in a target matrix
  76802. * @param angle defines the rotation angle
  76803. * @param result defines the target matrix
  76804. */
  76805. static RotationToRef(angle: number, result: Matrix2D): void;
  76806. private static _TempPreTranslationMatrix;
  76807. private static _TempPostTranslationMatrix;
  76808. private static _TempRotationMatrix;
  76809. private static _TempScalingMatrix;
  76810. private static _TempCompose0;
  76811. private static _TempCompose1;
  76812. private static _TempCompose2;
  76813. /**
  76814. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  76815. * @param tx defines the x coordinate of the translation
  76816. * @param ty defines the y coordinate of the translation
  76817. * @param angle defines the rotation angle
  76818. * @param scaleX defines the x coordinate of the scaling
  76819. * @param scaleY defines the y coordinate of the scaling
  76820. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  76821. * @param result defines the target matrix
  76822. */
  76823. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  76824. }
  76825. }
  76826. declare module BABYLON.GUI {
  76827. /**
  76828. * Class used to store 2D control sizes
  76829. */
  76830. export class Measure {
  76831. /** defines left coordinate */
  76832. left: number;
  76833. /** defines top coordinate */
  76834. top: number;
  76835. /** defines width dimension */
  76836. width: number;
  76837. /** defines height dimension */
  76838. height: number;
  76839. /**
  76840. * Creates a new measure
  76841. * @param left defines left coordinate
  76842. * @param top defines top coordinate
  76843. * @param width defines width dimension
  76844. * @param height defines height dimension
  76845. */
  76846. constructor(
  76847. /** defines left coordinate */
  76848. left: number,
  76849. /** defines top coordinate */
  76850. top: number,
  76851. /** defines width dimension */
  76852. width: number,
  76853. /** defines height dimension */
  76854. height: number);
  76855. /**
  76856. * Copy from another measure
  76857. * @param other defines the other measure to copy from
  76858. */
  76859. copyFrom(other: Measure): void;
  76860. /**
  76861. * Copy from a group of 4 floats
  76862. * @param left defines left coordinate
  76863. * @param top defines top coordinate
  76864. * @param width defines width dimension
  76865. * @param height defines height dimension
  76866. */
  76867. copyFromFloats(left: number, top: number, width: number, height: number): void;
  76868. /**
  76869. * Computes the axis aligned bounding box measure for two given measures
  76870. * @param a Input measure
  76871. * @param b Input measure
  76872. * @param result the resulting bounding measure
  76873. */
  76874. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  76875. /**
  76876. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  76877. * @param transform the matrix to transform the measure before computing the AABB
  76878. * @param addX number to add to left
  76879. * @param addY number to add to top
  76880. * @param addWidth number to add to width
  76881. * @param addHeight number to add to height
  76882. * @param result the resulting AABB
  76883. */
  76884. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  76885. /**
  76886. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  76887. * @param transform the matrix to transform the measure before computing the AABB
  76888. * @param result the resulting AABB
  76889. */
  76890. transformToRef(transform: Matrix2D, result: Measure): void;
  76891. /**
  76892. * Check equality between this measure and another one
  76893. * @param other defines the other measures
  76894. * @returns true if both measures are equals
  76895. */
  76896. isEqualsTo(other: Measure): boolean;
  76897. /**
  76898. * Creates an empty measure
  76899. * @returns a new measure
  76900. */
  76901. static Empty(): Measure;
  76902. }
  76903. }
  76904. declare module BABYLON.GUI {
  76905. /**
  76906. * Interface used to define a control that can receive focus
  76907. */
  76908. export interface IFocusableControl {
  76909. /**
  76910. * Function called when the control receives the focus
  76911. */
  76912. onFocus(): void;
  76913. /**
  76914. * Function called when the control loses the focus
  76915. */
  76916. onBlur(): void;
  76917. /**
  76918. * Function called to let the control handle keyboard events
  76919. * @param evt defines the current keyboard event
  76920. */
  76921. processKeyboard(evt: KeyboardEvent): void;
  76922. /**
  76923. * Function called to get the list of controls that should not steal the focus from this control
  76924. * @returns an array of controls
  76925. */
  76926. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  76927. }
  76928. /**
  76929. * Class used to create texture to support 2D GUI elements
  76930. * @see https://doc.babylonjs.com/how_to/gui
  76931. */
  76932. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  76933. private _isDirty;
  76934. private _renderObserver;
  76935. private _resizeObserver;
  76936. private _preKeyboardObserver;
  76937. private _pointerMoveObserver;
  76938. private _pointerObserver;
  76939. private _canvasPointerOutObserver;
  76940. private _canvasBlurObserver;
  76941. private _background;
  76942. /** @hidden */
  76943. _rootContainer: Container;
  76944. /** @hidden */
  76945. _lastPickedControl: Control;
  76946. /** @hidden */
  76947. _lastControlOver: {
  76948. [pointerId: number]: Control;
  76949. };
  76950. /** @hidden */
  76951. _lastControlDown: {
  76952. [pointerId: number]: Control;
  76953. };
  76954. /** @hidden */
  76955. _capturingControl: {
  76956. [pointerId: number]: Control;
  76957. };
  76958. /** @hidden */
  76959. _shouldBlockPointer: boolean;
  76960. /** @hidden */
  76961. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  76962. /** @hidden */
  76963. _linkedControls: Control[];
  76964. private _isFullscreen;
  76965. private _fullscreenViewport;
  76966. private _idealWidth;
  76967. private _idealHeight;
  76968. private _useSmallestIdeal;
  76969. private _renderAtIdealSize;
  76970. private _focusedControl;
  76971. private _blockNextFocusCheck;
  76972. private _renderScale;
  76973. private _rootElement;
  76974. private _cursorChanged;
  76975. private _defaultMousePointerId;
  76976. /** @hidden */
  76977. _numLayoutCalls: number;
  76978. /** Gets the number of layout calls made the last time the ADT has been rendered */
  76979. get numLayoutCalls(): number;
  76980. /** @hidden */
  76981. _numRenderCalls: number;
  76982. /** Gets the number of render calls made the last time the ADT has been rendered */
  76983. get numRenderCalls(): number;
  76984. /**
  76985. * Define type to string to ensure compatibility across browsers
  76986. * Safari doesn't support DataTransfer constructor
  76987. */
  76988. private _clipboardData;
  76989. /**
  76990. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  76991. */
  76992. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  76993. /**
  76994. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  76995. */
  76996. onControlPickedObservable: BABYLON.Observable<Control>;
  76997. /**
  76998. * BABYLON.Observable event triggered before layout is evaluated
  76999. */
  77000. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77001. /**
  77002. * BABYLON.Observable event triggered after the layout was evaluated
  77003. */
  77004. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77005. /**
  77006. * BABYLON.Observable event triggered before the texture is rendered
  77007. */
  77008. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77009. /**
  77010. * BABYLON.Observable event triggered after the texture was rendered
  77011. */
  77012. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77013. /**
  77014. * Gets or sets a boolean defining if alpha is stored as premultiplied
  77015. */
  77016. premulAlpha: boolean;
  77017. /**
  77018. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  77019. * Useful when you want more antialiasing
  77020. */
  77021. get renderScale(): number;
  77022. set renderScale(value: number);
  77023. /** Gets or sets the background color */
  77024. get background(): string;
  77025. set background(value: string);
  77026. /**
  77027. * Gets or sets the ideal width used to design controls.
  77028. * The GUI will then rescale everything accordingly
  77029. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77030. */
  77031. get idealWidth(): number;
  77032. set idealWidth(value: number);
  77033. /**
  77034. * Gets or sets the ideal height used to design controls.
  77035. * The GUI will then rescale everything accordingly
  77036. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77037. */
  77038. get idealHeight(): number;
  77039. set idealHeight(value: number);
  77040. /**
  77041. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  77042. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77043. */
  77044. get useSmallestIdeal(): boolean;
  77045. set useSmallestIdeal(value: boolean);
  77046. /**
  77047. * Gets or sets a boolean indicating if adaptive scaling must be used
  77048. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77049. */
  77050. get renderAtIdealSize(): boolean;
  77051. set renderAtIdealSize(value: boolean);
  77052. /**
  77053. * Gets the ratio used when in "ideal mode"
  77054. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77055. * */
  77056. get idealRatio(): number;
  77057. /**
  77058. * Gets the underlying layer used to render the texture when in fullscreen mode
  77059. */
  77060. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  77061. /**
  77062. * Gets the root container control
  77063. */
  77064. get rootContainer(): Container;
  77065. /**
  77066. * Returns an array containing the root container.
  77067. * This is mostly used to let the Inspector introspects the ADT
  77068. * @returns an array containing the rootContainer
  77069. */
  77070. getChildren(): Array<Container>;
  77071. /**
  77072. * Will return all controls that are inside this texture
  77073. * @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
  77074. * @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
  77075. * @return all child controls
  77076. */
  77077. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  77078. /**
  77079. * Gets or sets the current focused control
  77080. */
  77081. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  77082. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  77083. /**
  77084. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  77085. */
  77086. get isForeground(): boolean;
  77087. set isForeground(value: boolean);
  77088. /**
  77089. * Gets or set information about clipboardData
  77090. */
  77091. get clipboardData(): string;
  77092. set clipboardData(value: string);
  77093. /**
  77094. * Creates a new AdvancedDynamicTexture
  77095. * @param name defines the name of the texture
  77096. * @param width defines the width of the texture
  77097. * @param height defines the height of the texture
  77098. * @param scene defines the hosting scene
  77099. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  77100. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  77101. */
  77102. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  77103. /**
  77104. * Get the current class name of the texture useful for serialization or dynamic coding.
  77105. * @returns "AdvancedDynamicTexture"
  77106. */
  77107. getClassName(): string;
  77108. /**
  77109. * Function used to execute a function on all controls
  77110. * @param func defines the function to execute
  77111. * @param container defines the container where controls belong. If null the root container will be used
  77112. */
  77113. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  77114. private _useInvalidateRectOptimization;
  77115. /**
  77116. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  77117. */
  77118. get useInvalidateRectOptimization(): boolean;
  77119. set useInvalidateRectOptimization(value: boolean);
  77120. private _invalidatedRectangle;
  77121. /**
  77122. * Invalidates a rectangle area on the gui texture
  77123. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  77124. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  77125. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  77126. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  77127. */
  77128. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  77129. /**
  77130. * Marks the texture as dirty forcing a complete update
  77131. */
  77132. markAsDirty(): void;
  77133. /**
  77134. * Helper function used to create a new style
  77135. * @returns a new style
  77136. * @see https://doc.babylonjs.com/how_to/gui#styles
  77137. */
  77138. createStyle(): Style;
  77139. /**
  77140. * Adds a new control to the root container
  77141. * @param control defines the control to add
  77142. * @returns the current texture
  77143. */
  77144. addControl(control: Control): AdvancedDynamicTexture;
  77145. /**
  77146. * Removes a control from the root container
  77147. * @param control defines the control to remove
  77148. * @returns the current texture
  77149. */
  77150. removeControl(control: Control): AdvancedDynamicTexture;
  77151. /**
  77152. * Release all resources
  77153. */
  77154. dispose(): void;
  77155. private _onResize;
  77156. /** @hidden */
  77157. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  77158. /**
  77159. * Get screen coordinates for a vector3
  77160. * @param position defines the position to project
  77161. * @param worldMatrix defines the world matrix to use
  77162. * @returns the projected position
  77163. */
  77164. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  77165. private _checkUpdate;
  77166. private _clearMeasure;
  77167. private _render;
  77168. /** @hidden */
  77169. _changeCursor(cursor: string): void;
  77170. /** @hidden */
  77171. _registerLastControlDown(control: Control, pointerId: number): void;
  77172. private _doPicking;
  77173. /** @hidden */
  77174. _cleanControlAfterRemovalFromList(list: {
  77175. [pointerId: number]: Control;
  77176. }, control: Control): void;
  77177. /** @hidden */
  77178. _cleanControlAfterRemoval(control: Control): void;
  77179. /** Attach to all scene events required to support pointer events */
  77180. attach(): void;
  77181. /** @hidden */
  77182. private onClipboardCopy;
  77183. /** @hidden */
  77184. private onClipboardCut;
  77185. /** @hidden */
  77186. private onClipboardPaste;
  77187. /**
  77188. * Register the clipboard Events onto the canvas
  77189. */
  77190. registerClipboardEvents(): void;
  77191. /**
  77192. * Unregister the clipboard Events from the canvas
  77193. */
  77194. unRegisterClipboardEvents(): void;
  77195. /**
  77196. * Connect the texture to a hosting mesh to enable interactions
  77197. * @param mesh defines the mesh to attach to
  77198. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  77199. */
  77200. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  77201. /**
  77202. * Move the focus to a specific control
  77203. * @param control defines the control which will receive the focus
  77204. */
  77205. moveFocusToControl(control: IFocusableControl): void;
  77206. private _manageFocus;
  77207. private _attachToOnPointerOut;
  77208. private _attachToOnBlur;
  77209. /**
  77210. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  77211. * @param mesh defines the mesh which will receive the texture
  77212. * @param width defines the texture width (1024 by default)
  77213. * @param height defines the texture height (1024 by default)
  77214. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  77215. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  77216. * @returns a new AdvancedDynamicTexture
  77217. */
  77218. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  77219. /**
  77220. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  77221. * In this mode the texture will rely on a layer for its rendering.
  77222. * This allows it to be treated like any other layer.
  77223. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  77224. * LayerMask is set through advancedTexture.layer.layerMask
  77225. * @param name defines name for the texture
  77226. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  77227. * @param scene defines the hsoting scene
  77228. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  77229. * @returns a new AdvancedDynamicTexture
  77230. */
  77231. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  77232. }
  77233. }
  77234. declare module BABYLON.GUI {
  77235. /**
  77236. * Root class used for all 2D controls
  77237. * @see https://doc.babylonjs.com/how_to/gui#controls
  77238. */
  77239. export class Control {
  77240. /** defines the name of the control */
  77241. name?: string | undefined;
  77242. /**
  77243. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  77244. */
  77245. static AllowAlphaInheritance: boolean;
  77246. private _alpha;
  77247. private _alphaSet;
  77248. private _zIndex;
  77249. /** @hidden */
  77250. _host: AdvancedDynamicTexture;
  77251. /** Gets or sets the control parent */
  77252. parent: BABYLON.Nullable<Container>;
  77253. /** @hidden */
  77254. _currentMeasure: Measure;
  77255. private _fontFamily;
  77256. private _fontStyle;
  77257. private _fontWeight;
  77258. private _fontSize;
  77259. private _font;
  77260. /** @hidden */
  77261. _width: ValueAndUnit;
  77262. /** @hidden */
  77263. _height: ValueAndUnit;
  77264. /** @hidden */
  77265. protected _fontOffset: {
  77266. ascent: number;
  77267. height: number;
  77268. descent: number;
  77269. };
  77270. private _color;
  77271. private _style;
  77272. private _styleObserver;
  77273. /** @hidden */
  77274. protected _horizontalAlignment: number;
  77275. /** @hidden */
  77276. protected _verticalAlignment: number;
  77277. /** @hidden */
  77278. protected _isDirty: boolean;
  77279. /** @hidden */
  77280. protected _wasDirty: boolean;
  77281. /** @hidden */
  77282. _tempParentMeasure: Measure;
  77283. /** @hidden */
  77284. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  77285. /** @hidden */
  77286. protected _cachedParentMeasure: Measure;
  77287. private _paddingLeft;
  77288. private _paddingRight;
  77289. private _paddingTop;
  77290. private _paddingBottom;
  77291. /** @hidden */
  77292. _left: ValueAndUnit;
  77293. /** @hidden */
  77294. _top: ValueAndUnit;
  77295. private _scaleX;
  77296. private _scaleY;
  77297. private _rotation;
  77298. private _transformCenterX;
  77299. private _transformCenterY;
  77300. /** @hidden */
  77301. _transformMatrix: Matrix2D;
  77302. /** @hidden */
  77303. protected _invertTransformMatrix: Matrix2D;
  77304. /** @hidden */
  77305. protected _transformedPosition: BABYLON.Vector2;
  77306. private _isMatrixDirty;
  77307. private _cachedOffsetX;
  77308. private _cachedOffsetY;
  77309. private _isVisible;
  77310. private _isHighlighted;
  77311. /** @hidden */
  77312. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  77313. private _fontSet;
  77314. private _dummyVector2;
  77315. private _downCount;
  77316. private _enterCount;
  77317. private _doNotRender;
  77318. private _downPointerIds;
  77319. protected _isEnabled: boolean;
  77320. protected _disabledColor: string;
  77321. protected _disabledColorItem: string;
  77322. /** @hidden */
  77323. protected _rebuildLayout: boolean;
  77324. /** @hidden */
  77325. _customData: any;
  77326. /** @hidden */
  77327. _isClipped: boolean;
  77328. /** @hidden */
  77329. _automaticSize: boolean;
  77330. /** @hidden */
  77331. _tag: any;
  77332. /**
  77333. * 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
  77334. */
  77335. uniqueId: number;
  77336. /**
  77337. * Gets or sets an object used to store user defined information for the node
  77338. */
  77339. metadata: any;
  77340. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  77341. isHitTestVisible: boolean;
  77342. /** Gets or sets a boolean indicating if the control can block pointer events */
  77343. isPointerBlocker: boolean;
  77344. /** Gets or sets a boolean indicating if the control can be focusable */
  77345. isFocusInvisible: boolean;
  77346. /**
  77347. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  77348. * 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
  77349. */
  77350. clipChildren: boolean;
  77351. /**
  77352. * Gets or sets a boolean indicating that control content must be clipped
  77353. * 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
  77354. */
  77355. clipContent: boolean;
  77356. /**
  77357. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  77358. */
  77359. useBitmapCache: boolean;
  77360. private _cacheData;
  77361. private _shadowOffsetX;
  77362. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  77363. get shadowOffsetX(): number;
  77364. set shadowOffsetX(value: number);
  77365. private _shadowOffsetY;
  77366. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  77367. get shadowOffsetY(): number;
  77368. set shadowOffsetY(value: number);
  77369. private _shadowBlur;
  77370. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  77371. get shadowBlur(): number;
  77372. set shadowBlur(value: number);
  77373. private _shadowColor;
  77374. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  77375. get shadowColor(): string;
  77376. set shadowColor(value: string);
  77377. /** Gets or sets the cursor to use when the control is hovered */
  77378. hoverCursor: string;
  77379. /** @hidden */
  77380. protected _linkOffsetX: ValueAndUnit;
  77381. /** @hidden */
  77382. protected _linkOffsetY: ValueAndUnit;
  77383. /** Gets the control type name */
  77384. get typeName(): string;
  77385. /**
  77386. * Get the current class name of the control.
  77387. * @returns current class name
  77388. */
  77389. getClassName(): string;
  77390. /**
  77391. * An event triggered when pointer wheel is scrolled
  77392. */
  77393. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  77394. /**
  77395. * An event triggered when the pointer move over the control.
  77396. */
  77397. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  77398. /**
  77399. * An event triggered when the pointer move out of the control.
  77400. */
  77401. onPointerOutObservable: BABYLON.Observable<Control>;
  77402. /**
  77403. * An event triggered when the pointer taps the control
  77404. */
  77405. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  77406. /**
  77407. * An event triggered when pointer up
  77408. */
  77409. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  77410. /**
  77411. * An event triggered when a control is clicked on
  77412. */
  77413. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  77414. /**
  77415. * An event triggered when pointer enters the control
  77416. */
  77417. onPointerEnterObservable: BABYLON.Observable<Control>;
  77418. /**
  77419. * An event triggered when the control is marked as dirty
  77420. */
  77421. onDirtyObservable: BABYLON.Observable<Control>;
  77422. /**
  77423. * An event triggered before drawing the control
  77424. */
  77425. onBeforeDrawObservable: BABYLON.Observable<Control>;
  77426. /**
  77427. * An event triggered after the control was drawn
  77428. */
  77429. onAfterDrawObservable: BABYLON.Observable<Control>;
  77430. /**
  77431. * An event triggered when the control has been disposed
  77432. */
  77433. onDisposeObservable: BABYLON.Observable<Control>;
  77434. /**
  77435. * Get the hosting AdvancedDynamicTexture
  77436. */
  77437. get host(): AdvancedDynamicTexture;
  77438. /** Gets or set information about font offsets (used to render and align text) */
  77439. get fontOffset(): {
  77440. ascent: number;
  77441. height: number;
  77442. descent: number;
  77443. };
  77444. set fontOffset(offset: {
  77445. ascent: number;
  77446. height: number;
  77447. descent: number;
  77448. });
  77449. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  77450. get alpha(): number;
  77451. set alpha(value: number);
  77452. /**
  77453. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  77454. */
  77455. get isHighlighted(): boolean;
  77456. set isHighlighted(value: boolean);
  77457. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  77458. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77459. */
  77460. get scaleX(): number;
  77461. set scaleX(value: number);
  77462. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  77463. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77464. */
  77465. get scaleY(): number;
  77466. set scaleY(value: number);
  77467. /** Gets or sets the rotation angle (0 by default)
  77468. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77469. */
  77470. get rotation(): number;
  77471. set rotation(value: number);
  77472. /** Gets or sets the transformation center on Y axis (0 by default)
  77473. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77474. */
  77475. get transformCenterY(): number;
  77476. set transformCenterY(value: number);
  77477. /** Gets or sets the transformation center on X axis (0 by default)
  77478. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77479. */
  77480. get transformCenterX(): number;
  77481. set transformCenterX(value: number);
  77482. /**
  77483. * Gets or sets the horizontal alignment
  77484. * @see https://doc.babylonjs.com/how_to/gui#alignments
  77485. */
  77486. get horizontalAlignment(): number;
  77487. set horizontalAlignment(value: number);
  77488. /**
  77489. * Gets or sets the vertical alignment
  77490. * @see https://doc.babylonjs.com/how_to/gui#alignments
  77491. */
  77492. get verticalAlignment(): number;
  77493. set verticalAlignment(value: number);
  77494. /**
  77495. * Gets or sets a fixed ratio for this control.
  77496. * When different from 0, the ratio is used to compute the "second" dimension.
  77497. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  77498. * second dimension is computed as first dimension * fixedRatio
  77499. */
  77500. fixedRatio: number;
  77501. private _fixedRatioMasterIsWidth;
  77502. /**
  77503. * Gets or sets control width
  77504. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77505. */
  77506. get width(): string | number;
  77507. set width(value: string | number);
  77508. /**
  77509. * Gets or sets the control width in pixel
  77510. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77511. */
  77512. get widthInPixels(): number;
  77513. set widthInPixels(value: number);
  77514. /**
  77515. * Gets or sets control height
  77516. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77517. */
  77518. get height(): string | number;
  77519. set height(value: string | number);
  77520. /**
  77521. * Gets or sets control height in pixel
  77522. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77523. */
  77524. get heightInPixels(): number;
  77525. set heightInPixels(value: number);
  77526. /** Gets or set font family */
  77527. get fontFamily(): string;
  77528. set fontFamily(value: string);
  77529. /** Gets or sets font style */
  77530. get fontStyle(): string;
  77531. set fontStyle(value: string);
  77532. /** Gets or sets font weight */
  77533. get fontWeight(): string;
  77534. set fontWeight(value: string);
  77535. /**
  77536. * Gets or sets style
  77537. * @see https://doc.babylonjs.com/how_to/gui#styles
  77538. */
  77539. get style(): BABYLON.Nullable<Style>;
  77540. set style(value: BABYLON.Nullable<Style>);
  77541. /** @hidden */
  77542. get _isFontSizeInPercentage(): boolean;
  77543. /** Gets or sets font size in pixels */
  77544. get fontSizeInPixels(): number;
  77545. set fontSizeInPixels(value: number);
  77546. /** Gets or sets font size */
  77547. get fontSize(): string | number;
  77548. set fontSize(value: string | number);
  77549. /** Gets or sets foreground color */
  77550. get color(): string;
  77551. set color(value: string);
  77552. /** Gets or sets z index which is used to reorder controls on the z axis */
  77553. get zIndex(): number;
  77554. set zIndex(value: number);
  77555. /** Gets or sets a boolean indicating if the control can be rendered */
  77556. get notRenderable(): boolean;
  77557. set notRenderable(value: boolean);
  77558. /** Gets or sets a boolean indicating if the control is visible */
  77559. get isVisible(): boolean;
  77560. set isVisible(value: boolean);
  77561. /** Gets a boolean indicating that the control needs to update its rendering */
  77562. get isDirty(): boolean;
  77563. /**
  77564. * Gets the current linked mesh (or null if none)
  77565. */
  77566. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77567. /**
  77568. * Gets or sets a value indicating the padding to use on the left of the control
  77569. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77570. */
  77571. get paddingLeft(): string | number;
  77572. set paddingLeft(value: string | number);
  77573. /**
  77574. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  77575. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77576. */
  77577. get paddingLeftInPixels(): number;
  77578. set paddingLeftInPixels(value: number);
  77579. /**
  77580. * Gets or sets a value indicating the padding to use on the right of the control
  77581. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77582. */
  77583. get paddingRight(): string | number;
  77584. set paddingRight(value: string | number);
  77585. /**
  77586. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  77587. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77588. */
  77589. get paddingRightInPixels(): number;
  77590. set paddingRightInPixels(value: number);
  77591. /**
  77592. * Gets or sets a value indicating the padding to use on the top of the control
  77593. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77594. */
  77595. get paddingTop(): string | number;
  77596. set paddingTop(value: string | number);
  77597. /**
  77598. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  77599. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77600. */
  77601. get paddingTopInPixels(): number;
  77602. set paddingTopInPixels(value: number);
  77603. /**
  77604. * Gets or sets a value indicating the padding to use on the bottom of the control
  77605. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77606. */
  77607. get paddingBottom(): string | number;
  77608. set paddingBottom(value: string | number);
  77609. /**
  77610. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  77611. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77612. */
  77613. get paddingBottomInPixels(): number;
  77614. set paddingBottomInPixels(value: number);
  77615. /**
  77616. * Gets or sets a value indicating the left coordinate of the control
  77617. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77618. */
  77619. get left(): string | number;
  77620. set left(value: string | number);
  77621. /**
  77622. * Gets or sets a value indicating the left coordinate in pixels of the control
  77623. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77624. */
  77625. get leftInPixels(): number;
  77626. set leftInPixels(value: number);
  77627. /**
  77628. * Gets or sets a value indicating the top coordinate of the control
  77629. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77630. */
  77631. get top(): string | number;
  77632. set top(value: string | number);
  77633. /**
  77634. * Gets or sets a value indicating the top coordinate in pixels of the control
  77635. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77636. */
  77637. get topInPixels(): number;
  77638. set topInPixels(value: number);
  77639. /**
  77640. * Gets or sets a value indicating the offset on X axis to the linked mesh
  77641. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77642. */
  77643. get linkOffsetX(): string | number;
  77644. set linkOffsetX(value: string | number);
  77645. /**
  77646. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  77647. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77648. */
  77649. get linkOffsetXInPixels(): number;
  77650. set linkOffsetXInPixels(value: number);
  77651. /**
  77652. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  77653. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77654. */
  77655. get linkOffsetY(): string | number;
  77656. set linkOffsetY(value: string | number);
  77657. /**
  77658. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  77659. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77660. */
  77661. get linkOffsetYInPixels(): number;
  77662. set linkOffsetYInPixels(value: number);
  77663. /** Gets the center coordinate on X axis */
  77664. get centerX(): number;
  77665. /** Gets the center coordinate on Y axis */
  77666. get centerY(): number;
  77667. /** Gets or sets if control is Enabled*/
  77668. get isEnabled(): boolean;
  77669. set isEnabled(value: boolean);
  77670. /** Gets or sets background color of control if it's disabled*/
  77671. get disabledColor(): string;
  77672. set disabledColor(value: string);
  77673. /** Gets or sets front color of control if it's disabled*/
  77674. get disabledColorItem(): string;
  77675. set disabledColorItem(value: string);
  77676. /**
  77677. * Creates a new control
  77678. * @param name defines the name of the control
  77679. */
  77680. constructor(
  77681. /** defines the name of the control */
  77682. name?: string | undefined);
  77683. /** @hidden */
  77684. protected _getTypeName(): string;
  77685. /**
  77686. * Gets the first ascendant in the hierarchy of the given type
  77687. * @param className defines the required type
  77688. * @returns the ascendant or null if not found
  77689. */
  77690. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  77691. /** @hidden */
  77692. _resetFontCache(): void;
  77693. /**
  77694. * Determines if a container is an ascendant of the current control
  77695. * @param container defines the container to look for
  77696. * @returns true if the container is one of the ascendant of the control
  77697. */
  77698. isAscendant(container: Control): boolean;
  77699. /**
  77700. * Gets coordinates in local control space
  77701. * @param globalCoordinates defines the coordinates to transform
  77702. * @returns the new coordinates in local space
  77703. */
  77704. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  77705. /**
  77706. * Gets coordinates in local control space
  77707. * @param globalCoordinates defines the coordinates to transform
  77708. * @param result defines the target vector2 where to store the result
  77709. * @returns the current control
  77710. */
  77711. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  77712. /**
  77713. * Gets coordinates in parent local control space
  77714. * @param globalCoordinates defines the coordinates to transform
  77715. * @returns the new coordinates in parent local space
  77716. */
  77717. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  77718. /**
  77719. * Move the current control to a vector3 position projected onto the screen.
  77720. * @param position defines the target position
  77721. * @param scene defines the hosting scene
  77722. */
  77723. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  77724. /**
  77725. * Will store all controls that have this control as ascendant in a given array
  77726. * @param results defines the array where to store the descendants
  77727. * @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
  77728. * @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
  77729. */
  77730. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  77731. /**
  77732. * Will return all controls that have this control as ascendant
  77733. * @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
  77734. * @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
  77735. * @return all child controls
  77736. */
  77737. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  77738. /**
  77739. * Link current control with a target mesh
  77740. * @param mesh defines the mesh to link with
  77741. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77742. */
  77743. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  77744. /** @hidden */
  77745. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  77746. /** @hidden */
  77747. _offsetLeft(offset: number): void;
  77748. /** @hidden */
  77749. _offsetTop(offset: number): void;
  77750. /** @hidden */
  77751. _markMatrixAsDirty(): void;
  77752. /** @hidden */
  77753. _flagDescendantsAsMatrixDirty(): void;
  77754. /** @hidden */
  77755. _intersectsRect(rect: Measure): boolean;
  77756. /** @hidden */
  77757. protected invalidateRect(): void;
  77758. /** @hidden */
  77759. _markAsDirty(force?: boolean): void;
  77760. /** @hidden */
  77761. _markAllAsDirty(): void;
  77762. /** @hidden */
  77763. _link(host: AdvancedDynamicTexture): void;
  77764. /** @hidden */
  77765. protected _transform(context?: CanvasRenderingContext2D): void;
  77766. /** @hidden */
  77767. _renderHighlight(context: CanvasRenderingContext2D): void;
  77768. /** @hidden */
  77769. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77770. /** @hidden */
  77771. protected _applyStates(context: CanvasRenderingContext2D): void;
  77772. /** @hidden */
  77773. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77774. /** @hidden */
  77775. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77776. protected _evaluateClippingState(parentMeasure: Measure): void;
  77777. /** @hidden */
  77778. _measure(): void;
  77779. /** @hidden */
  77780. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77781. /** @hidden */
  77782. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77783. /** @hidden */
  77784. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77785. /** @hidden */
  77786. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77787. private static _ClipMeasure;
  77788. private _tmpMeasureA;
  77789. private _clip;
  77790. /** @hidden */
  77791. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  77792. /** @hidden */
  77793. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77794. /**
  77795. * Tests if a given coordinates belong to the current control
  77796. * @param x defines x coordinate to test
  77797. * @param y defines y coordinate to test
  77798. * @returns true if the coordinates are inside the control
  77799. */
  77800. contains(x: number, y: number): boolean;
  77801. /** @hidden */
  77802. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77803. /** @hidden */
  77804. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77805. /** @hidden */
  77806. _onPointerEnter(target: Control): boolean;
  77807. /** @hidden */
  77808. _onPointerOut(target: Control, force?: boolean): void;
  77809. /** @hidden */
  77810. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77811. /** @hidden */
  77812. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77813. /** @hidden */
  77814. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77815. /** @hidden */
  77816. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  77817. /** @hidden */
  77818. _onCanvasBlur(): void;
  77819. /** @hidden */
  77820. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77821. private _prepareFont;
  77822. /** Releases associated resources */
  77823. dispose(): void;
  77824. private static _HORIZONTAL_ALIGNMENT_LEFT;
  77825. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  77826. private static _HORIZONTAL_ALIGNMENT_CENTER;
  77827. private static _VERTICAL_ALIGNMENT_TOP;
  77828. private static _VERTICAL_ALIGNMENT_BOTTOM;
  77829. private static _VERTICAL_ALIGNMENT_CENTER;
  77830. /** HORIZONTAL_ALIGNMENT_LEFT */
  77831. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  77832. /** HORIZONTAL_ALIGNMENT_RIGHT */
  77833. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  77834. /** HORIZONTAL_ALIGNMENT_CENTER */
  77835. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  77836. /** VERTICAL_ALIGNMENT_TOP */
  77837. static get VERTICAL_ALIGNMENT_TOP(): number;
  77838. /** VERTICAL_ALIGNMENT_BOTTOM */
  77839. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  77840. /** VERTICAL_ALIGNMENT_CENTER */
  77841. static get VERTICAL_ALIGNMENT_CENTER(): number;
  77842. private static _FontHeightSizes;
  77843. /** @hidden */
  77844. static _GetFontOffset(font: string): {
  77845. ascent: number;
  77846. height: number;
  77847. descent: number;
  77848. };
  77849. /**
  77850. * Creates a stack panel that can be used to render headers
  77851. * @param control defines the control to associate with the header
  77852. * @param text defines the text of the header
  77853. * @param size defines the size of the header
  77854. * @param options defines options used to configure the header
  77855. * @returns a new StackPanel
  77856. * @ignore
  77857. * @hidden
  77858. */
  77859. static AddHeader: (control: Control, text: string, size: string | number, options: {
  77860. isHorizontal: boolean;
  77861. controlFirst: boolean;
  77862. }) => any;
  77863. /** @hidden */
  77864. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  77865. }
  77866. }
  77867. declare module BABYLON.GUI {
  77868. /**
  77869. * Root class for 2D containers
  77870. * @see https://doc.babylonjs.com/how_to/gui#containers
  77871. */
  77872. export class Container extends Control {
  77873. name?: string | undefined;
  77874. /** @hidden */
  77875. _children: Control[];
  77876. /** @hidden */
  77877. protected _measureForChildren: Measure;
  77878. /** @hidden */
  77879. protected _background: string;
  77880. /** @hidden */
  77881. protected _adaptWidthToChildren: boolean;
  77882. /** @hidden */
  77883. protected _adaptHeightToChildren: boolean;
  77884. /**
  77885. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  77886. */
  77887. logLayoutCycleErrors: boolean;
  77888. /**
  77889. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  77890. */
  77891. maxLayoutCycle: number;
  77892. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  77893. get adaptHeightToChildren(): boolean;
  77894. set adaptHeightToChildren(value: boolean);
  77895. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  77896. get adaptWidthToChildren(): boolean;
  77897. set adaptWidthToChildren(value: boolean);
  77898. /** Gets or sets background color */
  77899. get background(): string;
  77900. set background(value: string);
  77901. /** Gets the list of children */
  77902. get children(): Control[];
  77903. /**
  77904. * Creates a new Container
  77905. * @param name defines the name of the container
  77906. */
  77907. constructor(name?: string | undefined);
  77908. protected _getTypeName(): string;
  77909. _flagDescendantsAsMatrixDirty(): void;
  77910. /**
  77911. * Gets a child using its name
  77912. * @param name defines the child name to look for
  77913. * @returns the child control if found
  77914. */
  77915. getChildByName(name: string): BABYLON.Nullable<Control>;
  77916. /**
  77917. * Gets a child using its type and its name
  77918. * @param name defines the child name to look for
  77919. * @param type defines the child type to look for
  77920. * @returns the child control if found
  77921. */
  77922. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  77923. /**
  77924. * Search for a specific control in children
  77925. * @param control defines the control to look for
  77926. * @returns true if the control is in child list
  77927. */
  77928. containsControl(control: Control): boolean;
  77929. /**
  77930. * Adds a new control to the current container
  77931. * @param control defines the control to add
  77932. * @returns the current container
  77933. */
  77934. addControl(control: BABYLON.Nullable<Control>): Container;
  77935. /**
  77936. * Removes all controls from the current container
  77937. * @returns the current container
  77938. */
  77939. clearControls(): Container;
  77940. /**
  77941. * Removes a control from the current container
  77942. * @param control defines the control to remove
  77943. * @returns the current container
  77944. */
  77945. removeControl(control: Control): Container;
  77946. /** @hidden */
  77947. _reOrderControl(control: Control): void;
  77948. /** @hidden */
  77949. _offsetLeft(offset: number): void;
  77950. /** @hidden */
  77951. _offsetTop(offset: number): void;
  77952. /** @hidden */
  77953. _markAllAsDirty(): void;
  77954. /** @hidden */
  77955. protected _localDraw(context: CanvasRenderingContext2D): void;
  77956. /** @hidden */
  77957. _link(host: AdvancedDynamicTexture): void;
  77958. /** @hidden */
  77959. protected _beforeLayout(): void;
  77960. /** @hidden */
  77961. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77962. /** @hidden */
  77963. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77964. protected _postMeasure(): void;
  77965. /** @hidden */
  77966. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  77967. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  77968. /** @hidden */
  77969. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77970. /** @hidden */
  77971. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77972. /** Releases associated resources */
  77973. dispose(): void;
  77974. }
  77975. }
  77976. declare module BABYLON.GUI {
  77977. /** Class used to create rectangle container */
  77978. export class Rectangle extends Container {
  77979. name?: string | undefined;
  77980. private _thickness;
  77981. private _cornerRadius;
  77982. /** Gets or sets border thickness */
  77983. get thickness(): number;
  77984. set thickness(value: number);
  77985. /** Gets or sets the corner radius angle */
  77986. get cornerRadius(): number;
  77987. set cornerRadius(value: number);
  77988. /**
  77989. * Creates a new Rectangle
  77990. * @param name defines the control name
  77991. */
  77992. constructor(name?: string | undefined);
  77993. protected _getTypeName(): string;
  77994. protected _localDraw(context: CanvasRenderingContext2D): void;
  77995. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77996. private _drawRoundedRect;
  77997. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77998. }
  77999. }
  78000. declare module BABYLON.GUI {
  78001. /**
  78002. * Enum that determines the text-wrapping mode to use.
  78003. */
  78004. export enum TextWrapping {
  78005. /**
  78006. * Clip the text when it's larger than Control.width; this is the default mode.
  78007. */
  78008. Clip = 0,
  78009. /**
  78010. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  78011. */
  78012. WordWrap = 1,
  78013. /**
  78014. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  78015. */
  78016. Ellipsis = 2
  78017. }
  78018. /**
  78019. * Class used to create text block control
  78020. */
  78021. export class TextBlock extends Control {
  78022. /**
  78023. * Defines the name of the control
  78024. */
  78025. name?: string | undefined;
  78026. private _text;
  78027. private _textWrapping;
  78028. private _textHorizontalAlignment;
  78029. private _textVerticalAlignment;
  78030. private _lines;
  78031. private _resizeToFit;
  78032. private _lineSpacing;
  78033. private _outlineWidth;
  78034. private _outlineColor;
  78035. private _underline;
  78036. private _lineThrough;
  78037. /**
  78038. * An event triggered after the text is changed
  78039. */
  78040. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  78041. /**
  78042. * An event triggered after the text was broken up into lines
  78043. */
  78044. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  78045. /**
  78046. * Function used to split a string into words. By default, a string is split at each space character found
  78047. */
  78048. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  78049. /**
  78050. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  78051. */
  78052. get lines(): any[];
  78053. /**
  78054. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78055. */
  78056. get resizeToFit(): boolean;
  78057. /**
  78058. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78059. */
  78060. set resizeToFit(value: boolean);
  78061. /**
  78062. * Gets or sets a boolean indicating if text must be wrapped
  78063. */
  78064. get textWrapping(): TextWrapping | boolean;
  78065. /**
  78066. * Gets or sets a boolean indicating if text must be wrapped
  78067. */
  78068. set textWrapping(value: TextWrapping | boolean);
  78069. /**
  78070. * Gets or sets text to display
  78071. */
  78072. get text(): string;
  78073. /**
  78074. * Gets or sets text to display
  78075. */
  78076. set text(value: string);
  78077. /**
  78078. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  78079. */
  78080. get textHorizontalAlignment(): number;
  78081. /**
  78082. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  78083. */
  78084. set textHorizontalAlignment(value: number);
  78085. /**
  78086. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  78087. */
  78088. get textVerticalAlignment(): number;
  78089. /**
  78090. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  78091. */
  78092. set textVerticalAlignment(value: number);
  78093. /**
  78094. * Gets or sets line spacing value
  78095. */
  78096. set lineSpacing(value: string | number);
  78097. /**
  78098. * Gets or sets line spacing value
  78099. */
  78100. get lineSpacing(): string | number;
  78101. /**
  78102. * Gets or sets outlineWidth of the text to display
  78103. */
  78104. get outlineWidth(): number;
  78105. /**
  78106. * Gets or sets outlineWidth of the text to display
  78107. */
  78108. set outlineWidth(value: number);
  78109. /**
  78110. * Gets or sets a boolean indicating that text must have underline
  78111. */
  78112. get underline(): boolean;
  78113. /**
  78114. * Gets or sets a boolean indicating that text must have underline
  78115. */
  78116. set underline(value: boolean);
  78117. /**
  78118. * Gets or sets an boolean indicating that text must be crossed out
  78119. */
  78120. get lineThrough(): boolean;
  78121. /**
  78122. * Gets or sets an boolean indicating that text must be crossed out
  78123. */
  78124. set lineThrough(value: boolean);
  78125. /**
  78126. * Gets or sets outlineColor of the text to display
  78127. */
  78128. get outlineColor(): string;
  78129. /**
  78130. * Gets or sets outlineColor of the text to display
  78131. */
  78132. set outlineColor(value: string);
  78133. /**
  78134. * Creates a new TextBlock object
  78135. * @param name defines the name of the control
  78136. * @param text defines the text to display (emptry string by default)
  78137. */
  78138. constructor(
  78139. /**
  78140. * Defines the name of the control
  78141. */
  78142. name?: string | undefined, text?: string);
  78143. protected _getTypeName(): string;
  78144. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78145. private _drawText;
  78146. /** @hidden */
  78147. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78148. protected _applyStates(context: CanvasRenderingContext2D): void;
  78149. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  78150. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  78151. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  78152. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  78153. protected _renderLines(context: CanvasRenderingContext2D): void;
  78154. /**
  78155. * Given a width constraint applied on the text block, find the expected height
  78156. * @returns expected height
  78157. */
  78158. computeExpectedHeight(): number;
  78159. dispose(): void;
  78160. }
  78161. }
  78162. declare module BABYLON.GUI {
  78163. /**
  78164. * Class used to create 2D images
  78165. */
  78166. export class Image extends Control {
  78167. name?: string | undefined;
  78168. private _workingCanvas;
  78169. private _domImage;
  78170. private _imageWidth;
  78171. private _imageHeight;
  78172. private _loaded;
  78173. private _stretch;
  78174. private _source;
  78175. private _autoScale;
  78176. private _sourceLeft;
  78177. private _sourceTop;
  78178. private _sourceWidth;
  78179. private _sourceHeight;
  78180. private _svgAttributesComputationCompleted;
  78181. private _isSVG;
  78182. private _cellWidth;
  78183. private _cellHeight;
  78184. private _cellId;
  78185. private _populateNinePatchSlicesFromImage;
  78186. private _sliceLeft;
  78187. private _sliceRight;
  78188. private _sliceTop;
  78189. private _sliceBottom;
  78190. private _detectPointerOnOpaqueOnly;
  78191. private _imageDataCache;
  78192. /**
  78193. * BABYLON.Observable notified when the content is loaded
  78194. */
  78195. onImageLoadedObservable: BABYLON.Observable<Image>;
  78196. /**
  78197. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  78198. */
  78199. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  78200. /**
  78201. * Gets a boolean indicating that the content is loaded
  78202. */
  78203. get isLoaded(): boolean;
  78204. /**
  78205. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  78206. */
  78207. get populateNinePatchSlicesFromImage(): boolean;
  78208. set populateNinePatchSlicesFromImage(value: boolean);
  78209. /**
  78210. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  78211. * Beware using this as this will comsume more memory as the image has to be stored twice
  78212. */
  78213. get detectPointerOnOpaqueOnly(): boolean;
  78214. set detectPointerOnOpaqueOnly(value: boolean);
  78215. /**
  78216. * Gets or sets the left value for slicing (9-patch)
  78217. */
  78218. get sliceLeft(): number;
  78219. set sliceLeft(value: number);
  78220. /**
  78221. * Gets or sets the right value for slicing (9-patch)
  78222. */
  78223. get sliceRight(): number;
  78224. set sliceRight(value: number);
  78225. /**
  78226. * Gets or sets the top value for slicing (9-patch)
  78227. */
  78228. get sliceTop(): number;
  78229. set sliceTop(value: number);
  78230. /**
  78231. * Gets or sets the bottom value for slicing (9-patch)
  78232. */
  78233. get sliceBottom(): number;
  78234. set sliceBottom(value: number);
  78235. /**
  78236. * Gets or sets the left coordinate in the source image
  78237. */
  78238. get sourceLeft(): number;
  78239. set sourceLeft(value: number);
  78240. /**
  78241. * Gets or sets the top coordinate in the source image
  78242. */
  78243. get sourceTop(): number;
  78244. set sourceTop(value: number);
  78245. /**
  78246. * Gets or sets the width to capture in the source image
  78247. */
  78248. get sourceWidth(): number;
  78249. set sourceWidth(value: number);
  78250. /**
  78251. * Gets or sets the height to capture in the source image
  78252. */
  78253. get sourceHeight(): number;
  78254. set sourceHeight(value: number);
  78255. /** Indicates if the format of the image is SVG */
  78256. get isSVG(): boolean;
  78257. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  78258. get svgAttributesComputationCompleted(): boolean;
  78259. /**
  78260. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  78261. * @see https://doc.babylonjs.com/how_to/gui#image
  78262. */
  78263. get autoScale(): boolean;
  78264. set autoScale(value: boolean);
  78265. /** Gets or sets the streching mode used by the image */
  78266. get stretch(): number;
  78267. set stretch(value: number);
  78268. /** @hidden */
  78269. _rotate90(n: number, preserveProperties?: boolean): Image;
  78270. private _handleRotationForSVGImage;
  78271. private _rotate90SourceProperties;
  78272. /**
  78273. * Gets or sets the internal DOM image used to render the control
  78274. */
  78275. set domImage(value: HTMLImageElement);
  78276. get domImage(): HTMLImageElement;
  78277. private _onImageLoaded;
  78278. private _extractNinePatchSliceDataFromImage;
  78279. /**
  78280. * Gets or sets image source url
  78281. */
  78282. set source(value: BABYLON.Nullable<string>);
  78283. /**
  78284. * Checks for svg document with icon id present
  78285. */
  78286. private _svgCheck;
  78287. /**
  78288. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  78289. * given external svg file and icon id
  78290. */
  78291. private _getSVGAttribs;
  78292. /**
  78293. * Gets or sets the cell width to use when animation sheet is enabled
  78294. * @see https://doc.babylonjs.com/how_to/gui#image
  78295. */
  78296. get cellWidth(): number;
  78297. set cellWidth(value: number);
  78298. /**
  78299. * Gets or sets the cell height to use when animation sheet is enabled
  78300. * @see https://doc.babylonjs.com/how_to/gui#image
  78301. */
  78302. get cellHeight(): number;
  78303. set cellHeight(value: number);
  78304. /**
  78305. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  78306. * @see https://doc.babylonjs.com/how_to/gui#image
  78307. */
  78308. get cellId(): number;
  78309. set cellId(value: number);
  78310. /**
  78311. * Creates a new Image
  78312. * @param name defines the control name
  78313. * @param url defines the image url
  78314. */
  78315. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  78316. /**
  78317. * Tests if a given coordinates belong to the current control
  78318. * @param x defines x coordinate to test
  78319. * @param y defines y coordinate to test
  78320. * @returns true if the coordinates are inside the control
  78321. */
  78322. contains(x: number, y: number): boolean;
  78323. protected _getTypeName(): string;
  78324. /** Force the control to synchronize with its content */
  78325. synchronizeSizeWithContent(): void;
  78326. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78327. private _prepareWorkingCanvasForOpaqueDetection;
  78328. private _drawImage;
  78329. _draw(context: CanvasRenderingContext2D): void;
  78330. private _renderCornerPatch;
  78331. private _renderNinePatch;
  78332. dispose(): void;
  78333. /** STRETCH_NONE */
  78334. static readonly STRETCH_NONE: number;
  78335. /** STRETCH_FILL */
  78336. static readonly STRETCH_FILL: number;
  78337. /** STRETCH_UNIFORM */
  78338. static readonly STRETCH_UNIFORM: number;
  78339. /** STRETCH_EXTEND */
  78340. static readonly STRETCH_EXTEND: number;
  78341. /** NINE_PATCH */
  78342. static readonly STRETCH_NINE_PATCH: number;
  78343. }
  78344. }
  78345. declare module BABYLON.GUI {
  78346. /**
  78347. * Class used to create 2D buttons
  78348. */
  78349. export class Button extends Rectangle {
  78350. name?: string | undefined;
  78351. /**
  78352. * Function called to generate a pointer enter animation
  78353. */
  78354. pointerEnterAnimation: () => void;
  78355. /**
  78356. * Function called to generate a pointer out animation
  78357. */
  78358. pointerOutAnimation: () => void;
  78359. /**
  78360. * Function called to generate a pointer down animation
  78361. */
  78362. pointerDownAnimation: () => void;
  78363. /**
  78364. * Function called to generate a pointer up animation
  78365. */
  78366. pointerUpAnimation: () => void;
  78367. /**
  78368. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  78369. */
  78370. delegatePickingToChildren: boolean;
  78371. private _image;
  78372. /**
  78373. * Returns the image part of the button (if any)
  78374. */
  78375. get image(): BABYLON.Nullable<Image>;
  78376. private _textBlock;
  78377. /**
  78378. * Returns the image part of the button (if any)
  78379. */
  78380. get textBlock(): BABYLON.Nullable<TextBlock>;
  78381. /**
  78382. * Creates a new Button
  78383. * @param name defines the name of the button
  78384. */
  78385. constructor(name?: string | undefined);
  78386. protected _getTypeName(): string;
  78387. /** @hidden */
  78388. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78389. /** @hidden */
  78390. _onPointerEnter(target: Control): boolean;
  78391. /** @hidden */
  78392. _onPointerOut(target: Control, force?: boolean): void;
  78393. /** @hidden */
  78394. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78395. /** @hidden */
  78396. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78397. /**
  78398. * Creates a new button made with an image and a text
  78399. * @param name defines the name of the button
  78400. * @param text defines the text of the button
  78401. * @param imageUrl defines the url of the image
  78402. * @returns a new Button
  78403. */
  78404. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  78405. /**
  78406. * Creates a new button made with an image
  78407. * @param name defines the name of the button
  78408. * @param imageUrl defines the url of the image
  78409. * @returns a new Button
  78410. */
  78411. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  78412. /**
  78413. * Creates a new button made with a text
  78414. * @param name defines the name of the button
  78415. * @param text defines the text of the button
  78416. * @returns a new Button
  78417. */
  78418. static CreateSimpleButton(name: string, text: string): Button;
  78419. /**
  78420. * Creates a new button made with an image and a centered text
  78421. * @param name defines the name of the button
  78422. * @param text defines the text of the button
  78423. * @param imageUrl defines the url of the image
  78424. * @returns a new Button
  78425. */
  78426. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  78427. }
  78428. }
  78429. declare module BABYLON.GUI {
  78430. /**
  78431. * Class used to create a 2D stack panel container
  78432. */
  78433. export class StackPanel extends Container {
  78434. name?: string | undefined;
  78435. private _isVertical;
  78436. private _manualWidth;
  78437. private _manualHeight;
  78438. private _doNotTrackManualChanges;
  78439. /**
  78440. * Gets or sets a boolean indicating that layou warnings should be ignored
  78441. */
  78442. ignoreLayoutWarnings: boolean;
  78443. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  78444. get isVertical(): boolean;
  78445. set isVertical(value: boolean);
  78446. /**
  78447. * Gets or sets panel width.
  78448. * This value should not be set when in horizontal mode as it will be computed automatically
  78449. */
  78450. set width(value: string | number);
  78451. get width(): string | number;
  78452. /**
  78453. * Gets or sets panel height.
  78454. * This value should not be set when in vertical mode as it will be computed automatically
  78455. */
  78456. set height(value: string | number);
  78457. get height(): string | number;
  78458. /**
  78459. * Creates a new StackPanel
  78460. * @param name defines control name
  78461. */
  78462. constructor(name?: string | undefined);
  78463. protected _getTypeName(): string;
  78464. /** @hidden */
  78465. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78466. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78467. protected _postMeasure(): void;
  78468. }
  78469. }
  78470. declare module BABYLON.GUI {
  78471. /**
  78472. * Class used to represent a 2D checkbox
  78473. */
  78474. export class Checkbox extends Control {
  78475. name?: string | undefined;
  78476. private _isChecked;
  78477. private _background;
  78478. private _checkSizeRatio;
  78479. private _thickness;
  78480. /** Gets or sets border thickness */
  78481. get thickness(): number;
  78482. set thickness(value: number);
  78483. /**
  78484. * BABYLON.Observable raised when isChecked property changes
  78485. */
  78486. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  78487. /** Gets or sets a value indicating the ratio between overall size and check size */
  78488. get checkSizeRatio(): number;
  78489. set checkSizeRatio(value: number);
  78490. /** Gets or sets background color */
  78491. get background(): string;
  78492. set background(value: string);
  78493. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  78494. get isChecked(): boolean;
  78495. set isChecked(value: boolean);
  78496. /**
  78497. * Creates a new CheckBox
  78498. * @param name defines the control name
  78499. */
  78500. constructor(name?: string | undefined);
  78501. protected _getTypeName(): string;
  78502. /** @hidden */
  78503. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78504. /** @hidden */
  78505. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78506. /**
  78507. * Utility function to easily create a checkbox with a header
  78508. * @param title defines the label to use for the header
  78509. * @param onValueChanged defines the callback to call when value changes
  78510. * @returns a StackPanel containing the checkbox and a textBlock
  78511. */
  78512. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  78513. }
  78514. }
  78515. declare module BABYLON.GUI {
  78516. /**
  78517. * Class used to store key control properties
  78518. */
  78519. export class KeyPropertySet {
  78520. /** Width */
  78521. width?: string;
  78522. /** Height */
  78523. height?: string;
  78524. /** Left padding */
  78525. paddingLeft?: string;
  78526. /** Right padding */
  78527. paddingRight?: string;
  78528. /** Top padding */
  78529. paddingTop?: string;
  78530. /** Bottom padding */
  78531. paddingBottom?: string;
  78532. /** Foreground color */
  78533. color?: string;
  78534. /** Background color */
  78535. background?: string;
  78536. }
  78537. /**
  78538. * Class used to create virtual keyboard
  78539. */
  78540. export class VirtualKeyboard extends StackPanel {
  78541. /** BABYLON.Observable raised when a key is pressed */
  78542. onKeyPressObservable: BABYLON.Observable<string>;
  78543. /** Gets or sets default key button width */
  78544. defaultButtonWidth: string;
  78545. /** Gets or sets default key button height */
  78546. defaultButtonHeight: string;
  78547. /** Gets or sets default key button left padding */
  78548. defaultButtonPaddingLeft: string;
  78549. /** Gets or sets default key button right padding */
  78550. defaultButtonPaddingRight: string;
  78551. /** Gets or sets default key button top padding */
  78552. defaultButtonPaddingTop: string;
  78553. /** Gets or sets default key button bottom padding */
  78554. defaultButtonPaddingBottom: string;
  78555. /** Gets or sets default key button foreground color */
  78556. defaultButtonColor: string;
  78557. /** Gets or sets default key button background color */
  78558. defaultButtonBackground: string;
  78559. /** Gets or sets shift button foreground color */
  78560. shiftButtonColor: string;
  78561. /** Gets or sets shift button thickness*/
  78562. selectedShiftThickness: number;
  78563. /** Gets shift key state */
  78564. shiftState: number;
  78565. protected _getTypeName(): string;
  78566. private _createKey;
  78567. /**
  78568. * Adds a new row of keys
  78569. * @param keys defines the list of keys to add
  78570. * @param propertySets defines the associated property sets
  78571. */
  78572. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  78573. /**
  78574. * Set the shift key to a specific state
  78575. * @param shiftState defines the new shift state
  78576. */
  78577. applyShiftState(shiftState: number): void;
  78578. private _currentlyConnectedInputText;
  78579. private _connectedInputTexts;
  78580. private _onKeyPressObserver;
  78581. /** Gets the input text control currently attached to the keyboard */
  78582. get connectedInputText(): BABYLON.Nullable<InputText>;
  78583. /**
  78584. * Connects the keyboard with an input text control
  78585. *
  78586. * @param input defines the target control
  78587. */
  78588. connect(input: InputText): void;
  78589. /**
  78590. * Disconnects the keyboard from connected InputText controls
  78591. *
  78592. * @param input optionally defines a target control, otherwise all are disconnected
  78593. */
  78594. disconnect(input?: InputText): void;
  78595. private _removeConnectedInputObservables;
  78596. /**
  78597. * Release all resources
  78598. */
  78599. dispose(): void;
  78600. /**
  78601. * Creates a new keyboard using a default layout
  78602. *
  78603. * @param name defines control name
  78604. * @returns a new VirtualKeyboard
  78605. */
  78606. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  78607. }
  78608. }
  78609. declare module BABYLON.GUI {
  78610. /**
  78611. * Class used to create input text control
  78612. */
  78613. export class InputText extends Control implements IFocusableControl {
  78614. name?: string | undefined;
  78615. private _text;
  78616. private _placeholderText;
  78617. private _background;
  78618. private _focusedBackground;
  78619. private _focusedColor;
  78620. private _placeholderColor;
  78621. private _thickness;
  78622. private _margin;
  78623. private _autoStretchWidth;
  78624. private _maxWidth;
  78625. private _isFocused;
  78626. private _blinkTimeout;
  78627. private _blinkIsEven;
  78628. private _cursorOffset;
  78629. private _scrollLeft;
  78630. private _textWidth;
  78631. private _clickedCoordinate;
  78632. private _deadKey;
  78633. private _addKey;
  78634. private _currentKey;
  78635. private _isTextHighlightOn;
  78636. private _textHighlightColor;
  78637. private _highligherOpacity;
  78638. private _highlightedText;
  78639. private _startHighlightIndex;
  78640. private _endHighlightIndex;
  78641. private _cursorIndex;
  78642. private _onFocusSelectAll;
  78643. private _isPointerDown;
  78644. private _onClipboardObserver;
  78645. private _onPointerDblTapObserver;
  78646. /** @hidden */
  78647. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  78648. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  78649. promptMessage: string;
  78650. /** Force disable prompt on mobile device */
  78651. disableMobilePrompt: boolean;
  78652. /** BABYLON.Observable raised when the text changes */
  78653. onTextChangedObservable: BABYLON.Observable<InputText>;
  78654. /** BABYLON.Observable raised just before an entered character is to be added */
  78655. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  78656. /** BABYLON.Observable raised when the control gets the focus */
  78657. onFocusObservable: BABYLON.Observable<InputText>;
  78658. /** BABYLON.Observable raised when the control loses the focus */
  78659. onBlurObservable: BABYLON.Observable<InputText>;
  78660. /**Observable raised when the text is highlighted */
  78661. onTextHighlightObservable: BABYLON.Observable<InputText>;
  78662. /**Observable raised when copy event is triggered */
  78663. onTextCopyObservable: BABYLON.Observable<InputText>;
  78664. /** BABYLON.Observable raised when cut event is triggered */
  78665. onTextCutObservable: BABYLON.Observable<InputText>;
  78666. /** BABYLON.Observable raised when paste event is triggered */
  78667. onTextPasteObservable: BABYLON.Observable<InputText>;
  78668. /** BABYLON.Observable raised when a key event was processed */
  78669. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  78670. /** Gets or sets the maximum width allowed by the control */
  78671. get maxWidth(): string | number;
  78672. /** Gets the maximum width allowed by the control in pixels */
  78673. get maxWidthInPixels(): number;
  78674. set maxWidth(value: string | number);
  78675. /** Gets or sets the text highlighter transparency; default: 0.4 */
  78676. get highligherOpacity(): number;
  78677. set highligherOpacity(value: number);
  78678. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  78679. get onFocusSelectAll(): boolean;
  78680. set onFocusSelectAll(value: boolean);
  78681. /** Gets or sets the text hightlight color */
  78682. get textHighlightColor(): string;
  78683. set textHighlightColor(value: string);
  78684. /** Gets or sets control margin */
  78685. get margin(): string;
  78686. /** Gets control margin in pixels */
  78687. get marginInPixels(): number;
  78688. set margin(value: string);
  78689. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  78690. get autoStretchWidth(): boolean;
  78691. set autoStretchWidth(value: boolean);
  78692. /** Gets or sets border thickness */
  78693. get thickness(): number;
  78694. set thickness(value: number);
  78695. /** Gets or sets the background color when focused */
  78696. get focusedBackground(): string;
  78697. set focusedBackground(value: string);
  78698. /** Gets or sets the background color when focused */
  78699. get focusedColor(): string;
  78700. set focusedColor(value: string);
  78701. /** Gets or sets the background color */
  78702. get background(): string;
  78703. set background(value: string);
  78704. /** Gets or sets the placeholder color */
  78705. get placeholderColor(): string;
  78706. set placeholderColor(value: string);
  78707. /** Gets or sets the text displayed when the control is empty */
  78708. get placeholderText(): string;
  78709. set placeholderText(value: string);
  78710. /** Gets or sets the dead key flag */
  78711. get deadKey(): boolean;
  78712. set deadKey(flag: boolean);
  78713. /** Gets or sets the highlight text */
  78714. get highlightedText(): string;
  78715. set highlightedText(text: string);
  78716. /** Gets or sets if the current key should be added */
  78717. get addKey(): boolean;
  78718. set addKey(flag: boolean);
  78719. /** Gets or sets the value of the current key being entered */
  78720. get currentKey(): string;
  78721. set currentKey(key: string);
  78722. /** Gets or sets the text displayed in the control */
  78723. get text(): string;
  78724. set text(value: string);
  78725. /** Gets or sets control width */
  78726. get width(): string | number;
  78727. set width(value: string | number);
  78728. /**
  78729. * Creates a new InputText
  78730. * @param name defines the control name
  78731. * @param text defines the text of the control
  78732. */
  78733. constructor(name?: string | undefined, text?: string);
  78734. /** @hidden */
  78735. onBlur(): void;
  78736. /** @hidden */
  78737. onFocus(): void;
  78738. protected _getTypeName(): string;
  78739. /**
  78740. * Function called to get the list of controls that should not steal the focus from this control
  78741. * @returns an array of controls
  78742. */
  78743. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  78744. /** @hidden */
  78745. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  78746. /** @hidden */
  78747. private _updateValueFromCursorIndex;
  78748. /** @hidden */
  78749. private _processDblClick;
  78750. /** @hidden */
  78751. private _selectAllText;
  78752. /**
  78753. * Handles the keyboard event
  78754. * @param evt Defines the KeyboardEvent
  78755. */
  78756. processKeyboard(evt: KeyboardEvent): void;
  78757. /** @hidden */
  78758. private _onCopyText;
  78759. /** @hidden */
  78760. private _onCutText;
  78761. /** @hidden */
  78762. private _onPasteText;
  78763. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78764. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78765. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78766. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78767. protected _beforeRenderText(text: string): string;
  78768. dispose(): void;
  78769. }
  78770. }
  78771. declare module BABYLON.GUI {
  78772. /**
  78773. * Class used to create a 2D grid container
  78774. */
  78775. export class Grid extends Container {
  78776. name?: string | undefined;
  78777. private _rowDefinitions;
  78778. private _columnDefinitions;
  78779. private _cells;
  78780. private _childControls;
  78781. /**
  78782. * Gets the number of columns
  78783. */
  78784. get columnCount(): number;
  78785. /**
  78786. * Gets the number of rows
  78787. */
  78788. get rowCount(): number;
  78789. /** Gets the list of children */
  78790. get children(): Control[];
  78791. /** Gets the list of cells (e.g. the containers) */
  78792. get cells(): {
  78793. [key: string]: Container;
  78794. };
  78795. /**
  78796. * Gets the definition of a specific row
  78797. * @param index defines the index of the row
  78798. * @returns the row definition
  78799. */
  78800. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  78801. /**
  78802. * Gets the definition of a specific column
  78803. * @param index defines the index of the column
  78804. * @returns the column definition
  78805. */
  78806. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  78807. /**
  78808. * Adds a new row to the grid
  78809. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  78810. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  78811. * @returns the current grid
  78812. */
  78813. addRowDefinition(height: number, isPixel?: boolean): Grid;
  78814. /**
  78815. * Adds a new column to the grid
  78816. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  78817. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  78818. * @returns the current grid
  78819. */
  78820. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  78821. /**
  78822. * Update a row definition
  78823. * @param index defines the index of the row to update
  78824. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  78825. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  78826. * @returns the current grid
  78827. */
  78828. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  78829. /**
  78830. * Update a column definition
  78831. * @param index defines the index of the column to update
  78832. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  78833. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  78834. * @returns the current grid
  78835. */
  78836. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  78837. /**
  78838. * Gets the list of children stored in a specific cell
  78839. * @param row defines the row to check
  78840. * @param column defines the column to check
  78841. * @returns the list of controls
  78842. */
  78843. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  78844. /**
  78845. * Gets a string representing the child cell info (row x column)
  78846. * @param child defines the control to get info from
  78847. * @returns a string containing the child cell info (row x column)
  78848. */
  78849. getChildCellInfo(child: Control): string;
  78850. private _removeCell;
  78851. private _offsetCell;
  78852. /**
  78853. * Remove a column definition at specified index
  78854. * @param index defines the index of the column to remove
  78855. * @returns the current grid
  78856. */
  78857. removeColumnDefinition(index: number): Grid;
  78858. /**
  78859. * Remove a row definition at specified index
  78860. * @param index defines the index of the row to remove
  78861. * @returns the current grid
  78862. */
  78863. removeRowDefinition(index: number): Grid;
  78864. /**
  78865. * Adds a new control to the current grid
  78866. * @param control defines the control to add
  78867. * @param row defines the row where to add the control (0 by default)
  78868. * @param column defines the column where to add the control (0 by default)
  78869. * @returns the current grid
  78870. */
  78871. addControl(control: Control, row?: number, column?: number): Grid;
  78872. /**
  78873. * Removes a control from the current container
  78874. * @param control defines the control to remove
  78875. * @returns the current container
  78876. */
  78877. removeControl(control: Control): Container;
  78878. /**
  78879. * Creates a new Grid
  78880. * @param name defines control name
  78881. */
  78882. constructor(name?: string | undefined);
  78883. protected _getTypeName(): string;
  78884. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  78885. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78886. _flagDescendantsAsMatrixDirty(): void;
  78887. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78888. /** Releases associated resources */
  78889. dispose(): void;
  78890. }
  78891. }
  78892. declare module BABYLON.GUI {
  78893. /** Class used to create color pickers */
  78894. export class ColorPicker extends Control {
  78895. name?: string | undefined;
  78896. private static _Epsilon;
  78897. private _colorWheelCanvas;
  78898. private _value;
  78899. private _tmpColor;
  78900. private _pointerStartedOnSquare;
  78901. private _pointerStartedOnWheel;
  78902. private _squareLeft;
  78903. private _squareTop;
  78904. private _squareSize;
  78905. private _h;
  78906. private _s;
  78907. private _v;
  78908. private _lastPointerDownID;
  78909. /**
  78910. * BABYLON.Observable raised when the value changes
  78911. */
  78912. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  78913. /** Gets or sets the color of the color picker */
  78914. get value(): BABYLON.Color3;
  78915. set value(value: BABYLON.Color3);
  78916. /**
  78917. * Gets or sets control width
  78918. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78919. */
  78920. get width(): string | number;
  78921. set width(value: string | number);
  78922. /**
  78923. * Gets or sets control height
  78924. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78925. */
  78926. get height(): string | number;
  78927. /** Gets or sets control height */
  78928. set height(value: string | number);
  78929. /** Gets or sets control size */
  78930. get size(): string | number;
  78931. set size(value: string | number);
  78932. /**
  78933. * Creates a new ColorPicker
  78934. * @param name defines the control name
  78935. */
  78936. constructor(name?: string | undefined);
  78937. protected _getTypeName(): string;
  78938. /** @hidden */
  78939. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78940. private _updateSquareProps;
  78941. private _drawGradientSquare;
  78942. private _drawCircle;
  78943. private _createColorWheelCanvas;
  78944. /** @hidden */
  78945. _draw(context: CanvasRenderingContext2D): void;
  78946. private _pointerIsDown;
  78947. private _updateValueFromPointer;
  78948. private _isPointOnSquare;
  78949. private _isPointOnWheel;
  78950. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78951. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78952. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78953. _onCanvasBlur(): void;
  78954. /**
  78955. * This function expands the color picker by creating a color picker dialog with manual
  78956. * color value input and the ability to save colors into an array to be used later in
  78957. * subsequent launches of the dialogue.
  78958. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  78959. * @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.
  78960. * @returns picked color as a hex string and the saved colors array as hex strings.
  78961. */
  78962. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  78963. pickerWidth?: string;
  78964. pickerHeight?: string;
  78965. headerHeight?: string;
  78966. lastColor?: string;
  78967. swatchLimit?: number;
  78968. numSwatchesPerLine?: number;
  78969. savedColors?: Array<string>;
  78970. }): Promise<{
  78971. savedColors?: string[];
  78972. pickedColor: string;
  78973. }>;
  78974. }
  78975. }
  78976. declare module BABYLON.GUI {
  78977. /** Class used to create 2D ellipse containers */
  78978. export class Ellipse extends Container {
  78979. name?: string | undefined;
  78980. private _thickness;
  78981. /** Gets or sets border thickness */
  78982. get thickness(): number;
  78983. set thickness(value: number);
  78984. /**
  78985. * Creates a new Ellipse
  78986. * @param name defines the control name
  78987. */
  78988. constructor(name?: string | undefined);
  78989. protected _getTypeName(): string;
  78990. protected _localDraw(context: CanvasRenderingContext2D): void;
  78991. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78992. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78993. }
  78994. }
  78995. declare module BABYLON.GUI {
  78996. /**
  78997. * Class used to create a password control
  78998. */
  78999. export class InputPassword extends InputText {
  79000. protected _beforeRenderText(text: string): string;
  79001. }
  79002. }
  79003. declare module BABYLON.GUI {
  79004. /** Class used to render 2D lines */
  79005. export class Line extends Control {
  79006. name?: string | undefined;
  79007. private _lineWidth;
  79008. private _x1;
  79009. private _y1;
  79010. private _x2;
  79011. private _y2;
  79012. private _dash;
  79013. private _connectedControl;
  79014. private _connectedControlDirtyObserver;
  79015. /** Gets or sets the dash pattern */
  79016. get dash(): Array<number>;
  79017. set dash(value: Array<number>);
  79018. /** Gets or sets the control connected with the line end */
  79019. get connectedControl(): Control;
  79020. set connectedControl(value: Control);
  79021. /** Gets or sets start coordinates on X axis */
  79022. get x1(): string | number;
  79023. set x1(value: string | number);
  79024. /** Gets or sets start coordinates on Y axis */
  79025. get y1(): string | number;
  79026. set y1(value: string | number);
  79027. /** Gets or sets end coordinates on X axis */
  79028. get x2(): string | number;
  79029. set x2(value: string | number);
  79030. /** Gets or sets end coordinates on Y axis */
  79031. get y2(): string | number;
  79032. set y2(value: string | number);
  79033. /** Gets or sets line width */
  79034. get lineWidth(): number;
  79035. set lineWidth(value: number);
  79036. /** Gets or sets horizontal alignment */
  79037. set horizontalAlignment(value: number);
  79038. /** Gets or sets vertical alignment */
  79039. set verticalAlignment(value: number);
  79040. private get _effectiveX2();
  79041. private get _effectiveY2();
  79042. /**
  79043. * Creates a new Line
  79044. * @param name defines the control name
  79045. */
  79046. constructor(name?: string | undefined);
  79047. protected _getTypeName(): string;
  79048. _draw(context: CanvasRenderingContext2D): void;
  79049. _measure(): void;
  79050. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79051. /**
  79052. * Move one end of the line given 3D cartesian coordinates.
  79053. * @param position Targeted world position
  79054. * @param scene BABYLON.Scene
  79055. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79056. */
  79057. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  79058. /**
  79059. * Move one end of the line to a position in screen absolute space.
  79060. * @param projectedPosition Position in screen absolute space (X, Y)
  79061. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79062. */
  79063. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  79064. }
  79065. }
  79066. declare module BABYLON.GUI {
  79067. /**
  79068. * Class used to store a point for a MultiLine object.
  79069. * The point can be pure 2D coordinates, a mesh or a control
  79070. */
  79071. export class MultiLinePoint {
  79072. private _multiLine;
  79073. private _x;
  79074. private _y;
  79075. private _control;
  79076. private _mesh;
  79077. private _controlObserver;
  79078. private _meshObserver;
  79079. /** @hidden */
  79080. _point: BABYLON.Vector2;
  79081. /**
  79082. * Creates a new MultiLinePoint
  79083. * @param multiLine defines the source MultiLine object
  79084. */
  79085. constructor(multiLine: MultiLine);
  79086. /** Gets or sets x coordinate */
  79087. get x(): string | number;
  79088. set x(value: string | number);
  79089. /** Gets or sets y coordinate */
  79090. get y(): string | number;
  79091. set y(value: string | number);
  79092. /** Gets or sets the control associated with this point */
  79093. get control(): BABYLON.Nullable<Control>;
  79094. set control(value: BABYLON.Nullable<Control>);
  79095. /** Gets or sets the mesh associated with this point */
  79096. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  79097. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  79098. /** Resets links */
  79099. resetLinks(): void;
  79100. /**
  79101. * Gets a translation vector
  79102. * @returns the translation vector
  79103. */
  79104. translate(): BABYLON.Vector2;
  79105. private _translatePoint;
  79106. /** Release associated resources */
  79107. dispose(): void;
  79108. }
  79109. }
  79110. declare module BABYLON.GUI {
  79111. /**
  79112. * Class used to create multi line control
  79113. */
  79114. export class MultiLine extends Control {
  79115. name?: string | undefined;
  79116. private _lineWidth;
  79117. private _dash;
  79118. private _points;
  79119. private _minX;
  79120. private _minY;
  79121. private _maxX;
  79122. private _maxY;
  79123. /**
  79124. * Creates a new MultiLine
  79125. * @param name defines the control name
  79126. */
  79127. constructor(name?: string | undefined);
  79128. /** Gets or sets dash pattern */
  79129. get dash(): Array<number>;
  79130. set dash(value: Array<number>);
  79131. /**
  79132. * Gets point stored at specified index
  79133. * @param index defines the index to look for
  79134. * @returns the requested point if found
  79135. */
  79136. getAt(index: number): MultiLinePoint;
  79137. /** Function called when a point is updated */
  79138. onPointUpdate: () => void;
  79139. /**
  79140. * Adds new points to the point collection
  79141. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  79142. * @returns the list of created MultiLinePoint
  79143. */
  79144. add(...items: (AbstractMesh | Control | {
  79145. x: string | number;
  79146. y: string | number;
  79147. })[]): MultiLinePoint[];
  79148. /**
  79149. * Adds a new point to the point collection
  79150. * @param item defines the item (mesh, control or 2d coordiantes) to add
  79151. * @returns the created MultiLinePoint
  79152. */
  79153. push(item?: (AbstractMesh | Control | {
  79154. x: string | number;
  79155. y: string | number;
  79156. })): MultiLinePoint;
  79157. /**
  79158. * Remove a specific value or point from the active point collection
  79159. * @param value defines the value or point to remove
  79160. */
  79161. remove(value: number | MultiLinePoint): void;
  79162. /**
  79163. * Resets this object to initial state (no point)
  79164. */
  79165. reset(): void;
  79166. /**
  79167. * Resets all links
  79168. */
  79169. resetLinks(): void;
  79170. /** Gets or sets line width */
  79171. get lineWidth(): number;
  79172. set lineWidth(value: number);
  79173. set horizontalAlignment(value: number);
  79174. set verticalAlignment(value: number);
  79175. protected _getTypeName(): string;
  79176. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79177. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79178. _measure(): void;
  79179. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79180. dispose(): void;
  79181. }
  79182. }
  79183. declare module BABYLON.GUI {
  79184. /**
  79185. * Class used to create radio button controls
  79186. */
  79187. export class RadioButton extends Control {
  79188. name?: string | undefined;
  79189. private _isChecked;
  79190. private _background;
  79191. private _checkSizeRatio;
  79192. private _thickness;
  79193. /** Gets or sets border thickness */
  79194. get thickness(): number;
  79195. set thickness(value: number);
  79196. /** Gets or sets group name */
  79197. group: string;
  79198. /** BABYLON.Observable raised when isChecked is changed */
  79199. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79200. /** Gets or sets a value indicating the ratio between overall size and check size */
  79201. get checkSizeRatio(): number;
  79202. set checkSizeRatio(value: number);
  79203. /** Gets or sets background color */
  79204. get background(): string;
  79205. set background(value: string);
  79206. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79207. get isChecked(): boolean;
  79208. set isChecked(value: boolean);
  79209. /**
  79210. * Creates a new RadioButton
  79211. * @param name defines the control name
  79212. */
  79213. constructor(name?: string | undefined);
  79214. protected _getTypeName(): string;
  79215. _draw(context: CanvasRenderingContext2D): void;
  79216. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79217. /**
  79218. * Utility function to easily create a radio button with a header
  79219. * @param title defines the label to use for the header
  79220. * @param group defines the group to use for the radio button
  79221. * @param isChecked defines the initial state of the radio button
  79222. * @param onValueChanged defines the callback to call when value changes
  79223. * @returns a StackPanel containing the radio button and a textBlock
  79224. */
  79225. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  79226. }
  79227. }
  79228. declare module BABYLON.GUI {
  79229. /**
  79230. * Class used to create slider controls
  79231. */
  79232. export class BaseSlider extends Control {
  79233. name?: string | undefined;
  79234. protected _thumbWidth: ValueAndUnit;
  79235. private _minimum;
  79236. private _maximum;
  79237. private _value;
  79238. private _isVertical;
  79239. protected _barOffset: ValueAndUnit;
  79240. private _isThumbClamped;
  79241. protected _displayThumb: boolean;
  79242. private _step;
  79243. private _lastPointerDownID;
  79244. protected _effectiveBarOffset: number;
  79245. protected _renderLeft: number;
  79246. protected _renderTop: number;
  79247. protected _renderWidth: number;
  79248. protected _renderHeight: number;
  79249. protected _backgroundBoxLength: number;
  79250. protected _backgroundBoxThickness: number;
  79251. protected _effectiveThumbThickness: number;
  79252. /** BABYLON.Observable raised when the sldier value changes */
  79253. onValueChangedObservable: BABYLON.Observable<number>;
  79254. /** Gets or sets a boolean indicating if the thumb must be rendered */
  79255. get displayThumb(): boolean;
  79256. set displayThumb(value: boolean);
  79257. /** Gets or sets a step to apply to values (0 by default) */
  79258. get step(): number;
  79259. set step(value: number);
  79260. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  79261. get barOffset(): string | number;
  79262. /** Gets main bar offset in pixels*/
  79263. get barOffsetInPixels(): number;
  79264. set barOffset(value: string | number);
  79265. /** Gets or sets thumb width */
  79266. get thumbWidth(): string | number;
  79267. /** Gets thumb width in pixels */
  79268. get thumbWidthInPixels(): number;
  79269. set thumbWidth(value: string | number);
  79270. /** Gets or sets minimum value */
  79271. get minimum(): number;
  79272. set minimum(value: number);
  79273. /** Gets or sets maximum value */
  79274. get maximum(): number;
  79275. set maximum(value: number);
  79276. /** Gets or sets current value */
  79277. get value(): number;
  79278. set value(value: number);
  79279. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  79280. get isVertical(): boolean;
  79281. set isVertical(value: boolean);
  79282. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  79283. get isThumbClamped(): boolean;
  79284. set isThumbClamped(value: boolean);
  79285. /**
  79286. * Creates a new BaseSlider
  79287. * @param name defines the control name
  79288. */
  79289. constructor(name?: string | undefined);
  79290. protected _getTypeName(): string;
  79291. protected _getThumbPosition(): number;
  79292. protected _getThumbThickness(type: string): number;
  79293. protected _prepareRenderingData(type: string): void;
  79294. private _pointerIsDown;
  79295. /** @hidden */
  79296. protected _updateValueFromPointer(x: number, y: number): void;
  79297. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79298. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  79299. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79300. _onCanvasBlur(): void;
  79301. }
  79302. }
  79303. declare module BABYLON.GUI {
  79304. /**
  79305. * Class used to create slider controls
  79306. */
  79307. export class Slider extends BaseSlider {
  79308. name?: string | undefined;
  79309. private _background;
  79310. private _borderColor;
  79311. private _thumbColor;
  79312. private _isThumbCircle;
  79313. protected _displayValueBar: boolean;
  79314. /** Gets or sets a boolean indicating if the value bar must be rendered */
  79315. get displayValueBar(): boolean;
  79316. set displayValueBar(value: boolean);
  79317. /** Gets or sets border color */
  79318. get borderColor(): string;
  79319. set borderColor(value: string);
  79320. /** Gets or sets background color */
  79321. get background(): string;
  79322. set background(value: string);
  79323. /** Gets or sets thumb's color */
  79324. get thumbColor(): string;
  79325. set thumbColor(value: string);
  79326. /** Gets or sets a boolean indicating if the thumb should be round or square */
  79327. get isThumbCircle(): boolean;
  79328. set isThumbCircle(value: boolean);
  79329. /**
  79330. * Creates a new Slider
  79331. * @param name defines the control name
  79332. */
  79333. constructor(name?: string | undefined);
  79334. protected _getTypeName(): string;
  79335. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79336. }
  79337. }
  79338. declare module BABYLON.GUI {
  79339. /** Class used to create a RadioGroup
  79340. * which contains groups of radio buttons
  79341. */
  79342. export class SelectorGroup {
  79343. /** name of SelectorGroup */
  79344. name: string;
  79345. private _groupPanel;
  79346. private _selectors;
  79347. private _groupHeader;
  79348. /**
  79349. * Creates a new SelectorGroup
  79350. * @param name of group, used as a group heading
  79351. */
  79352. constructor(
  79353. /** name of SelectorGroup */
  79354. name: string);
  79355. /** Gets the groupPanel of the SelectorGroup */
  79356. get groupPanel(): StackPanel;
  79357. /** Gets the selectors array */
  79358. get selectors(): StackPanel[];
  79359. /** Gets and sets the group header */
  79360. get header(): string;
  79361. set header(label: string);
  79362. /** @hidden */
  79363. private _addGroupHeader;
  79364. /** @hidden*/
  79365. _getSelector(selectorNb: number): StackPanel | undefined;
  79366. /** Removes the selector at the given position
  79367. * @param selectorNb the position of the selector within the group
  79368. */
  79369. removeSelector(selectorNb: number): void;
  79370. }
  79371. /** Class used to create a CheckboxGroup
  79372. * which contains groups of checkbox buttons
  79373. */
  79374. export class CheckboxGroup extends SelectorGroup {
  79375. /** Adds a checkbox as a control
  79376. * @param text is the label for the selector
  79377. * @param func is the function called when the Selector is checked
  79378. * @param checked is true when Selector is checked
  79379. */
  79380. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  79381. /** @hidden */
  79382. _setSelectorLabel(selectorNb: number, label: string): void;
  79383. /** @hidden */
  79384. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79385. /** @hidden */
  79386. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79387. /** @hidden */
  79388. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79389. }
  79390. /** Class used to create a RadioGroup
  79391. * which contains groups of radio buttons
  79392. */
  79393. export class RadioGroup extends SelectorGroup {
  79394. private _selectNb;
  79395. /** Adds a radio button as a control
  79396. * @param label is the label for the selector
  79397. * @param func is the function called when the Selector is checked
  79398. * @param checked is true when Selector is checked
  79399. */
  79400. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  79401. /** @hidden */
  79402. _setSelectorLabel(selectorNb: number, label: string): void;
  79403. /** @hidden */
  79404. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79405. /** @hidden */
  79406. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79407. /** @hidden */
  79408. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79409. }
  79410. /** Class used to create a SliderGroup
  79411. * which contains groups of slider buttons
  79412. */
  79413. export class SliderGroup extends SelectorGroup {
  79414. /**
  79415. * Adds a slider to the SelectorGroup
  79416. * @param label is the label for the SliderBar
  79417. * @param func is the function called when the Slider moves
  79418. * @param unit is a string describing the units used, eg degrees or metres
  79419. * @param min is the minimum value for the Slider
  79420. * @param max is the maximum value for the Slider
  79421. * @param value is the start value for the Slider between min and max
  79422. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  79423. */
  79424. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  79425. /** @hidden */
  79426. _setSelectorLabel(selectorNb: number, label: string): void;
  79427. /** @hidden */
  79428. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79429. /** @hidden */
  79430. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79431. /** @hidden */
  79432. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79433. }
  79434. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  79435. * @see https://doc.babylonjs.com/how_to/selector
  79436. */
  79437. export class SelectionPanel extends Rectangle {
  79438. /** name of SelectionPanel */
  79439. name: string;
  79440. /** an array of SelectionGroups */
  79441. groups: SelectorGroup[];
  79442. private _panel;
  79443. private _buttonColor;
  79444. private _buttonBackground;
  79445. private _headerColor;
  79446. private _barColor;
  79447. private _barHeight;
  79448. private _spacerHeight;
  79449. private _labelColor;
  79450. private _groups;
  79451. private _bars;
  79452. /**
  79453. * Creates a new SelectionPanel
  79454. * @param name of SelectionPanel
  79455. * @param groups is an array of SelectionGroups
  79456. */
  79457. constructor(
  79458. /** name of SelectionPanel */
  79459. name: string,
  79460. /** an array of SelectionGroups */
  79461. groups?: SelectorGroup[]);
  79462. protected _getTypeName(): string;
  79463. /** Gets or sets the headerColor */
  79464. get headerColor(): string;
  79465. set headerColor(color: string);
  79466. private _setHeaderColor;
  79467. /** Gets or sets the button color */
  79468. get buttonColor(): string;
  79469. set buttonColor(color: string);
  79470. private _setbuttonColor;
  79471. /** Gets or sets the label color */
  79472. get labelColor(): string;
  79473. set labelColor(color: string);
  79474. private _setLabelColor;
  79475. /** Gets or sets the button background */
  79476. get buttonBackground(): string;
  79477. set buttonBackground(color: string);
  79478. private _setButtonBackground;
  79479. /** Gets or sets the color of separator bar */
  79480. get barColor(): string;
  79481. set barColor(color: string);
  79482. private _setBarColor;
  79483. /** Gets or sets the height of separator bar */
  79484. get barHeight(): string;
  79485. set barHeight(value: string);
  79486. private _setBarHeight;
  79487. /** Gets or sets the height of spacers*/
  79488. get spacerHeight(): string;
  79489. set spacerHeight(value: string);
  79490. private _setSpacerHeight;
  79491. /** Adds a bar between groups */
  79492. private _addSpacer;
  79493. /** Add a group to the selection panel
  79494. * @param group is the selector group to add
  79495. */
  79496. addGroup(group: SelectorGroup): void;
  79497. /** Remove the group from the given position
  79498. * @param groupNb is the position of the group in the list
  79499. */
  79500. removeGroup(groupNb: number): void;
  79501. /** Change a group header label
  79502. * @param label is the new group header label
  79503. * @param groupNb is the number of the group to relabel
  79504. * */
  79505. setHeaderName(label: string, groupNb: number): void;
  79506. /** Change selector label to the one given
  79507. * @param label is the new selector label
  79508. * @param groupNb is the number of the groupcontaining the selector
  79509. * @param selectorNb is the number of the selector within a group to relabel
  79510. * */
  79511. relabel(label: string, groupNb: number, selectorNb: number): void;
  79512. /** For a given group position remove the selector at the given position
  79513. * @param groupNb is the number of the group to remove the selector from
  79514. * @param selectorNb is the number of the selector within the group
  79515. */
  79516. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  79517. /** For a given group position of correct type add a checkbox button
  79518. * @param groupNb is the number of the group to remove the selector from
  79519. * @param label is the label for the selector
  79520. * @param func is the function called when the Selector is checked
  79521. * @param checked is true when Selector is checked
  79522. */
  79523. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  79524. /** For a given group position of correct type add a radio button
  79525. * @param groupNb is the number of the group to remove the selector from
  79526. * @param label is the label for the selector
  79527. * @param func is the function called when the Selector is checked
  79528. * @param checked is true when Selector is checked
  79529. */
  79530. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  79531. /**
  79532. * For a given slider group add a slider
  79533. * @param groupNb is the number of the group to add the slider to
  79534. * @param label is the label for the Slider
  79535. * @param func is the function called when the Slider moves
  79536. * @param unit is a string describing the units used, eg degrees or metres
  79537. * @param min is the minimum value for the Slider
  79538. * @param max is the maximum value for the Slider
  79539. * @param value is the start value for the Slider between min and max
  79540. * @param onVal is the function used to format the value displayed, eg radians to degrees
  79541. */
  79542. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  79543. }
  79544. }
  79545. declare module BABYLON.GUI {
  79546. /**
  79547. * Class used to hold a the container for ScrollViewer
  79548. * @hidden
  79549. */
  79550. export class _ScrollViewerWindow extends Container {
  79551. parentClientWidth: number;
  79552. parentClientHeight: number;
  79553. private _freezeControls;
  79554. private _parentMeasure;
  79555. private _oldLeft;
  79556. private _oldTop;
  79557. get freezeControls(): boolean;
  79558. set freezeControls(value: boolean);
  79559. private _bucketWidth;
  79560. private _bucketHeight;
  79561. private _buckets;
  79562. private _bucketLen;
  79563. get bucketWidth(): number;
  79564. get bucketHeight(): number;
  79565. setBucketSizes(width: number, height: number): void;
  79566. private _useBuckets;
  79567. private _makeBuckets;
  79568. private _dispatchInBuckets;
  79569. private _updateMeasures;
  79570. private _updateChildrenMeasures;
  79571. private _restoreMeasures;
  79572. /**
  79573. * Creates a new ScrollViewerWindow
  79574. * @param name of ScrollViewerWindow
  79575. */
  79576. constructor(name?: string);
  79577. protected _getTypeName(): string;
  79578. /** @hidden */
  79579. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79580. /** @hidden */
  79581. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79582. private _scrollChildren;
  79583. private _scrollChildrenWithBuckets;
  79584. /** @hidden */
  79585. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  79586. protected _postMeasure(): void;
  79587. }
  79588. }
  79589. declare module BABYLON.GUI {
  79590. /**
  79591. * Class used to create slider controls
  79592. */
  79593. export class ScrollBar extends BaseSlider {
  79594. name?: string | undefined;
  79595. private _background;
  79596. private _borderColor;
  79597. private _tempMeasure;
  79598. /** Gets or sets border color */
  79599. get borderColor(): string;
  79600. set borderColor(value: string);
  79601. /** Gets or sets background color */
  79602. get background(): string;
  79603. set background(value: string);
  79604. /**
  79605. * Creates a new Slider
  79606. * @param name defines the control name
  79607. */
  79608. constructor(name?: string | undefined);
  79609. protected _getTypeName(): string;
  79610. protected _getThumbThickness(): number;
  79611. _draw(context: CanvasRenderingContext2D): void;
  79612. private _first;
  79613. private _originX;
  79614. private _originY;
  79615. /** @hidden */
  79616. protected _updateValueFromPointer(x: number, y: number): void;
  79617. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79618. }
  79619. }
  79620. declare module BABYLON.GUI {
  79621. /**
  79622. * Class used to create slider controls
  79623. */
  79624. export class ImageScrollBar extends BaseSlider {
  79625. name?: string | undefined;
  79626. private _backgroundBaseImage;
  79627. private _backgroundImage;
  79628. private _thumbImage;
  79629. private _thumbBaseImage;
  79630. private _thumbLength;
  79631. private _thumbHeight;
  79632. private _barImageHeight;
  79633. private _tempMeasure;
  79634. /** Number of 90° rotation to apply on the images when in vertical mode */
  79635. num90RotationInVerticalMode: number;
  79636. /**
  79637. * Gets or sets the image used to render the background for horizontal bar
  79638. */
  79639. get backgroundImage(): Image;
  79640. set backgroundImage(value: Image);
  79641. /**
  79642. * Gets or sets the image used to render the thumb
  79643. */
  79644. get thumbImage(): Image;
  79645. set thumbImage(value: Image);
  79646. /**
  79647. * Gets or sets the length of the thumb
  79648. */
  79649. get thumbLength(): number;
  79650. set thumbLength(value: number);
  79651. /**
  79652. * Gets or sets the height of the thumb
  79653. */
  79654. get thumbHeight(): number;
  79655. set thumbHeight(value: number);
  79656. /**
  79657. * Gets or sets the height of the bar image
  79658. */
  79659. get barImageHeight(): number;
  79660. set barImageHeight(value: number);
  79661. /**
  79662. * Creates a new ImageScrollBar
  79663. * @param name defines the control name
  79664. */
  79665. constructor(name?: string | undefined);
  79666. protected _getTypeName(): string;
  79667. protected _getThumbThickness(): number;
  79668. _draw(context: CanvasRenderingContext2D): void;
  79669. private _first;
  79670. private _originX;
  79671. private _originY;
  79672. /** @hidden */
  79673. protected _updateValueFromPointer(x: number, y: number): void;
  79674. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79675. }
  79676. }
  79677. declare module BABYLON.GUI {
  79678. /**
  79679. * Class used to hold a viewer window and sliders in a grid
  79680. */
  79681. export class ScrollViewer extends Rectangle {
  79682. private _grid;
  79683. private _horizontalBarSpace;
  79684. private _verticalBarSpace;
  79685. private _dragSpace;
  79686. private _horizontalBar;
  79687. private _verticalBar;
  79688. private _barColor;
  79689. private _barBackground;
  79690. private _barImage;
  79691. private _horizontalBarImage;
  79692. private _verticalBarImage;
  79693. private _barBackgroundImage;
  79694. private _horizontalBarBackgroundImage;
  79695. private _verticalBarBackgroundImage;
  79696. private _barSize;
  79697. private _window;
  79698. private _pointerIsOver;
  79699. private _wheelPrecision;
  79700. private _onWheelObserver;
  79701. private _clientWidth;
  79702. private _clientHeight;
  79703. private _useImageBar;
  79704. private _thumbLength;
  79705. private _thumbHeight;
  79706. private _barImageHeight;
  79707. private _horizontalBarImageHeight;
  79708. private _verticalBarImageHeight;
  79709. private _oldWindowContentsWidth;
  79710. private _oldWindowContentsHeight;
  79711. /**
  79712. * Gets the horizontal scrollbar
  79713. */
  79714. get horizontalBar(): ScrollBar | ImageScrollBar;
  79715. /**
  79716. * Gets the vertical scrollbar
  79717. */
  79718. get verticalBar(): ScrollBar | ImageScrollBar;
  79719. /**
  79720. * Adds a new control to the current container
  79721. * @param control defines the control to add
  79722. * @returns the current container
  79723. */
  79724. addControl(control: BABYLON.Nullable<Control>): Container;
  79725. /**
  79726. * Removes a control from the current container
  79727. * @param control defines the control to remove
  79728. * @returns the current container
  79729. */
  79730. removeControl(control: Control): Container;
  79731. /** Gets the list of children */
  79732. get children(): Control[];
  79733. _flagDescendantsAsMatrixDirty(): void;
  79734. /**
  79735. * Freezes or unfreezes the controls in the window.
  79736. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  79737. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  79738. */
  79739. get freezeControls(): boolean;
  79740. set freezeControls(value: boolean);
  79741. /** Gets the bucket width */
  79742. get bucketWidth(): number;
  79743. /** Gets the bucket height */
  79744. get bucketHeight(): number;
  79745. /**
  79746. * Sets the bucket sizes.
  79747. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  79748. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  79749. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  79750. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  79751. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  79752. * used), that's why it is not enabled by default.
  79753. * @param width width of the bucket
  79754. * @param height height of the bucket
  79755. */
  79756. setBucketSizes(width: number, height: number): void;
  79757. private _forceHorizontalBar;
  79758. private _forceVerticalBar;
  79759. /**
  79760. * Forces the horizontal scroll bar to be displayed
  79761. */
  79762. get forceHorizontalBar(): boolean;
  79763. set forceHorizontalBar(value: boolean);
  79764. /**
  79765. * Forces the vertical scroll bar to be displayed
  79766. */
  79767. get forceVerticalBar(): boolean;
  79768. set forceVerticalBar(value: boolean);
  79769. /**
  79770. * Creates a new ScrollViewer
  79771. * @param name of ScrollViewer
  79772. */
  79773. constructor(name?: string, isImageBased?: boolean);
  79774. /** Reset the scroll viewer window to initial size */
  79775. resetWindow(): void;
  79776. protected _getTypeName(): string;
  79777. private _buildClientSizes;
  79778. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79779. protected _postMeasure(): void;
  79780. /**
  79781. * Gets or sets the mouse wheel precision
  79782. * from 0 to 1 with a default value of 0.05
  79783. * */
  79784. get wheelPrecision(): number;
  79785. set wheelPrecision(value: number);
  79786. /** Gets or sets the scroll bar container background color */
  79787. get scrollBackground(): string;
  79788. set scrollBackground(color: string);
  79789. /** Gets or sets the bar color */
  79790. get barColor(): string;
  79791. set barColor(color: string);
  79792. /** Gets or sets the bar image */
  79793. get thumbImage(): Image;
  79794. set thumbImage(value: Image);
  79795. /** Gets or sets the horizontal bar image */
  79796. get horizontalThumbImage(): Image;
  79797. set horizontalThumbImage(value: Image);
  79798. /** Gets or sets the vertical bar image */
  79799. get verticalThumbImage(): Image;
  79800. set verticalThumbImage(value: Image);
  79801. /** Gets or sets the size of the bar */
  79802. get barSize(): number;
  79803. set barSize(value: number);
  79804. /** Gets or sets the length of the thumb */
  79805. get thumbLength(): number;
  79806. set thumbLength(value: number);
  79807. /** Gets or sets the height of the thumb */
  79808. get thumbHeight(): number;
  79809. set thumbHeight(value: number);
  79810. /** Gets or sets the height of the bar image */
  79811. get barImageHeight(): number;
  79812. set barImageHeight(value: number);
  79813. /** Gets or sets the height of the horizontal bar image */
  79814. get horizontalBarImageHeight(): number;
  79815. set horizontalBarImageHeight(value: number);
  79816. /** Gets or sets the height of the vertical bar image */
  79817. get verticalBarImageHeight(): number;
  79818. set verticalBarImageHeight(value: number);
  79819. /** Gets or sets the bar background */
  79820. get barBackground(): string;
  79821. set barBackground(color: string);
  79822. /** Gets or sets the bar background image */
  79823. get barImage(): Image;
  79824. set barImage(value: Image);
  79825. /** Gets or sets the horizontal bar background image */
  79826. get horizontalBarImage(): Image;
  79827. set horizontalBarImage(value: Image);
  79828. /** Gets or sets the vertical bar background image */
  79829. get verticalBarImage(): Image;
  79830. set verticalBarImage(value: Image);
  79831. private _setWindowPosition;
  79832. /** @hidden */
  79833. private _updateScroller;
  79834. _link(host: AdvancedDynamicTexture): void;
  79835. /** @hidden */
  79836. private _addBar;
  79837. /** @hidden */
  79838. private _attachWheel;
  79839. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79840. /** Releases associated resources */
  79841. dispose(): void;
  79842. }
  79843. }
  79844. declare module BABYLON.GUI {
  79845. /** Class used to render a grid */
  79846. export class DisplayGrid extends Control {
  79847. name?: string | undefined;
  79848. private _cellWidth;
  79849. private _cellHeight;
  79850. private _minorLineTickness;
  79851. private _minorLineColor;
  79852. private _majorLineTickness;
  79853. private _majorLineColor;
  79854. private _majorLineFrequency;
  79855. private _background;
  79856. private _displayMajorLines;
  79857. private _displayMinorLines;
  79858. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  79859. get displayMinorLines(): boolean;
  79860. set displayMinorLines(value: boolean);
  79861. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  79862. get displayMajorLines(): boolean;
  79863. set displayMajorLines(value: boolean);
  79864. /** Gets or sets background color (Black by default) */
  79865. get background(): string;
  79866. set background(value: string);
  79867. /** Gets or sets the width of each cell (20 by default) */
  79868. get cellWidth(): number;
  79869. set cellWidth(value: number);
  79870. /** Gets or sets the height of each cell (20 by default) */
  79871. get cellHeight(): number;
  79872. set cellHeight(value: number);
  79873. /** Gets or sets the tickness of minor lines (1 by default) */
  79874. get minorLineTickness(): number;
  79875. set minorLineTickness(value: number);
  79876. /** Gets or sets the color of minor lines (DarkGray by default) */
  79877. get minorLineColor(): string;
  79878. set minorLineColor(value: string);
  79879. /** Gets or sets the tickness of major lines (2 by default) */
  79880. get majorLineTickness(): number;
  79881. set majorLineTickness(value: number);
  79882. /** Gets or sets the color of major lines (White by default) */
  79883. get majorLineColor(): string;
  79884. set majorLineColor(value: string);
  79885. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  79886. get majorLineFrequency(): number;
  79887. set majorLineFrequency(value: number);
  79888. /**
  79889. * Creates a new GridDisplayRectangle
  79890. * @param name defines the control name
  79891. */
  79892. constructor(name?: string | undefined);
  79893. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79894. protected _getTypeName(): string;
  79895. }
  79896. }
  79897. declare module BABYLON.GUI {
  79898. /**
  79899. * Class used to create slider controls based on images
  79900. */
  79901. export class ImageBasedSlider extends BaseSlider {
  79902. name?: string | undefined;
  79903. private _backgroundImage;
  79904. private _thumbImage;
  79905. private _valueBarImage;
  79906. private _tempMeasure;
  79907. get displayThumb(): boolean;
  79908. set displayThumb(value: boolean);
  79909. /**
  79910. * Gets or sets the image used to render the background
  79911. */
  79912. get backgroundImage(): Image;
  79913. set backgroundImage(value: Image);
  79914. /**
  79915. * Gets or sets the image used to render the value bar
  79916. */
  79917. get valueBarImage(): Image;
  79918. set valueBarImage(value: Image);
  79919. /**
  79920. * Gets or sets the image used to render the thumb
  79921. */
  79922. get thumbImage(): Image;
  79923. set thumbImage(value: Image);
  79924. /**
  79925. * Creates a new ImageBasedSlider
  79926. * @param name defines the control name
  79927. */
  79928. constructor(name?: string | undefined);
  79929. protected _getTypeName(): string;
  79930. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79931. }
  79932. }
  79933. declare module BABYLON.GUI {
  79934. /**
  79935. * Forcing an export so that this code will execute
  79936. * @hidden
  79937. */
  79938. const name = "Statics";
  79939. }
  79940. declare module BABYLON.GUI {
  79941. /**
  79942. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  79943. */
  79944. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  79945. /**
  79946. * Define the instrumented AdvancedDynamicTexture.
  79947. */
  79948. texture: AdvancedDynamicTexture;
  79949. private _captureRenderTime;
  79950. private _renderTime;
  79951. private _captureLayoutTime;
  79952. private _layoutTime;
  79953. private _onBeginRenderObserver;
  79954. private _onEndRenderObserver;
  79955. private _onBeginLayoutObserver;
  79956. private _onEndLayoutObserver;
  79957. /**
  79958. * Gets the perf counter used to capture render time
  79959. */
  79960. get renderTimeCounter(): BABYLON.PerfCounter;
  79961. /**
  79962. * Gets the perf counter used to capture layout time
  79963. */
  79964. get layoutTimeCounter(): BABYLON.PerfCounter;
  79965. /**
  79966. * Enable or disable the render time capture
  79967. */
  79968. get captureRenderTime(): boolean;
  79969. set captureRenderTime(value: boolean);
  79970. /**
  79971. * Enable or disable the layout time capture
  79972. */
  79973. get captureLayoutTime(): boolean;
  79974. set captureLayoutTime(value: boolean);
  79975. /**
  79976. * Instantiates a new advanced dynamic texture instrumentation.
  79977. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  79978. * @param texture Defines the AdvancedDynamicTexture to instrument
  79979. */
  79980. constructor(
  79981. /**
  79982. * Define the instrumented AdvancedDynamicTexture.
  79983. */
  79984. texture: AdvancedDynamicTexture);
  79985. /**
  79986. * Dispose and release associated resources.
  79987. */
  79988. dispose(): void;
  79989. }
  79990. }
  79991. declare module BABYLON.GUI {
  79992. /**
  79993. * Class used to load GUI via XML.
  79994. */
  79995. export class XmlLoader {
  79996. private _nodes;
  79997. private _nodeTypes;
  79998. private _isLoaded;
  79999. private _objectAttributes;
  80000. private _parentClass;
  80001. /**
  80002. * Create a new xml loader
  80003. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  80004. */
  80005. constructor(parentClass?: null);
  80006. private _getChainElement;
  80007. private _getClassAttribute;
  80008. private _createGuiElement;
  80009. private _parseGrid;
  80010. private _parseElement;
  80011. private _prepareSourceElement;
  80012. private _parseElementsFromSource;
  80013. private _parseXml;
  80014. /**
  80015. * Gets if the loading has finished.
  80016. * @returns whether the loading has finished or not
  80017. */
  80018. isLoaded(): boolean;
  80019. /**
  80020. * Gets a loaded node / control by id.
  80021. * @param id the Controls id set in the xml
  80022. * @returns element of type Control
  80023. */
  80024. getNodeById(id: string): any;
  80025. /**
  80026. * Gets all loaded nodes / controls
  80027. * @returns Array of controls
  80028. */
  80029. getNodes(): any;
  80030. /**
  80031. * Initiates the xml layout loading
  80032. * @param xmlFile defines the xml layout to load
  80033. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  80034. * @param callback defines the callback called on layout load.
  80035. */
  80036. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  80037. }
  80038. }
  80039. declare module BABYLON.GUI {
  80040. /**
  80041. * Class used to create containers for controls
  80042. */
  80043. export class Container3D extends Control3D {
  80044. private _blockLayout;
  80045. /**
  80046. * Gets the list of child controls
  80047. */
  80048. protected _children: Control3D[];
  80049. /**
  80050. * Gets the list of child controls
  80051. */
  80052. get children(): Array<Control3D>;
  80053. /**
  80054. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  80055. * This is helpful to optimize layout operation when adding multiple children in a row
  80056. */
  80057. get blockLayout(): boolean;
  80058. set blockLayout(value: boolean);
  80059. /**
  80060. * Creates a new container
  80061. * @param name defines the container name
  80062. */
  80063. constructor(name?: string);
  80064. /**
  80065. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  80066. * @returns the current container
  80067. */
  80068. updateLayout(): Container3D;
  80069. /**
  80070. * Gets a boolean indicating if the given control is in the children of this control
  80071. * @param control defines the control to check
  80072. * @returns true if the control is in the child list
  80073. */
  80074. containsControl(control: Control3D): boolean;
  80075. /**
  80076. * Adds a control to the children of this control
  80077. * @param control defines the control to add
  80078. * @returns the current container
  80079. */
  80080. addControl(control: Control3D): Container3D;
  80081. /**
  80082. * This function will be called everytime a new control is added
  80083. */
  80084. protected _arrangeChildren(): void;
  80085. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  80086. /**
  80087. * Removes a control from the children of this control
  80088. * @param control defines the control to remove
  80089. * @returns the current container
  80090. */
  80091. removeControl(control: Control3D): Container3D;
  80092. protected _getTypeName(): string;
  80093. /**
  80094. * Releases all associated resources
  80095. */
  80096. dispose(): void;
  80097. /** Control rotation will remain unchanged */
  80098. static readonly UNSET_ORIENTATION: number;
  80099. /** Control will rotate to make it look at sphere central axis */
  80100. static readonly FACEORIGIN_ORIENTATION: number;
  80101. /** Control will rotate to make it look back at sphere central axis */
  80102. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  80103. /** Control will rotate to look at z axis (0, 0, 1) */
  80104. static readonly FACEFORWARD_ORIENTATION: number;
  80105. /** Control will rotate to look at negative z axis (0, 0, -1) */
  80106. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  80107. }
  80108. }
  80109. declare module BABYLON.GUI {
  80110. /**
  80111. * Class used to manage 3D user interface
  80112. * @see https://doc.babylonjs.com/how_to/gui3d
  80113. */
  80114. export class GUI3DManager implements BABYLON.IDisposable {
  80115. private _scene;
  80116. private _sceneDisposeObserver;
  80117. private _utilityLayer;
  80118. private _rootContainer;
  80119. private _pointerObserver;
  80120. private _pointerOutObserver;
  80121. /** @hidden */
  80122. _lastPickedControl: Control3D;
  80123. /** @hidden */
  80124. _lastControlOver: {
  80125. [pointerId: number]: Control3D;
  80126. };
  80127. /** @hidden */
  80128. _lastControlDown: {
  80129. [pointerId: number]: Control3D;
  80130. };
  80131. /**
  80132. * BABYLON.Observable raised when the point picked by the pointer events changed
  80133. */
  80134. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  80135. /** @hidden */
  80136. _sharedMaterials: {
  80137. [key: string]: BABYLON.Material;
  80138. };
  80139. /** Gets the hosting scene */
  80140. get scene(): BABYLON.Scene;
  80141. /** Gets associated utility layer */
  80142. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  80143. /**
  80144. * Creates a new GUI3DManager
  80145. * @param scene
  80146. */
  80147. constructor(scene?: BABYLON.Scene);
  80148. private _handlePointerOut;
  80149. private _doPicking;
  80150. /**
  80151. * Gets the root container
  80152. */
  80153. get rootContainer(): Container3D;
  80154. /**
  80155. * Gets a boolean indicating if the given control is in the root child list
  80156. * @param control defines the control to check
  80157. * @returns true if the control is in the root child list
  80158. */
  80159. containsControl(control: Control3D): boolean;
  80160. /**
  80161. * Adds a control to the root child list
  80162. * @param control defines the control to add
  80163. * @returns the current manager
  80164. */
  80165. addControl(control: Control3D): GUI3DManager;
  80166. /**
  80167. * Removes a control from the root child list
  80168. * @param control defines the control to remove
  80169. * @returns the current container
  80170. */
  80171. removeControl(control: Control3D): GUI3DManager;
  80172. /**
  80173. * Releases all associated resources
  80174. */
  80175. dispose(): void;
  80176. }
  80177. }
  80178. declare module BABYLON.GUI {
  80179. /**
  80180. * Class used to transport BABYLON.Vector3 information for pointer events
  80181. */
  80182. export class Vector3WithInfo extends BABYLON.Vector3 {
  80183. /** defines the current mouse button index */
  80184. buttonIndex: number;
  80185. /**
  80186. * Creates a new Vector3WithInfo
  80187. * @param source defines the vector3 data to transport
  80188. * @param buttonIndex defines the current mouse button index
  80189. */
  80190. constructor(source: BABYLON.Vector3,
  80191. /** defines the current mouse button index */
  80192. buttonIndex?: number);
  80193. }
  80194. }
  80195. declare module BABYLON.GUI {
  80196. /**
  80197. * Class used as base class for controls
  80198. */
  80199. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  80200. /** Defines the control name */
  80201. name?: string | undefined;
  80202. /** @hidden */
  80203. _host: GUI3DManager;
  80204. private _node;
  80205. private _downCount;
  80206. private _enterCount;
  80207. private _downPointerIds;
  80208. private _isVisible;
  80209. /** Gets or sets the control position in world space */
  80210. get position(): BABYLON.Vector3;
  80211. set position(value: BABYLON.Vector3);
  80212. /** Gets or sets the control scaling in world space */
  80213. get scaling(): BABYLON.Vector3;
  80214. set scaling(value: BABYLON.Vector3);
  80215. /** Callback used to start pointer enter animation */
  80216. pointerEnterAnimation: () => void;
  80217. /** Callback used to start pointer out animation */
  80218. pointerOutAnimation: () => void;
  80219. /** Callback used to start pointer down animation */
  80220. pointerDownAnimation: () => void;
  80221. /** Callback used to start pointer up animation */
  80222. pointerUpAnimation: () => void;
  80223. /**
  80224. * An event triggered when the pointer move over the control
  80225. */
  80226. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  80227. /**
  80228. * An event triggered when the pointer move out of the control
  80229. */
  80230. onPointerOutObservable: BABYLON.Observable<Control3D>;
  80231. /**
  80232. * An event triggered when the pointer taps the control
  80233. */
  80234. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  80235. /**
  80236. * An event triggered when pointer is up
  80237. */
  80238. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  80239. /**
  80240. * An event triggered when a control is clicked on (with a mouse)
  80241. */
  80242. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  80243. /**
  80244. * An event triggered when pointer enters the control
  80245. */
  80246. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  80247. /**
  80248. * Gets or sets the parent container
  80249. */
  80250. parent: BABYLON.Nullable<Container3D>;
  80251. private _behaviors;
  80252. /**
  80253. * Gets the list of attached behaviors
  80254. * @see https://doc.babylonjs.com/features/behaviour
  80255. */
  80256. get behaviors(): BABYLON.Behavior<Control3D>[];
  80257. /**
  80258. * Attach a behavior to the control
  80259. * @see https://doc.babylonjs.com/features/behaviour
  80260. * @param behavior defines the behavior to attach
  80261. * @returns the current control
  80262. */
  80263. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  80264. /**
  80265. * Remove an attached behavior
  80266. * @see https://doc.babylonjs.com/features/behaviour
  80267. * @param behavior defines the behavior to attach
  80268. * @returns the current control
  80269. */
  80270. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  80271. /**
  80272. * Gets an attached behavior by name
  80273. * @param name defines the name of the behavior to look for
  80274. * @see https://doc.babylonjs.com/features/behaviour
  80275. * @returns null if behavior was not found else the requested behavior
  80276. */
  80277. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  80278. /** Gets or sets a boolean indicating if the control is visible */
  80279. get isVisible(): boolean;
  80280. set isVisible(value: boolean);
  80281. /**
  80282. * Creates a new control
  80283. * @param name defines the control name
  80284. */
  80285. constructor(
  80286. /** Defines the control name */
  80287. name?: string | undefined);
  80288. /**
  80289. * Gets a string representing the class name
  80290. */
  80291. get typeName(): string;
  80292. /**
  80293. * Get the current class name of the control.
  80294. * @returns current class name
  80295. */
  80296. getClassName(): string;
  80297. protected _getTypeName(): string;
  80298. /**
  80299. * Gets the transform node used by this control
  80300. */
  80301. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  80302. /**
  80303. * Gets the mesh used to render this control
  80304. */
  80305. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80306. /**
  80307. * Link the control as child of the given node
  80308. * @param node defines the node to link to. Use null to unlink the control
  80309. * @returns the current control
  80310. */
  80311. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  80312. /** @hidden **/
  80313. _prepareNode(scene: BABYLON.Scene): void;
  80314. /**
  80315. * Node creation.
  80316. * Can be overriden by children
  80317. * @param scene defines the scene where the node must be attached
  80318. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  80319. */
  80320. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  80321. /**
  80322. * Affect a material to the given mesh
  80323. * @param mesh defines the mesh which will represent the control
  80324. */
  80325. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80326. /** @hidden */
  80327. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  80328. /** @hidden */
  80329. _onPointerEnter(target: Control3D): boolean;
  80330. /** @hidden */
  80331. _onPointerOut(target: Control3D): void;
  80332. /** @hidden */
  80333. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  80334. /** @hidden */
  80335. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80336. /** @hidden */
  80337. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  80338. /** @hidden */
  80339. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  80340. /** @hidden */
  80341. _disposeNode(): void;
  80342. /**
  80343. * Releases all associated resources
  80344. */
  80345. dispose(): void;
  80346. }
  80347. }
  80348. declare module BABYLON.GUI {
  80349. /**
  80350. * Class used as a root to all buttons
  80351. */
  80352. export class AbstractButton3D extends Control3D {
  80353. /**
  80354. * Creates a new button
  80355. * @param name defines the control name
  80356. */
  80357. constructor(name?: string);
  80358. protected _getTypeName(): string;
  80359. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80360. }
  80361. }
  80362. declare module BABYLON.GUI {
  80363. /**
  80364. * Class used to create a button in 3D
  80365. */
  80366. export class Button3D extends AbstractButton3D {
  80367. /** @hidden */
  80368. protected _currentMaterial: BABYLON.Material;
  80369. private _facadeTexture;
  80370. private _content;
  80371. private _contentResolution;
  80372. private _contentScaleRatio;
  80373. /**
  80374. * Gets or sets the texture resolution used to render content (512 by default)
  80375. */
  80376. get contentResolution(): BABYLON.int;
  80377. set contentResolution(value: BABYLON.int);
  80378. /**
  80379. * Gets or sets the texture scale ratio used to render content (2 by default)
  80380. */
  80381. get contentScaleRatio(): number;
  80382. set contentScaleRatio(value: number);
  80383. protected _disposeFacadeTexture(): void;
  80384. protected _resetContent(): void;
  80385. /**
  80386. * Creates a new button
  80387. * @param name defines the control name
  80388. */
  80389. constructor(name?: string);
  80390. /**
  80391. * Gets or sets the GUI 2D content used to display the button's facade
  80392. */
  80393. get content(): Control;
  80394. set content(value: Control);
  80395. /**
  80396. * Apply the facade texture (created from the content property).
  80397. * This function can be overloaded by child classes
  80398. * @param facadeTexture defines the AdvancedDynamicTexture to use
  80399. */
  80400. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  80401. protected _getTypeName(): string;
  80402. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80403. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80404. /**
  80405. * Releases all associated resources
  80406. */
  80407. dispose(): void;
  80408. }
  80409. }
  80410. declare module BABYLON.GUI {
  80411. /**
  80412. * Abstract class used to create a container panel deployed on the surface of a volume
  80413. */
  80414. export abstract class VolumeBasedPanel extends Container3D {
  80415. private _columns;
  80416. private _rows;
  80417. private _rowThenColum;
  80418. private _orientation;
  80419. protected _cellWidth: number;
  80420. protected _cellHeight: number;
  80421. /**
  80422. * Gets or sets the distance between elements
  80423. */
  80424. margin: number;
  80425. /**
  80426. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  80427. * | Value | Type | Description |
  80428. * | ----- | ----------------------------------- | ----------- |
  80429. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  80430. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  80431. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  80432. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  80433. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  80434. */
  80435. get orientation(): number;
  80436. set orientation(value: number);
  80437. /**
  80438. * Gets or sets the number of columns requested (10 by default).
  80439. * The panel will automatically compute the number of rows based on number of child controls.
  80440. */
  80441. get columns(): BABYLON.int;
  80442. set columns(value: BABYLON.int);
  80443. /**
  80444. * Gets or sets a the number of rows requested.
  80445. * The panel will automatically compute the number of columns based on number of child controls.
  80446. */
  80447. get rows(): BABYLON.int;
  80448. set rows(value: BABYLON.int);
  80449. /**
  80450. * Creates new VolumeBasedPanel
  80451. */
  80452. constructor();
  80453. protected _arrangeChildren(): void;
  80454. /** Child classes must implement this function to provide correct control positioning */
  80455. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80456. /** Child classes can implement this function to provide additional processing */
  80457. protected _finalProcessing(): void;
  80458. }
  80459. }
  80460. declare module BABYLON.GUI {
  80461. /**
  80462. * Class used to create a container panel deployed on the surface of a cylinder
  80463. */
  80464. export class CylinderPanel extends VolumeBasedPanel {
  80465. private _radius;
  80466. /**
  80467. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  80468. */
  80469. get radius(): BABYLON.float;
  80470. set radius(value: BABYLON.float);
  80471. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80472. private _cylindricalMapping;
  80473. }
  80474. }
  80475. declare module BABYLON.GUI {
  80476. /** @hidden */
  80477. export var fluentVertexShader: {
  80478. name: string;
  80479. shader: string;
  80480. };
  80481. }
  80482. declare module BABYLON.GUI {
  80483. /** @hidden */
  80484. export var fluentPixelShader: {
  80485. name: string;
  80486. shader: string;
  80487. };
  80488. }
  80489. declare module BABYLON.GUI {
  80490. /** @hidden */
  80491. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  80492. INNERGLOW: boolean;
  80493. BORDER: boolean;
  80494. HOVERLIGHT: boolean;
  80495. TEXTURE: boolean;
  80496. constructor();
  80497. }
  80498. /**
  80499. * Class used to render controls with fluent desgin
  80500. */
  80501. export class FluentMaterial extends BABYLON.PushMaterial {
  80502. /**
  80503. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  80504. */
  80505. innerGlowColorIntensity: number;
  80506. /**
  80507. * Gets or sets the inner glow color (white by default)
  80508. */
  80509. innerGlowColor: BABYLON.Color3;
  80510. /**
  80511. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  80512. */
  80513. albedoColor: BABYLON.Color3;
  80514. /**
  80515. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  80516. */
  80517. renderBorders: boolean;
  80518. /**
  80519. * Gets or sets border width (default is 0.5)
  80520. */
  80521. borderWidth: number;
  80522. /**
  80523. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  80524. */
  80525. edgeSmoothingValue: number;
  80526. /**
  80527. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  80528. */
  80529. borderMinValue: number;
  80530. /**
  80531. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  80532. */
  80533. renderHoverLight: boolean;
  80534. /**
  80535. * Gets or sets the radius used to render the hover light (default is 1.0)
  80536. */
  80537. hoverRadius: number;
  80538. /**
  80539. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  80540. */
  80541. hoverColor: BABYLON.Color4;
  80542. /**
  80543. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  80544. */
  80545. hoverPosition: BABYLON.Vector3;
  80546. private _albedoTexture;
  80547. /** Gets or sets the texture to use for albedo color */
  80548. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  80549. /**
  80550. * Creates a new Fluent material
  80551. * @param name defines the name of the material
  80552. * @param scene defines the hosting scene
  80553. */
  80554. constructor(name: string, scene: BABYLON.Scene);
  80555. needAlphaBlending(): boolean;
  80556. needAlphaTesting(): boolean;
  80557. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80558. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80559. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80560. getActiveTextures(): BABYLON.BaseTexture[];
  80561. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80562. dispose(forceDisposeEffect?: boolean): void;
  80563. clone(name: string): FluentMaterial;
  80564. serialize(): any;
  80565. getClassName(): string;
  80566. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  80567. }
  80568. }
  80569. declare module BABYLON.GUI {
  80570. /**
  80571. * Class used to create a holographic button in 3D
  80572. */
  80573. export class HolographicButton extends Button3D {
  80574. private _backPlate;
  80575. private _textPlate;
  80576. private _frontPlate;
  80577. private _text;
  80578. private _imageUrl;
  80579. private _shareMaterials;
  80580. private _frontMaterial;
  80581. private _backMaterial;
  80582. private _plateMaterial;
  80583. private _pickedPointObserver;
  80584. private _tooltipFade;
  80585. private _tooltipTextBlock;
  80586. private _tooltipTexture;
  80587. private _tooltipMesh;
  80588. private _tooltipHoverObserver;
  80589. private _tooltipOutObserver;
  80590. private _disposeTooltip;
  80591. /**
  80592. * Rendering ground id of all the mesh in the button
  80593. */
  80594. set renderingGroupId(id: number);
  80595. get renderingGroupId(): number;
  80596. /**
  80597. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  80598. */
  80599. set tooltipText(text: BABYLON.Nullable<string>);
  80600. get tooltipText(): BABYLON.Nullable<string>;
  80601. /**
  80602. * Gets or sets text for the button
  80603. */
  80604. get text(): string;
  80605. set text(value: string);
  80606. /**
  80607. * Gets or sets the image url for the button
  80608. */
  80609. get imageUrl(): string;
  80610. set imageUrl(value: string);
  80611. /**
  80612. * Gets the back material used by this button
  80613. */
  80614. get backMaterial(): FluentMaterial;
  80615. /**
  80616. * Gets the front material used by this button
  80617. */
  80618. get frontMaterial(): FluentMaterial;
  80619. /**
  80620. * Gets the plate material used by this button
  80621. */
  80622. get plateMaterial(): BABYLON.StandardMaterial;
  80623. /**
  80624. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  80625. */
  80626. get shareMaterials(): boolean;
  80627. /**
  80628. * Creates a new button
  80629. * @param name defines the control name
  80630. */
  80631. constructor(name?: string, shareMaterials?: boolean);
  80632. protected _getTypeName(): string;
  80633. private _rebuildContent;
  80634. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80635. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  80636. private _createBackMaterial;
  80637. private _createFrontMaterial;
  80638. private _createPlateMaterial;
  80639. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  80640. /**
  80641. * Releases all associated resources
  80642. */
  80643. dispose(): void;
  80644. }
  80645. }
  80646. declare module BABYLON.GUI {
  80647. /**
  80648. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  80649. */
  80650. export class MeshButton3D extends Button3D {
  80651. /** @hidden */
  80652. protected _currentMesh: BABYLON.Mesh;
  80653. /**
  80654. * Creates a new 3D button based on a mesh
  80655. * @param mesh mesh to become a 3D button
  80656. * @param name defines the control name
  80657. */
  80658. constructor(mesh: BABYLON.Mesh, name?: string);
  80659. protected _getTypeName(): string;
  80660. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80661. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80662. }
  80663. }
  80664. declare module BABYLON.GUI {
  80665. /**
  80666. * Class used to create a container panel deployed on the surface of a plane
  80667. */
  80668. export class PlanePanel extends VolumeBasedPanel {
  80669. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80670. }
  80671. }
  80672. declare module BABYLON.GUI {
  80673. /**
  80674. * Class used to create a container panel where items get randomized planar mapping
  80675. */
  80676. export class ScatterPanel extends VolumeBasedPanel {
  80677. private _iteration;
  80678. /**
  80679. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  80680. */
  80681. get iteration(): BABYLON.float;
  80682. set iteration(value: BABYLON.float);
  80683. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80684. private _scatterMapping;
  80685. protected _finalProcessing(): void;
  80686. }
  80687. }
  80688. declare module BABYLON.GUI {
  80689. /**
  80690. * Class used to create a container panel deployed on the surface of a sphere
  80691. */
  80692. export class SpherePanel extends VolumeBasedPanel {
  80693. private _radius;
  80694. /**
  80695. * Gets or sets the radius of the sphere where to project controls (5 by default)
  80696. */
  80697. get radius(): BABYLON.float;
  80698. set radius(value: BABYLON.float);
  80699. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80700. private _sphericalMapping;
  80701. }
  80702. }
  80703. declare module BABYLON.GUI {
  80704. /**
  80705. * Class used to create a stack panel in 3D on XY plane
  80706. */
  80707. export class StackPanel3D extends Container3D {
  80708. private _isVertical;
  80709. /**
  80710. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  80711. */
  80712. get isVertical(): boolean;
  80713. set isVertical(value: boolean);
  80714. /**
  80715. * Gets or sets the distance between elements
  80716. */
  80717. margin: number;
  80718. /**
  80719. * Creates new StackPanel
  80720. * @param isVertical
  80721. */
  80722. constructor(isVertical?: boolean);
  80723. protected _arrangeChildren(): void;
  80724. }
  80725. }
  80726. declare module BABYLON {
  80727. /**
  80728. * Configuration for glTF validation
  80729. */
  80730. export interface IGLTFValidationConfiguration {
  80731. /**
  80732. * The url of the glTF validator.
  80733. */
  80734. url: string;
  80735. }
  80736. /**
  80737. * glTF validation
  80738. */
  80739. export class GLTFValidation {
  80740. /**
  80741. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  80742. */
  80743. static Configuration: IGLTFValidationConfiguration;
  80744. private static _LoadScriptPromise;
  80745. /**
  80746. * Validate a glTF asset using the glTF-Validator.
  80747. * @param data The JSON of a glTF or the array buffer of a binary glTF
  80748. * @param rootUrl The root url for the glTF
  80749. * @param fileName The file name for the glTF
  80750. * @param getExternalResource The callback to get external resources for the glTF validator
  80751. * @returns A promise that resolves with the glTF validation results once complete
  80752. */
  80753. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  80754. }
  80755. }
  80756. declare module BABYLON {
  80757. /**
  80758. * Mode that determines the coordinate system to use.
  80759. */
  80760. export enum GLTFLoaderCoordinateSystemMode {
  80761. /**
  80762. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  80763. */
  80764. AUTO = 0,
  80765. /**
  80766. * Sets the useRightHandedSystem flag on the scene.
  80767. */
  80768. FORCE_RIGHT_HANDED = 1
  80769. }
  80770. /**
  80771. * Mode that determines what animations will start.
  80772. */
  80773. export enum GLTFLoaderAnimationStartMode {
  80774. /**
  80775. * No animation will start.
  80776. */
  80777. NONE = 0,
  80778. /**
  80779. * The first animation will start.
  80780. */
  80781. FIRST = 1,
  80782. /**
  80783. * All animations will start.
  80784. */
  80785. ALL = 2
  80786. }
  80787. /**
  80788. * Interface that contains the data for the glTF asset.
  80789. */
  80790. export interface IGLTFLoaderData {
  80791. /**
  80792. * The object that represents the glTF JSON.
  80793. */
  80794. json: Object;
  80795. /**
  80796. * The BIN chunk of a binary glTF.
  80797. */
  80798. bin: Nullable<IDataBuffer>;
  80799. }
  80800. /**
  80801. * Interface for extending the loader.
  80802. */
  80803. export interface IGLTFLoaderExtension {
  80804. /**
  80805. * The name of this extension.
  80806. */
  80807. readonly name: string;
  80808. /**
  80809. * Defines whether this extension is enabled.
  80810. */
  80811. enabled: boolean;
  80812. /**
  80813. * Defines the order of this extension.
  80814. * The loader sorts the extensions using these values when loading.
  80815. */
  80816. order?: number;
  80817. }
  80818. /**
  80819. * Loader state.
  80820. */
  80821. export enum GLTFLoaderState {
  80822. /**
  80823. * The asset is loading.
  80824. */
  80825. LOADING = 0,
  80826. /**
  80827. * The asset is ready for rendering.
  80828. */
  80829. READY = 1,
  80830. /**
  80831. * The asset is completely loaded.
  80832. */
  80833. COMPLETE = 2
  80834. }
  80835. /** @hidden */
  80836. export interface IImportMeshAsyncOutput {
  80837. meshes: AbstractMesh[];
  80838. particleSystems: IParticleSystem[];
  80839. skeletons: Skeleton[];
  80840. animationGroups: AnimationGroup[];
  80841. lights: Light[];
  80842. transformNodes: TransformNode[];
  80843. }
  80844. /** @hidden */
  80845. export interface IGLTFLoader extends IDisposable {
  80846. readonly state: Nullable<GLTFLoaderState>;
  80847. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  80848. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  80849. }
  80850. /**
  80851. * File loader for loading glTF files into a scene.
  80852. */
  80853. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  80854. /** @hidden */
  80855. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  80856. /** @hidden */
  80857. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  80858. /**
  80859. * Raised when the asset has been parsed
  80860. */
  80861. onParsedObservable: Observable<IGLTFLoaderData>;
  80862. private _onParsedObserver;
  80863. /**
  80864. * Raised when the asset has been parsed
  80865. */
  80866. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  80867. /**
  80868. * 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.
  80869. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  80870. * Defaults to true.
  80871. * @hidden
  80872. */
  80873. static IncrementalLoading: boolean;
  80874. /**
  80875. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  80876. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  80877. * @hidden
  80878. */
  80879. static HomogeneousCoordinates: boolean;
  80880. /**
  80881. * The coordinate system mode. Defaults to AUTO.
  80882. */
  80883. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  80884. /**
  80885. * The animation start mode. Defaults to FIRST.
  80886. */
  80887. animationStartMode: GLTFLoaderAnimationStartMode;
  80888. /**
  80889. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  80890. */
  80891. compileMaterials: boolean;
  80892. /**
  80893. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  80894. */
  80895. useClipPlane: boolean;
  80896. /**
  80897. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  80898. */
  80899. compileShadowGenerators: boolean;
  80900. /**
  80901. * Defines if the Alpha blended materials are only applied as coverage.
  80902. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  80903. * If true, no extra effects are applied to transparent pixels.
  80904. */
  80905. transparencyAsCoverage: boolean;
  80906. /**
  80907. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  80908. * Enabling will disable offline support and glTF validator.
  80909. * Defaults to false.
  80910. */
  80911. useRangeRequests: boolean;
  80912. /**
  80913. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  80914. */
  80915. createInstances: boolean;
  80916. /**
  80917. * 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.
  80918. */
  80919. alwaysComputeBoundingBox: boolean;
  80920. /**
  80921. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  80922. */
  80923. loadAllMaterials: boolean;
  80924. /**
  80925. * Function called before loading a url referenced by the asset.
  80926. */
  80927. preprocessUrlAsync: (url: string) => Promise<string>;
  80928. /**
  80929. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  80930. * 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, ...)
  80931. */
  80932. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  80933. private _onMeshLoadedObserver;
  80934. /**
  80935. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  80936. * 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, ...)
  80937. */
  80938. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  80939. /**
  80940. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  80941. */
  80942. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  80943. private _onTextureLoadedObserver;
  80944. /**
  80945. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  80946. */
  80947. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  80948. /**
  80949. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  80950. */
  80951. readonly onMaterialLoadedObservable: Observable<Material>;
  80952. private _onMaterialLoadedObserver;
  80953. /**
  80954. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  80955. */
  80956. set onMaterialLoaded(callback: (material: Material) => void);
  80957. /**
  80958. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  80959. */
  80960. readonly onCameraLoadedObservable: Observable<Camera>;
  80961. private _onCameraLoadedObserver;
  80962. /**
  80963. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  80964. */
  80965. set onCameraLoaded(callback: (camera: Camera) => void);
  80966. /**
  80967. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  80968. * For assets with LODs, raised when all of the LODs are complete.
  80969. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  80970. */
  80971. readonly onCompleteObservable: Observable<void>;
  80972. private _onCompleteObserver;
  80973. /**
  80974. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  80975. * For assets with LODs, raised when all of the LODs are complete.
  80976. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  80977. */
  80978. set onComplete(callback: () => void);
  80979. /**
  80980. * Observable raised when an error occurs.
  80981. */
  80982. readonly onErrorObservable: Observable<any>;
  80983. private _onErrorObserver;
  80984. /**
  80985. * Callback raised when an error occurs.
  80986. */
  80987. set onError(callback: (reason: any) => void);
  80988. /**
  80989. * Observable raised after the loader is disposed.
  80990. */
  80991. readonly onDisposeObservable: Observable<void>;
  80992. private _onDisposeObserver;
  80993. /**
  80994. * Callback raised after the loader is disposed.
  80995. */
  80996. set onDispose(callback: () => void);
  80997. /**
  80998. * Observable raised after a loader extension is created.
  80999. * Set additional options for a loader extension in this event.
  81000. */
  81001. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  81002. private _onExtensionLoadedObserver;
  81003. /**
  81004. * Callback raised after a loader extension is created.
  81005. */
  81006. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  81007. /**
  81008. * Defines if the loader logging is enabled.
  81009. */
  81010. get loggingEnabled(): boolean;
  81011. set loggingEnabled(value: boolean);
  81012. /**
  81013. * Defines if the loader should capture performance counters.
  81014. */
  81015. get capturePerformanceCounters(): boolean;
  81016. set capturePerformanceCounters(value: boolean);
  81017. /**
  81018. * Defines if the loader should validate the asset.
  81019. */
  81020. validate: boolean;
  81021. /**
  81022. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  81023. */
  81024. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  81025. private _onValidatedObserver;
  81026. /**
  81027. * Callback raised after a loader extension is created.
  81028. */
  81029. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  81030. private _loader;
  81031. private _progressCallback?;
  81032. private _requests;
  81033. private static magicBase64Encoded;
  81034. /**
  81035. * Name of the loader ("gltf")
  81036. */
  81037. name: string;
  81038. /** @hidden */
  81039. extensions: ISceneLoaderPluginExtensions;
  81040. /**
  81041. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  81042. */
  81043. dispose(): void;
  81044. /** @hidden */
  81045. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81046. /** @hidden */
  81047. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81048. /** @hidden */
  81049. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81050. meshes: AbstractMesh[];
  81051. particleSystems: IParticleSystem[];
  81052. skeletons: Skeleton[];
  81053. animationGroups: AnimationGroup[];
  81054. }>;
  81055. /** @hidden */
  81056. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81057. /** @hidden */
  81058. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81059. /** @hidden */
  81060. canDirectLoad(data: string): boolean;
  81061. /** @hidden */
  81062. directLoad(scene: Scene, data: string): Promise<any>;
  81063. /**
  81064. * The callback that allows custom handling of the root url based on the response url.
  81065. * @param rootUrl the original root url
  81066. * @param responseURL the response url if available
  81067. * @returns the new root url
  81068. */
  81069. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  81070. /** @hidden */
  81071. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  81072. /**
  81073. * The loader state or null if the loader is not active.
  81074. */
  81075. get loaderState(): Nullable<GLTFLoaderState>;
  81076. /**
  81077. * Returns a promise that resolves when the asset is completely loaded.
  81078. * @returns a promise that resolves when the asset is completely loaded.
  81079. */
  81080. whenCompleteAsync(): Promise<void>;
  81081. /** @hidden */
  81082. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  81083. /** @hidden */
  81084. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  81085. private _onProgress;
  81086. private _validate;
  81087. private _getLoader;
  81088. private _parseJson;
  81089. private _unpackBinaryAsync;
  81090. private _unpackBinaryV1Async;
  81091. private _unpackBinaryV2Async;
  81092. private static _parseVersion;
  81093. private static _compareVersion;
  81094. private static readonly _logSpaces;
  81095. private _logIndentLevel;
  81096. private _loggingEnabled;
  81097. /** @hidden */
  81098. _log: (message: string) => void;
  81099. /** @hidden */
  81100. _logOpen(message: string): void;
  81101. /** @hidden */
  81102. _logClose(): void;
  81103. private _logEnabled;
  81104. private _logDisabled;
  81105. private _capturePerformanceCounters;
  81106. /** @hidden */
  81107. _startPerformanceCounter: (counterName: string) => void;
  81108. /** @hidden */
  81109. _endPerformanceCounter: (counterName: string) => void;
  81110. private _startPerformanceCounterEnabled;
  81111. private _startPerformanceCounterDisabled;
  81112. private _endPerformanceCounterEnabled;
  81113. private _endPerformanceCounterDisabled;
  81114. }
  81115. }
  81116. declare module BABYLON.GLTF1 {
  81117. /**
  81118. * Enums
  81119. * @hidden
  81120. */
  81121. export enum EComponentType {
  81122. BYTE = 5120,
  81123. UNSIGNED_BYTE = 5121,
  81124. SHORT = 5122,
  81125. UNSIGNED_SHORT = 5123,
  81126. FLOAT = 5126
  81127. }
  81128. /** @hidden */
  81129. export enum EShaderType {
  81130. FRAGMENT = 35632,
  81131. VERTEX = 35633
  81132. }
  81133. /** @hidden */
  81134. export enum EParameterType {
  81135. BYTE = 5120,
  81136. UNSIGNED_BYTE = 5121,
  81137. SHORT = 5122,
  81138. UNSIGNED_SHORT = 5123,
  81139. INT = 5124,
  81140. UNSIGNED_INT = 5125,
  81141. FLOAT = 5126,
  81142. FLOAT_VEC2 = 35664,
  81143. FLOAT_VEC3 = 35665,
  81144. FLOAT_VEC4 = 35666,
  81145. INT_VEC2 = 35667,
  81146. INT_VEC3 = 35668,
  81147. INT_VEC4 = 35669,
  81148. BOOL = 35670,
  81149. BOOL_VEC2 = 35671,
  81150. BOOL_VEC3 = 35672,
  81151. BOOL_VEC4 = 35673,
  81152. FLOAT_MAT2 = 35674,
  81153. FLOAT_MAT3 = 35675,
  81154. FLOAT_MAT4 = 35676,
  81155. SAMPLER_2D = 35678
  81156. }
  81157. /** @hidden */
  81158. export enum ETextureWrapMode {
  81159. CLAMP_TO_EDGE = 33071,
  81160. MIRRORED_REPEAT = 33648,
  81161. REPEAT = 10497
  81162. }
  81163. /** @hidden */
  81164. export enum ETextureFilterType {
  81165. NEAREST = 9728,
  81166. LINEAR = 9728,
  81167. NEAREST_MIPMAP_NEAREST = 9984,
  81168. LINEAR_MIPMAP_NEAREST = 9985,
  81169. NEAREST_MIPMAP_LINEAR = 9986,
  81170. LINEAR_MIPMAP_LINEAR = 9987
  81171. }
  81172. /** @hidden */
  81173. export enum ETextureFormat {
  81174. ALPHA = 6406,
  81175. RGB = 6407,
  81176. RGBA = 6408,
  81177. LUMINANCE = 6409,
  81178. LUMINANCE_ALPHA = 6410
  81179. }
  81180. /** @hidden */
  81181. export enum ECullingType {
  81182. FRONT = 1028,
  81183. BACK = 1029,
  81184. FRONT_AND_BACK = 1032
  81185. }
  81186. /** @hidden */
  81187. export enum EBlendingFunction {
  81188. ZERO = 0,
  81189. ONE = 1,
  81190. SRC_COLOR = 768,
  81191. ONE_MINUS_SRC_COLOR = 769,
  81192. DST_COLOR = 774,
  81193. ONE_MINUS_DST_COLOR = 775,
  81194. SRC_ALPHA = 770,
  81195. ONE_MINUS_SRC_ALPHA = 771,
  81196. DST_ALPHA = 772,
  81197. ONE_MINUS_DST_ALPHA = 773,
  81198. CONSTANT_COLOR = 32769,
  81199. ONE_MINUS_CONSTANT_COLOR = 32770,
  81200. CONSTANT_ALPHA = 32771,
  81201. ONE_MINUS_CONSTANT_ALPHA = 32772,
  81202. SRC_ALPHA_SATURATE = 776
  81203. }
  81204. /** @hidden */
  81205. export interface IGLTFProperty {
  81206. extensions?: {
  81207. [key: string]: any;
  81208. };
  81209. extras?: Object;
  81210. }
  81211. /** @hidden */
  81212. export interface IGLTFChildRootProperty extends IGLTFProperty {
  81213. name?: string;
  81214. }
  81215. /** @hidden */
  81216. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  81217. bufferView: string;
  81218. byteOffset: number;
  81219. byteStride: number;
  81220. count: number;
  81221. type: string;
  81222. componentType: EComponentType;
  81223. max?: number[];
  81224. min?: number[];
  81225. name?: string;
  81226. }
  81227. /** @hidden */
  81228. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  81229. buffer: string;
  81230. byteOffset: number;
  81231. byteLength: number;
  81232. byteStride: number;
  81233. target?: number;
  81234. }
  81235. /** @hidden */
  81236. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  81237. uri: string;
  81238. byteLength?: number;
  81239. type?: string;
  81240. }
  81241. /** @hidden */
  81242. export interface IGLTFShader extends IGLTFChildRootProperty {
  81243. uri: string;
  81244. type: EShaderType;
  81245. }
  81246. /** @hidden */
  81247. export interface IGLTFProgram extends IGLTFChildRootProperty {
  81248. attributes: string[];
  81249. fragmentShader: string;
  81250. vertexShader: string;
  81251. }
  81252. /** @hidden */
  81253. export interface IGLTFTechniqueParameter {
  81254. type: number;
  81255. count?: number;
  81256. semantic?: string;
  81257. node?: string;
  81258. value?: number | boolean | string | Array<any>;
  81259. source?: string;
  81260. babylonValue?: any;
  81261. }
  81262. /** @hidden */
  81263. export interface IGLTFTechniqueCommonProfile {
  81264. lightingModel: string;
  81265. texcoordBindings: Object;
  81266. parameters?: Array<any>;
  81267. }
  81268. /** @hidden */
  81269. export interface IGLTFTechniqueStatesFunctions {
  81270. blendColor?: number[];
  81271. blendEquationSeparate?: number[];
  81272. blendFuncSeparate?: number[];
  81273. colorMask: boolean[];
  81274. cullFace: number[];
  81275. }
  81276. /** @hidden */
  81277. export interface IGLTFTechniqueStates {
  81278. enable: number[];
  81279. functions: IGLTFTechniqueStatesFunctions;
  81280. }
  81281. /** @hidden */
  81282. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  81283. parameters: {
  81284. [key: string]: IGLTFTechniqueParameter;
  81285. };
  81286. program: string;
  81287. attributes: {
  81288. [key: string]: string;
  81289. };
  81290. uniforms: {
  81291. [key: string]: string;
  81292. };
  81293. states: IGLTFTechniqueStates;
  81294. }
  81295. /** @hidden */
  81296. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  81297. technique?: string;
  81298. values: string[];
  81299. }
  81300. /** @hidden */
  81301. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  81302. attributes: {
  81303. [key: string]: string;
  81304. };
  81305. indices: string;
  81306. material: string;
  81307. mode?: number;
  81308. }
  81309. /** @hidden */
  81310. export interface IGLTFMesh extends IGLTFChildRootProperty {
  81311. primitives: IGLTFMeshPrimitive[];
  81312. }
  81313. /** @hidden */
  81314. export interface IGLTFImage extends IGLTFChildRootProperty {
  81315. uri: string;
  81316. }
  81317. /** @hidden */
  81318. export interface IGLTFSampler extends IGLTFChildRootProperty {
  81319. magFilter?: number;
  81320. minFilter?: number;
  81321. wrapS?: number;
  81322. wrapT?: number;
  81323. }
  81324. /** @hidden */
  81325. export interface IGLTFTexture extends IGLTFChildRootProperty {
  81326. sampler: string;
  81327. source: string;
  81328. format?: ETextureFormat;
  81329. internalFormat?: ETextureFormat;
  81330. target?: number;
  81331. type?: number;
  81332. babylonTexture?: Texture;
  81333. }
  81334. /** @hidden */
  81335. export interface IGLTFAmbienLight {
  81336. color?: number[];
  81337. }
  81338. /** @hidden */
  81339. export interface IGLTFDirectionalLight {
  81340. color?: number[];
  81341. }
  81342. /** @hidden */
  81343. export interface IGLTFPointLight {
  81344. color?: number[];
  81345. constantAttenuation?: number;
  81346. linearAttenuation?: number;
  81347. quadraticAttenuation?: number;
  81348. }
  81349. /** @hidden */
  81350. export interface IGLTFSpotLight {
  81351. color?: number[];
  81352. constantAttenuation?: number;
  81353. fallOfAngle?: number;
  81354. fallOffExponent?: number;
  81355. linearAttenuation?: number;
  81356. quadraticAttenuation?: number;
  81357. }
  81358. /** @hidden */
  81359. export interface IGLTFLight extends IGLTFChildRootProperty {
  81360. type: string;
  81361. }
  81362. /** @hidden */
  81363. export interface IGLTFCameraOrthographic {
  81364. xmag: number;
  81365. ymag: number;
  81366. zfar: number;
  81367. znear: number;
  81368. }
  81369. /** @hidden */
  81370. export interface IGLTFCameraPerspective {
  81371. aspectRatio: number;
  81372. yfov: number;
  81373. zfar: number;
  81374. znear: number;
  81375. }
  81376. /** @hidden */
  81377. export interface IGLTFCamera extends IGLTFChildRootProperty {
  81378. type: string;
  81379. }
  81380. /** @hidden */
  81381. export interface IGLTFAnimationChannelTarget {
  81382. id: string;
  81383. path: string;
  81384. }
  81385. /** @hidden */
  81386. export interface IGLTFAnimationChannel {
  81387. sampler: string;
  81388. target: IGLTFAnimationChannelTarget;
  81389. }
  81390. /** @hidden */
  81391. export interface IGLTFAnimationSampler {
  81392. input: string;
  81393. output: string;
  81394. interpolation?: string;
  81395. }
  81396. /** @hidden */
  81397. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  81398. channels?: IGLTFAnimationChannel[];
  81399. parameters?: {
  81400. [key: string]: string;
  81401. };
  81402. samplers?: {
  81403. [key: string]: IGLTFAnimationSampler;
  81404. };
  81405. }
  81406. /** @hidden */
  81407. export interface IGLTFNodeInstanceSkin {
  81408. skeletons: string[];
  81409. skin: string;
  81410. meshes: string[];
  81411. }
  81412. /** @hidden */
  81413. export interface IGLTFSkins extends IGLTFChildRootProperty {
  81414. bindShapeMatrix: number[];
  81415. inverseBindMatrices: string;
  81416. jointNames: string[];
  81417. babylonSkeleton?: Skeleton;
  81418. }
  81419. /** @hidden */
  81420. export interface IGLTFNode extends IGLTFChildRootProperty {
  81421. camera?: string;
  81422. children: string[];
  81423. skin?: string;
  81424. jointName?: string;
  81425. light?: string;
  81426. matrix: number[];
  81427. mesh?: string;
  81428. meshes?: string[];
  81429. rotation?: number[];
  81430. scale?: number[];
  81431. translation?: number[];
  81432. babylonNode?: Node;
  81433. }
  81434. /** @hidden */
  81435. export interface IGLTFScene extends IGLTFChildRootProperty {
  81436. nodes: string[];
  81437. }
  81438. /** @hidden */
  81439. export interface IGLTFRuntime {
  81440. extensions: {
  81441. [key: string]: any;
  81442. };
  81443. accessors: {
  81444. [key: string]: IGLTFAccessor;
  81445. };
  81446. buffers: {
  81447. [key: string]: IGLTFBuffer;
  81448. };
  81449. bufferViews: {
  81450. [key: string]: IGLTFBufferView;
  81451. };
  81452. meshes: {
  81453. [key: string]: IGLTFMesh;
  81454. };
  81455. lights: {
  81456. [key: string]: IGLTFLight;
  81457. };
  81458. cameras: {
  81459. [key: string]: IGLTFCamera;
  81460. };
  81461. nodes: {
  81462. [key: string]: IGLTFNode;
  81463. };
  81464. images: {
  81465. [key: string]: IGLTFImage;
  81466. };
  81467. textures: {
  81468. [key: string]: IGLTFTexture;
  81469. };
  81470. shaders: {
  81471. [key: string]: IGLTFShader;
  81472. };
  81473. programs: {
  81474. [key: string]: IGLTFProgram;
  81475. };
  81476. samplers: {
  81477. [key: string]: IGLTFSampler;
  81478. };
  81479. techniques: {
  81480. [key: string]: IGLTFTechnique;
  81481. };
  81482. materials: {
  81483. [key: string]: IGLTFMaterial;
  81484. };
  81485. animations: {
  81486. [key: string]: IGLTFAnimation;
  81487. };
  81488. skins: {
  81489. [key: string]: IGLTFSkins;
  81490. };
  81491. currentScene?: Object;
  81492. scenes: {
  81493. [key: string]: IGLTFScene;
  81494. };
  81495. extensionsUsed: string[];
  81496. extensionsRequired?: string[];
  81497. buffersCount: number;
  81498. shaderscount: number;
  81499. scene: Scene;
  81500. rootUrl: string;
  81501. loadedBufferCount: number;
  81502. loadedBufferViews: {
  81503. [name: string]: ArrayBufferView;
  81504. };
  81505. loadedShaderCount: number;
  81506. importOnlyMeshes: boolean;
  81507. importMeshesNames?: string[];
  81508. dummyNodes: Node[];
  81509. forAssetContainer: boolean;
  81510. }
  81511. /** @hidden */
  81512. export interface INodeToRoot {
  81513. bone: Bone;
  81514. node: IGLTFNode;
  81515. id: string;
  81516. }
  81517. /** @hidden */
  81518. export interface IJointNode {
  81519. node: IGLTFNode;
  81520. id: string;
  81521. }
  81522. }
  81523. declare module BABYLON.GLTF1 {
  81524. /**
  81525. * Utils functions for GLTF
  81526. * @hidden
  81527. */
  81528. export class GLTFUtils {
  81529. /**
  81530. * Sets the given "parameter" matrix
  81531. * @param scene: the Scene object
  81532. * @param source: the source node where to pick the matrix
  81533. * @param parameter: the GLTF technique parameter
  81534. * @param uniformName: the name of the shader's uniform
  81535. * @param shaderMaterial: the shader material
  81536. */
  81537. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  81538. /**
  81539. * Sets the given "parameter" matrix
  81540. * @param shaderMaterial: the shader material
  81541. * @param uniform: the name of the shader's uniform
  81542. * @param value: the value of the uniform
  81543. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  81544. */
  81545. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  81546. /**
  81547. * Returns the wrap mode of the texture
  81548. * @param mode: the mode value
  81549. */
  81550. static GetWrapMode(mode: number): number;
  81551. /**
  81552. * Returns the byte stride giving an accessor
  81553. * @param accessor: the GLTF accessor objet
  81554. */
  81555. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  81556. /**
  81557. * Returns the texture filter mode giving a mode value
  81558. * @param mode: the filter mode value
  81559. */
  81560. static GetTextureFilterMode(mode: number): ETextureFilterType;
  81561. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  81562. /**
  81563. * Returns a buffer from its accessor
  81564. * @param gltfRuntime: the GLTF runtime
  81565. * @param accessor: the GLTF accessor
  81566. */
  81567. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  81568. /**
  81569. * Decodes a buffer view into a string
  81570. * @param view: the buffer view
  81571. */
  81572. static DecodeBufferToText(view: ArrayBufferView): string;
  81573. /**
  81574. * Returns the default material of gltf. Related to
  81575. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  81576. * @param scene: the Babylon.js scene
  81577. */
  81578. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  81579. private static _DefaultMaterial;
  81580. }
  81581. }
  81582. declare module BABYLON.GLTF1 {
  81583. /**
  81584. * Implementation of the base glTF spec
  81585. * @hidden
  81586. */
  81587. export class GLTFLoaderBase {
  81588. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  81589. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  81590. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  81591. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  81592. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  81593. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  81594. }
  81595. /**
  81596. * glTF V1 Loader
  81597. * @hidden
  81598. */
  81599. export class GLTFLoader implements IGLTFLoader {
  81600. static Extensions: {
  81601. [name: string]: GLTFLoaderExtension;
  81602. };
  81603. static RegisterExtension(extension: GLTFLoaderExtension): void;
  81604. state: Nullable<GLTFLoaderState>;
  81605. dispose(): void;
  81606. private _importMeshAsync;
  81607. /**
  81608. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  81609. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  81610. * @param scene the scene the meshes should be added to
  81611. * @param forAssetContainer defines if the entities must be stored in the scene
  81612. * @param data gltf data containing information of the meshes in a loaded file
  81613. * @param rootUrl root url to load from
  81614. * @param onProgress event that fires when loading progress has occured
  81615. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  81616. */
  81617. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  81618. private _loadAsync;
  81619. /**
  81620. * Imports all objects from a loaded gltf file and adds them to the scene
  81621. * @param scene the scene the objects should be added to
  81622. * @param data gltf data containing information of the meshes in a loaded file
  81623. * @param rootUrl root url to load from
  81624. * @param onProgress event that fires when loading progress has occured
  81625. * @returns a promise which completes when objects have been loaded to the scene
  81626. */
  81627. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  81628. private _loadShadersAsync;
  81629. private _loadBuffersAsync;
  81630. private _createNodes;
  81631. }
  81632. /** @hidden */
  81633. export abstract class GLTFLoaderExtension {
  81634. private _name;
  81635. constructor(name: string);
  81636. get name(): string;
  81637. /**
  81638. * Defines an override for loading the runtime
  81639. * Return true to stop further extensions from loading the runtime
  81640. */
  81641. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  81642. /**
  81643. * Defines an onverride for creating gltf runtime
  81644. * Return true to stop further extensions from creating the runtime
  81645. */
  81646. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  81647. /**
  81648. * Defines an override for loading buffers
  81649. * Return true to stop further extensions from loading this buffer
  81650. */
  81651. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  81652. /**
  81653. * Defines an override for loading texture buffers
  81654. * Return true to stop further extensions from loading this texture data
  81655. */
  81656. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81657. /**
  81658. * Defines an override for creating textures
  81659. * Return true to stop further extensions from loading this texture
  81660. */
  81661. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  81662. /**
  81663. * Defines an override for loading shader strings
  81664. * Return true to stop further extensions from loading this shader data
  81665. */
  81666. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81667. /**
  81668. * Defines an override for loading materials
  81669. * Return true to stop further extensions from loading this material
  81670. */
  81671. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  81672. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  81673. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  81674. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  81675. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  81676. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  81677. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  81678. private static LoadTextureBufferAsync;
  81679. private static CreateTextureAsync;
  81680. private static ApplyExtensions;
  81681. }
  81682. }
  81683. declare module BABYLON.GLTF1 {
  81684. /** @hidden */
  81685. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  81686. private _bin;
  81687. constructor();
  81688. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  81689. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81690. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81691. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81692. }
  81693. }
  81694. declare module BABYLON.GLTF1 {
  81695. /** @hidden */
  81696. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  81697. constructor();
  81698. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  81699. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  81700. private _loadTexture;
  81701. }
  81702. }
  81703. declare module BABYLON.GLTF2.Loader {
  81704. /**
  81705. * Loader interface with an index field.
  81706. */
  81707. export interface IArrayItem {
  81708. /**
  81709. * The index of this item in the array.
  81710. */
  81711. index: number;
  81712. }
  81713. /**
  81714. * Loader interface with additional members.
  81715. */
  81716. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  81717. /** @hidden */
  81718. _data?: Promise<ArrayBufferView>;
  81719. /** @hidden */
  81720. _babylonVertexBuffer?: Promise<VertexBuffer>;
  81721. }
  81722. /**
  81723. * Loader interface with additional members.
  81724. */
  81725. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  81726. }
  81727. /** @hidden */
  81728. export interface _IAnimationSamplerData {
  81729. input: Float32Array;
  81730. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  81731. output: Float32Array;
  81732. }
  81733. /**
  81734. * Loader interface with additional members.
  81735. */
  81736. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  81737. /** @hidden */
  81738. _data?: Promise<_IAnimationSamplerData>;
  81739. }
  81740. /**
  81741. * Loader interface with additional members.
  81742. */
  81743. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  81744. channels: IAnimationChannel[];
  81745. samplers: IAnimationSampler[];
  81746. /** @hidden */
  81747. _babylonAnimationGroup?: AnimationGroup;
  81748. }
  81749. /**
  81750. * Loader interface with additional members.
  81751. */
  81752. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  81753. /** @hidden */
  81754. _data?: Promise<ArrayBufferView>;
  81755. }
  81756. /**
  81757. * Loader interface with additional members.
  81758. */
  81759. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  81760. /** @hidden */
  81761. _data?: Promise<ArrayBufferView>;
  81762. /** @hidden */
  81763. _babylonBuffer?: Promise<Buffer>;
  81764. }
  81765. /**
  81766. * Loader interface with additional members.
  81767. */
  81768. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  81769. }
  81770. /**
  81771. * Loader interface with additional members.
  81772. */
  81773. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  81774. /** @hidden */
  81775. _data?: Promise<ArrayBufferView>;
  81776. }
  81777. /**
  81778. * Loader interface with additional members.
  81779. */
  81780. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  81781. }
  81782. /**
  81783. * Loader interface with additional members.
  81784. */
  81785. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  81786. }
  81787. /**
  81788. * Loader interface with additional members.
  81789. */
  81790. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  81791. baseColorTexture?: ITextureInfo;
  81792. metallicRoughnessTexture?: ITextureInfo;
  81793. }
  81794. /**
  81795. * Loader interface with additional members.
  81796. */
  81797. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  81798. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  81799. normalTexture?: IMaterialNormalTextureInfo;
  81800. occlusionTexture?: IMaterialOcclusionTextureInfo;
  81801. emissiveTexture?: ITextureInfo;
  81802. /** @hidden */
  81803. _data?: {
  81804. [babylonDrawMode: number]: {
  81805. babylonMaterial: Material;
  81806. babylonMeshes: AbstractMesh[];
  81807. promise: Promise<void>;
  81808. };
  81809. };
  81810. }
  81811. /**
  81812. * Loader interface with additional members.
  81813. */
  81814. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  81815. primitives: IMeshPrimitive[];
  81816. }
  81817. /**
  81818. * Loader interface with additional members.
  81819. */
  81820. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  81821. /** @hidden */
  81822. _instanceData?: {
  81823. babylonSourceMesh: Mesh;
  81824. promise: Promise<any>;
  81825. };
  81826. }
  81827. /**
  81828. * Loader interface with additional members.
  81829. */
  81830. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  81831. /**
  81832. * The parent glTF node.
  81833. */
  81834. parent?: INode;
  81835. /** @hidden */
  81836. _babylonTransformNode?: TransformNode;
  81837. /** @hidden */
  81838. _primitiveBabylonMeshes?: AbstractMesh[];
  81839. /** @hidden */
  81840. _babylonBones?: Bone[];
  81841. /** @hidden */
  81842. _numMorphTargets?: number;
  81843. }
  81844. /** @hidden */
  81845. export interface _ISamplerData {
  81846. noMipMaps: boolean;
  81847. samplingMode: number;
  81848. wrapU: number;
  81849. wrapV: number;
  81850. }
  81851. /**
  81852. * Loader interface with additional members.
  81853. */
  81854. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  81855. /** @hidden */
  81856. _data?: _ISamplerData;
  81857. }
  81858. /**
  81859. * Loader interface with additional members.
  81860. */
  81861. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  81862. }
  81863. /**
  81864. * Loader interface with additional members.
  81865. */
  81866. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  81867. /** @hidden */
  81868. _data?: {
  81869. babylonSkeleton: Skeleton;
  81870. promise: Promise<void>;
  81871. };
  81872. }
  81873. /**
  81874. * Loader interface with additional members.
  81875. */
  81876. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  81877. }
  81878. /**
  81879. * Loader interface with additional members.
  81880. */
  81881. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  81882. }
  81883. /**
  81884. * Loader interface with additional members.
  81885. */
  81886. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  81887. accessors?: IAccessor[];
  81888. animations?: IAnimation[];
  81889. buffers?: IBuffer[];
  81890. bufferViews?: IBufferView[];
  81891. cameras?: ICamera[];
  81892. images?: IImage[];
  81893. materials?: IMaterial[];
  81894. meshes?: IMesh[];
  81895. nodes?: INode[];
  81896. samplers?: ISampler[];
  81897. scenes?: IScene[];
  81898. skins?: ISkin[];
  81899. textures?: ITexture[];
  81900. }
  81901. }
  81902. declare module BABYLON.GLTF2 {
  81903. /**
  81904. * Interface for a glTF loader extension.
  81905. */
  81906. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  81907. /**
  81908. * Called after the loader state changes to LOADING.
  81909. */
  81910. onLoading?(): void;
  81911. /**
  81912. * Called after the loader state changes to READY.
  81913. */
  81914. onReady?(): void;
  81915. /**
  81916. * Define this method to modify the default behavior when loading scenes.
  81917. * @param context The context when loading the asset
  81918. * @param scene The glTF scene property
  81919. * @returns A promise that resolves when the load is complete or null if not handled
  81920. */
  81921. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  81922. /**
  81923. * Define this method to modify the default behavior when loading nodes.
  81924. * @param context The context when loading the asset
  81925. * @param node The glTF node property
  81926. * @param assign A function called synchronously after parsing the glTF properties
  81927. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  81928. */
  81929. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81930. /**
  81931. * Define this method to modify the default behavior when loading cameras.
  81932. * @param context The context when loading the asset
  81933. * @param camera The glTF camera property
  81934. * @param assign A function called synchronously after parsing the glTF properties
  81935. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  81936. */
  81937. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  81938. /**
  81939. * @hidden
  81940. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  81941. * @param context The context when loading the asset
  81942. * @param primitive The glTF mesh primitive property
  81943. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  81944. */
  81945. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  81946. /**
  81947. * @hidden
  81948. * Define this method to modify the default behavior when loading data for mesh primitives.
  81949. * @param context The context when loading the asset
  81950. * @param name The mesh name when loading the asset
  81951. * @param node The glTF node when loading the asset
  81952. * @param mesh The glTF mesh when loading the asset
  81953. * @param primitive The glTF mesh primitive property
  81954. * @param assign A function called synchronously after parsing the glTF properties
  81955. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  81956. */
  81957. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  81958. /**
  81959. * @hidden
  81960. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  81961. * @param context The context when loading the asset
  81962. * @param material The glTF material property
  81963. * @param assign A function called synchronously after parsing the glTF properties
  81964. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  81965. */
  81966. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  81967. /**
  81968. * Define this method to modify the default behavior when creating materials.
  81969. * @param context The context when loading the asset
  81970. * @param material The glTF material property
  81971. * @param babylonDrawMode The draw mode for the Babylon material
  81972. * @returns The Babylon material or null if not handled
  81973. */
  81974. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  81975. /**
  81976. * Define this method to modify the default behavior when loading material properties.
  81977. * @param context The context when loading the asset
  81978. * @param material The glTF material property
  81979. * @param babylonMaterial The Babylon material
  81980. * @returns A promise that resolves when the load is complete or null if not handled
  81981. */
  81982. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81983. /**
  81984. * Define this method to modify the default behavior when loading texture infos.
  81985. * @param context The context when loading the asset
  81986. * @param textureInfo The glTF texture info property
  81987. * @param assign A function called synchronously after parsing the glTF properties
  81988. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  81989. */
  81990. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81991. /**
  81992. * @hidden
  81993. * Define this method to modify the default behavior when loading textures.
  81994. * @param context The context when loading the asset
  81995. * @param texture The glTF texture 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. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82000. /**
  82001. * Define this method to modify the default behavior when loading animations.
  82002. * @param context The context when loading the asset
  82003. * @param animation The glTF animation property
  82004. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  82005. */
  82006. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82007. /**
  82008. * @hidden
  82009. * Define this method to modify the default behavior when loading skins.
  82010. * @param context The context when loading the asset
  82011. * @param node The glTF node property
  82012. * @param skin The glTF skin property
  82013. * @returns A promise that resolves when the load is complete or null if not handled
  82014. */
  82015. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  82016. /**
  82017. * @hidden
  82018. * Define this method to modify the default behavior when loading uris.
  82019. * @param context The context when loading the asset
  82020. * @param property The glTF property associated with the uri
  82021. * @param uri The uri to load
  82022. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82023. */
  82024. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  82025. /**
  82026. * Define this method to modify the default behavior when loading buffer views.
  82027. * @param context The context when loading the asset
  82028. * @param bufferView The glTF buffer view property
  82029. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82030. */
  82031. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  82032. /**
  82033. * Define this method to modify the default behavior when loading buffers.
  82034. * @param context The context when loading the asset
  82035. * @param buffer The glTF buffer property
  82036. * @param byteOffset The byte offset to load
  82037. * @param byteLength The byte length to load
  82038. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82039. */
  82040. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  82041. }
  82042. }
  82043. declare module BABYLON.GLTF2 {
  82044. /**
  82045. * Helper class for working with arrays when loading the glTF asset
  82046. */
  82047. export class ArrayItem {
  82048. /**
  82049. * Gets an item from the given array.
  82050. * @param context The context when loading the asset
  82051. * @param array The array to get the item from
  82052. * @param index The index to the array
  82053. * @returns The array item
  82054. */
  82055. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  82056. /**
  82057. * Assign an `index` field to each item of the given array.
  82058. * @param array The array of items
  82059. */
  82060. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  82061. }
  82062. /**
  82063. * The glTF 2.0 loader
  82064. */
  82065. export class GLTFLoader implements IGLTFLoader {
  82066. /** @hidden */
  82067. _completePromises: Promise<any>[];
  82068. /** @hidden */
  82069. _forAssetContainer: boolean;
  82070. /** Storage */
  82071. _babylonLights: Light[];
  82072. /** @hidden */
  82073. _disableInstancedMesh: number;
  82074. private _disposed;
  82075. private _parent;
  82076. private _state;
  82077. private _extensions;
  82078. private _rootUrl;
  82079. private _fileName;
  82080. private _uniqueRootUrl;
  82081. private _gltf;
  82082. private _bin;
  82083. private _babylonScene;
  82084. private _rootBabylonMesh;
  82085. private _defaultBabylonMaterialData;
  82086. private static _RegisteredExtensions;
  82087. /**
  82088. * The default glTF sampler.
  82089. */
  82090. static readonly DefaultSampler: ISampler;
  82091. /**
  82092. * Registers a loader extension.
  82093. * @param name The name of the loader extension.
  82094. * @param factory The factory function that creates the loader extension.
  82095. */
  82096. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  82097. /**
  82098. * Unregisters a loader extension.
  82099. * @param name The name of the loader extension.
  82100. * @returns A boolean indicating whether the extension has been unregistered
  82101. */
  82102. static UnregisterExtension(name: string): boolean;
  82103. /**
  82104. * The loader state.
  82105. */
  82106. get state(): Nullable<GLTFLoaderState>;
  82107. /**
  82108. * The object that represents the glTF JSON.
  82109. */
  82110. get gltf(): IGLTF;
  82111. /**
  82112. * The BIN chunk of a binary glTF.
  82113. */
  82114. get bin(): Nullable<IDataBuffer>;
  82115. /**
  82116. * The parent file loader.
  82117. */
  82118. get parent(): GLTFFileLoader;
  82119. /**
  82120. * The Babylon scene when loading the asset.
  82121. */
  82122. get babylonScene(): Scene;
  82123. /**
  82124. * The root Babylon mesh when loading the asset.
  82125. */
  82126. get rootBabylonMesh(): Mesh;
  82127. /** @hidden */
  82128. constructor(parent: GLTFFileLoader);
  82129. /** @hidden */
  82130. dispose(): void;
  82131. /** @hidden */
  82132. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  82133. /** @hidden */
  82134. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82135. private _loadAsync;
  82136. private _loadData;
  82137. private _setupData;
  82138. private _loadExtensions;
  82139. private _checkExtensions;
  82140. private _setState;
  82141. private _createRootNode;
  82142. /**
  82143. * Loads a glTF scene.
  82144. * @param context The context when loading the asset
  82145. * @param scene The glTF scene property
  82146. * @returns A promise that resolves when the load is complete
  82147. */
  82148. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  82149. private _forEachPrimitive;
  82150. private _getMeshes;
  82151. private _getTransformNodes;
  82152. private _getSkeletons;
  82153. private _getAnimationGroups;
  82154. private _startAnimations;
  82155. /**
  82156. * Loads a glTF node.
  82157. * @param context The context when loading the asset
  82158. * @param node The glTF node property
  82159. * @param assign A function called synchronously after parsing the glTF properties
  82160. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  82161. */
  82162. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  82163. private _loadMeshAsync;
  82164. /**
  82165. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  82166. * @param context The context when loading the asset
  82167. * @param name The mesh name when loading the asset
  82168. * @param node The glTF node when loading the asset
  82169. * @param mesh The glTF mesh when loading the asset
  82170. * @param primitive The glTF mesh primitive property
  82171. * @param assign A function called synchronously after parsing the glTF properties
  82172. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82173. */
  82174. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  82175. private _loadVertexDataAsync;
  82176. private _createMorphTargets;
  82177. private _loadMorphTargetsAsync;
  82178. private _loadMorphTargetVertexDataAsync;
  82179. private static _LoadTransform;
  82180. private _loadSkinAsync;
  82181. private _loadBones;
  82182. private _loadBone;
  82183. private _loadSkinInverseBindMatricesDataAsync;
  82184. private _updateBoneMatrices;
  82185. private _getNodeMatrix;
  82186. /**
  82187. * Loads a glTF camera.
  82188. * @param context The context when loading the asset
  82189. * @param camera The glTF camera property
  82190. * @param assign A function called synchronously after parsing the glTF properties
  82191. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  82192. */
  82193. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  82194. private _loadAnimationsAsync;
  82195. /**
  82196. * Loads a glTF animation.
  82197. * @param context The context when loading the asset
  82198. * @param animation The glTF animation property
  82199. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  82200. */
  82201. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  82202. /**
  82203. * @hidden Loads a glTF animation channel.
  82204. * @param context The context when loading the asset
  82205. * @param animationContext The context of the animation when loading the asset
  82206. * @param animation The glTF animation property
  82207. * @param channel The glTF animation channel property
  82208. * @param babylonAnimationGroup The babylon animation group property
  82209. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  82210. * @returns A void promise when the channel load is complete
  82211. */
  82212. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  82213. private _loadAnimationSamplerAsync;
  82214. private _loadBufferAsync;
  82215. /**
  82216. * Loads a glTF buffer view.
  82217. * @param context The context when loading the asset
  82218. * @param bufferView The glTF buffer view property
  82219. * @returns A promise that resolves with the loaded data when the load is complete
  82220. */
  82221. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  82222. private _loadAccessorAsync;
  82223. /** @hidden */
  82224. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  82225. private _loadIndicesAccessorAsync;
  82226. private _loadVertexBufferViewAsync;
  82227. private _loadVertexAccessorAsync;
  82228. private _loadMaterialMetallicRoughnessPropertiesAsync;
  82229. /** @hidden */
  82230. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  82231. private _createDefaultMaterial;
  82232. /**
  82233. * Creates a Babylon material from a glTF material.
  82234. * @param context The context when loading the asset
  82235. * @param material The glTF material property
  82236. * @param babylonDrawMode The draw mode for the Babylon material
  82237. * @returns The Babylon material
  82238. */
  82239. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  82240. /**
  82241. * Loads properties from a glTF material into a Babylon material.
  82242. * @param context The context when loading the asset
  82243. * @param material The glTF material property
  82244. * @param babylonMaterial The Babylon material
  82245. * @returns A promise that resolves when the load is complete
  82246. */
  82247. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  82248. /**
  82249. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  82250. * @param context The context when loading the asset
  82251. * @param material The glTF material property
  82252. * @param babylonMaterial The Babylon material
  82253. * @returns A promise that resolves when the load is complete
  82254. */
  82255. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  82256. /**
  82257. * Loads the alpha properties from a glTF material into a Babylon material.
  82258. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  82259. * @param context The context when loading the asset
  82260. * @param material The glTF material property
  82261. * @param babylonMaterial The Babylon material
  82262. */
  82263. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  82264. /**
  82265. * Loads a glTF texture info.
  82266. * @param context The context when loading the asset
  82267. * @param textureInfo The glTF texture info property
  82268. * @param assign A function called synchronously after parsing the glTF properties
  82269. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  82270. */
  82271. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82272. /** @hidden */
  82273. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82274. /** @hidden */
  82275. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82276. private _loadSampler;
  82277. /**
  82278. * Loads a glTF image.
  82279. * @param context The context when loading the asset
  82280. * @param image The glTF image property
  82281. * @returns A promise that resolves with the loaded data when the load is complete
  82282. */
  82283. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  82284. /**
  82285. * Loads a glTF uri.
  82286. * @param context The context when loading the asset
  82287. * @param property The glTF property associated with the uri
  82288. * @param uri The base64 or relative uri
  82289. * @returns A promise that resolves with the loaded data when the load is complete
  82290. */
  82291. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  82292. /**
  82293. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  82294. * @param babylonObject the Babylon object with metadata
  82295. * @param pointer the JSON pointer
  82296. */
  82297. static AddPointerMetadata(babylonObject: {
  82298. metadata: any;
  82299. }, pointer: string): void;
  82300. private static _GetTextureWrapMode;
  82301. private static _GetTextureSamplingMode;
  82302. private static _GetTypedArrayConstructor;
  82303. private static _GetTypedArray;
  82304. private static _GetNumComponents;
  82305. private static _ValidateUri;
  82306. /** @hidden */
  82307. static _GetDrawMode(context: string, mode: number | undefined): number;
  82308. private _compileMaterialsAsync;
  82309. private _compileShadowGeneratorsAsync;
  82310. private _forEachExtensions;
  82311. private _applyExtensions;
  82312. private _extensionsOnLoading;
  82313. private _extensionsOnReady;
  82314. private _extensionsLoadSceneAsync;
  82315. private _extensionsLoadNodeAsync;
  82316. private _extensionsLoadCameraAsync;
  82317. private _extensionsLoadVertexDataAsync;
  82318. private _extensionsLoadMeshPrimitiveAsync;
  82319. private _extensionsLoadMaterialAsync;
  82320. private _extensionsCreateMaterial;
  82321. private _extensionsLoadMaterialPropertiesAsync;
  82322. private _extensionsLoadTextureInfoAsync;
  82323. private _extensionsLoadTextureAsync;
  82324. private _extensionsLoadAnimationAsync;
  82325. private _extensionsLoadSkinAsync;
  82326. private _extensionsLoadUriAsync;
  82327. private _extensionsLoadBufferViewAsync;
  82328. private _extensionsLoadBufferAsync;
  82329. /**
  82330. * Helper method called by a loader extension to load an glTF extension.
  82331. * @param context The context when loading the asset
  82332. * @param property The glTF property to load the extension from
  82333. * @param extensionName The name of the extension to load
  82334. * @param actionAsync The action to run
  82335. * @returns The promise returned by actionAsync or null if the extension does not exist
  82336. */
  82337. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  82338. /**
  82339. * Helper method called by a loader extension to load a glTF extra.
  82340. * @param context The context when loading the asset
  82341. * @param property The glTF property to load the extra 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 extra does not exist
  82345. */
  82346. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  82347. /**
  82348. * Checks for presence of an extension.
  82349. * @param name The name of the extension to check
  82350. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  82351. */
  82352. isExtensionUsed(name: string): boolean;
  82353. /**
  82354. * Increments the indentation level and logs a message.
  82355. * @param message The message to log
  82356. */
  82357. logOpen(message: string): void;
  82358. /**
  82359. * Decrements the indentation level.
  82360. */
  82361. logClose(): void;
  82362. /**
  82363. * Logs a message
  82364. * @param message The message to log
  82365. */
  82366. log(message: string): void;
  82367. /**
  82368. * Starts a performance counter.
  82369. * @param counterName The name of the performance counter
  82370. */
  82371. startPerformanceCounter(counterName: string): void;
  82372. /**
  82373. * Ends a performance counter.
  82374. * @param counterName The name of the performance counter
  82375. */
  82376. endPerformanceCounter(counterName: string): void;
  82377. }
  82378. }
  82379. declare module BABYLON.GLTF2.Loader.Extensions {
  82380. /** @hidden */
  82381. interface IEXTLightsImageBased_LightImageBased {
  82382. _babylonTexture?: BaseTexture;
  82383. _loaded?: Promise<void>;
  82384. }
  82385. /**
  82386. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  82387. */
  82388. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  82389. /**
  82390. * The name of this extension.
  82391. */
  82392. readonly name: string;
  82393. /**
  82394. * Defines whether this extension is enabled.
  82395. */
  82396. enabled: boolean;
  82397. private _loader;
  82398. private _lights?;
  82399. /** @hidden */
  82400. constructor(loader: GLTFLoader);
  82401. /** @hidden */
  82402. dispose(): void;
  82403. /** @hidden */
  82404. onLoading(): void;
  82405. /** @hidden */
  82406. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82407. private _loadLightAsync;
  82408. }
  82409. }
  82410. declare module BABYLON.GLTF2.Loader.Extensions {
  82411. /**
  82412. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  82413. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  82414. * !!! Experimental Extension Subject to Changes !!!
  82415. */
  82416. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  82417. /**
  82418. * The name of this extension.
  82419. */
  82420. readonly name: string;
  82421. /**
  82422. * Defines whether this extension is enabled.
  82423. */
  82424. enabled: boolean;
  82425. private _loader;
  82426. /** @hidden */
  82427. constructor(loader: GLTFLoader);
  82428. /** @hidden */
  82429. dispose(): void;
  82430. /** @hidden */
  82431. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82432. }
  82433. }
  82434. declare module BABYLON.GLTF2.Loader.Extensions {
  82435. /**
  82436. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  82437. */
  82438. export class EXT_texture_webp implements IGLTFLoaderExtension {
  82439. /** The name of this extension. */
  82440. readonly name: string;
  82441. /** Defines whether this extension is enabled. */
  82442. enabled: boolean;
  82443. private _loader;
  82444. /** @hidden */
  82445. constructor(loader: GLTFLoader);
  82446. /** @hidden */
  82447. dispose(): void;
  82448. /** @hidden */
  82449. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82450. }
  82451. }
  82452. declare module BABYLON.GLTF2.Loader.Extensions {
  82453. /**
  82454. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  82455. */
  82456. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  82457. /**
  82458. * The name of this extension.
  82459. */
  82460. readonly name: string;
  82461. /**
  82462. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  82463. */
  82464. dracoCompression?: DracoCompression;
  82465. /**
  82466. * Defines whether this extension is enabled.
  82467. */
  82468. enabled: boolean;
  82469. private _loader;
  82470. /** @hidden */
  82471. constructor(loader: GLTFLoader);
  82472. /** @hidden */
  82473. dispose(): void;
  82474. /** @hidden */
  82475. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82476. }
  82477. }
  82478. declare module BABYLON.GLTF2.Loader.Extensions {
  82479. /**
  82480. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  82481. */
  82482. export class KHR_lights implements IGLTFLoaderExtension {
  82483. /**
  82484. * The name of this extension.
  82485. */
  82486. readonly name: string;
  82487. /**
  82488. * Defines whether this extension is enabled.
  82489. */
  82490. enabled: boolean;
  82491. private _loader;
  82492. private _lights?;
  82493. /** @hidden */
  82494. constructor(loader: GLTFLoader);
  82495. /** @hidden */
  82496. dispose(): void;
  82497. /** @hidden */
  82498. onLoading(): void;
  82499. /** @hidden */
  82500. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82501. }
  82502. }
  82503. declare module BABYLON.GLTF2.Loader.Extensions {
  82504. /**
  82505. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  82506. */
  82507. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  82508. /**
  82509. * The name of this extension.
  82510. */
  82511. readonly name: string;
  82512. /**
  82513. * Defines whether this extension is enabled.
  82514. */
  82515. enabled: boolean;
  82516. /**
  82517. * Defines a number that determines the order the extensions are applied.
  82518. */
  82519. order: number;
  82520. private _loader;
  82521. /** @hidden */
  82522. constructor(loader: GLTFLoader);
  82523. /** @hidden */
  82524. dispose(): void;
  82525. /** @hidden */
  82526. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82527. private _loadSpecularGlossinessPropertiesAsync;
  82528. }
  82529. }
  82530. declare module BABYLON.GLTF2.Loader.Extensions {
  82531. /**
  82532. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  82533. */
  82534. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  82535. /**
  82536. * The name of this extension.
  82537. */
  82538. readonly name: string;
  82539. /**
  82540. * Defines whether this extension is enabled.
  82541. */
  82542. enabled: boolean;
  82543. /**
  82544. * Defines a number that determines the order the extensions are applied.
  82545. */
  82546. order: number;
  82547. private _loader;
  82548. /** @hidden */
  82549. constructor(loader: GLTFLoader);
  82550. /** @hidden */
  82551. dispose(): void;
  82552. /** @hidden */
  82553. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82554. private _loadUnlitPropertiesAsync;
  82555. }
  82556. }
  82557. declare module BABYLON.GLTF2.Loader.Extensions {
  82558. /**
  82559. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  82560. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  82561. * !!! Experimental Extension Subject to Changes !!!
  82562. */
  82563. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  82564. /**
  82565. * The name of this extension.
  82566. */
  82567. readonly name: string;
  82568. /**
  82569. * Defines whether this extension is enabled.
  82570. */
  82571. enabled: boolean;
  82572. /**
  82573. * Defines a number that determines the order the extensions are applied.
  82574. */
  82575. order: number;
  82576. private _loader;
  82577. /** @hidden */
  82578. constructor(loader: GLTFLoader);
  82579. /** @hidden */
  82580. dispose(): void;
  82581. /** @hidden */
  82582. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82583. private _loadClearCoatPropertiesAsync;
  82584. }
  82585. }
  82586. declare module BABYLON.GLTF2.Loader.Extensions {
  82587. /**
  82588. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  82589. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  82590. * !!! Experimental Extension Subject to Changes !!!
  82591. */
  82592. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  82593. /**
  82594. * The name of this extension.
  82595. */
  82596. readonly name: string;
  82597. /**
  82598. * Defines whether this extension is enabled.
  82599. */
  82600. enabled: boolean;
  82601. /**
  82602. * Defines a number that determines the order the extensions are applied.
  82603. */
  82604. order: number;
  82605. private _loader;
  82606. /** @hidden */
  82607. constructor(loader: GLTFLoader);
  82608. /** @hidden */
  82609. dispose(): void;
  82610. /** @hidden */
  82611. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82612. private _loadSheenPropertiesAsync;
  82613. }
  82614. }
  82615. declare module BABYLON.GLTF2.Loader.Extensions {
  82616. /**
  82617. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  82618. * !!! Experimental Extension Subject to Changes !!!
  82619. */
  82620. export class KHR_materials_specular implements IGLTFLoaderExtension {
  82621. /**
  82622. * The name of this extension.
  82623. */
  82624. readonly name: string;
  82625. /**
  82626. * Defines whether this extension is enabled.
  82627. */
  82628. enabled: boolean;
  82629. /**
  82630. * Defines a number that determines the order the extensions are applied.
  82631. */
  82632. order: number;
  82633. private _loader;
  82634. /** @hidden */
  82635. constructor(loader: GLTFLoader);
  82636. /** @hidden */
  82637. dispose(): void;
  82638. /** @hidden */
  82639. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82640. private _loadSpecularPropertiesAsync;
  82641. }
  82642. }
  82643. declare module BABYLON.GLTF2.Loader.Extensions {
  82644. /**
  82645. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  82646. * !!! Experimental Extension Subject to Changes !!!
  82647. */
  82648. export class KHR_materials_ior implements IGLTFLoaderExtension {
  82649. /**
  82650. * Default ior Value from the spec.
  82651. */
  82652. private static readonly _DEFAULT_IOR;
  82653. /**
  82654. * The name of this extension.
  82655. */
  82656. readonly name: string;
  82657. /**
  82658. * Defines whether this extension is enabled.
  82659. */
  82660. enabled: boolean;
  82661. /**
  82662. * Defines a number that determines the order the extensions are applied.
  82663. */
  82664. order: number;
  82665. private _loader;
  82666. /** @hidden */
  82667. constructor(loader: GLTFLoader);
  82668. /** @hidden */
  82669. dispose(): void;
  82670. /** @hidden */
  82671. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82672. private _loadIorPropertiesAsync;
  82673. }
  82674. }
  82675. declare module BABYLON.GLTF2.Loader.Extensions {
  82676. /**
  82677. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  82678. * !!! Experimental Extension Subject to Changes !!!
  82679. */
  82680. export class KHR_materials_variants implements IGLTFLoaderExtension {
  82681. /**
  82682. * The name of this extension.
  82683. */
  82684. readonly name: string;
  82685. /**
  82686. * Defines whether this extension is enabled.
  82687. */
  82688. enabled: boolean;
  82689. private _loader;
  82690. private _variants?;
  82691. /** @hidden */
  82692. constructor(loader: GLTFLoader);
  82693. /** @hidden */
  82694. dispose(): void;
  82695. /**
  82696. * Gets the list of available variant names for this asset.
  82697. * @param rootMesh The glTF root mesh
  82698. * @returns the list of all the variant names for this model
  82699. */
  82700. static GetAvailableVariants(rootMesh: Mesh): string[];
  82701. /**
  82702. * Gets the list of available variant names for this asset.
  82703. * @param rootMesh The glTF root mesh
  82704. * @returns the list of all the variant names for this model
  82705. */
  82706. getAvailableVariants(rootMesh: Mesh): string[];
  82707. /**
  82708. * Select a variant given a variant name or a list of variant names.
  82709. * @param rootMesh The glTF root mesh
  82710. * @param variantName The variant name(s) to select.
  82711. */
  82712. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  82713. /**
  82714. * Select a variant given a variant name or a list of variant names.
  82715. * @param rootMesh The glTF root mesh
  82716. * @param variantName The variant name(s) to select.
  82717. */
  82718. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  82719. /**
  82720. * Reset back to the original before selecting a variant.
  82721. * @param rootMesh The glTF root mesh
  82722. */
  82723. static Reset(rootMesh: Mesh): void;
  82724. /**
  82725. * Reset back to the original before selecting a variant.
  82726. * @param rootMesh The glTF root mesh
  82727. */
  82728. reset(rootMesh: Mesh): void;
  82729. /**
  82730. * Gets the last selected variant name(s) or null if original.
  82731. * @param rootMesh The glTF root mesh
  82732. * @returns The selected variant name(s).
  82733. */
  82734. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  82735. /**
  82736. * Gets the last selected variant name(s) or null if original.
  82737. * @param rootMesh The glTF root mesh
  82738. * @returns The selected variant name(s).
  82739. */
  82740. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  82741. private static _GetExtensionMetadata;
  82742. /** @hidden */
  82743. onLoading(): void;
  82744. /** @hidden */
  82745. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82746. }
  82747. }
  82748. declare module BABYLON.GLTF2.Loader.Extensions {
  82749. /**
  82750. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  82751. * !!! Experimental Extension Subject to Changes !!!
  82752. */
  82753. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  82754. /**
  82755. * The name of this extension.
  82756. */
  82757. readonly name: string;
  82758. /**
  82759. * Defines whether this extension is enabled.
  82760. */
  82761. enabled: boolean;
  82762. /**
  82763. * Defines a number that determines the order the extensions are applied.
  82764. */
  82765. order: number;
  82766. private _loader;
  82767. /** @hidden */
  82768. constructor(loader: GLTFLoader);
  82769. /** @hidden */
  82770. dispose(): void;
  82771. /** @hidden */
  82772. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82773. private _loadTransparentPropertiesAsync;
  82774. }
  82775. }
  82776. declare module BABYLON.GLTF2.Loader.Extensions {
  82777. /**
  82778. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  82779. */
  82780. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  82781. /**
  82782. * The name of this extension.
  82783. */
  82784. readonly name: string;
  82785. /**
  82786. * Defines whether this extension is enabled.
  82787. */
  82788. enabled: boolean;
  82789. /** @hidden */
  82790. constructor(loader: GLTFLoader);
  82791. /** @hidden */
  82792. dispose(): void;
  82793. }
  82794. }
  82795. declare module BABYLON.GLTF2.Loader.Extensions {
  82796. /**
  82797. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  82798. * !!! Experimental Extension Subject to Changes !!!
  82799. */
  82800. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  82801. /** The name of this extension. */
  82802. readonly name: string;
  82803. /** Defines whether this extension is enabled. */
  82804. enabled: boolean;
  82805. private _loader;
  82806. /** @hidden */
  82807. constructor(loader: GLTFLoader);
  82808. /** @hidden */
  82809. dispose(): void;
  82810. /** @hidden */
  82811. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82812. }
  82813. }
  82814. declare module BABYLON.GLTF2.Loader.Extensions {
  82815. /**
  82816. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  82817. */
  82818. export class KHR_texture_transform implements IGLTFLoaderExtension {
  82819. /**
  82820. * The name of this extension.
  82821. */
  82822. readonly name: string;
  82823. /**
  82824. * Defines whether this extension is enabled.
  82825. */
  82826. enabled: boolean;
  82827. private _loader;
  82828. /** @hidden */
  82829. constructor(loader: GLTFLoader);
  82830. /** @hidden */
  82831. dispose(): void;
  82832. /** @hidden */
  82833. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82834. }
  82835. }
  82836. declare module BABYLON.GLTF2.Loader.Extensions {
  82837. /**
  82838. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  82839. * !!! Experimental Extension Subject to Changes !!!
  82840. */
  82841. export class KHR_xmp implements IGLTFLoaderExtension {
  82842. /**
  82843. * The name of this extension.
  82844. */
  82845. readonly name: string;
  82846. /**
  82847. * Defines whether this extension is enabled.
  82848. */
  82849. enabled: boolean;
  82850. /**
  82851. * Defines a number that determines the order the extensions are applied.
  82852. */
  82853. order: number;
  82854. private _loader;
  82855. /** @hidden */
  82856. constructor(loader: GLTFLoader);
  82857. /** @hidden */
  82858. dispose(): void;
  82859. /**
  82860. * Called after the loader state changes to LOADING.
  82861. */
  82862. onLoading(): void;
  82863. }
  82864. }
  82865. declare module BABYLON.GLTF2.Loader.Extensions {
  82866. /**
  82867. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  82868. */
  82869. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  82870. /**
  82871. * The name of this extension.
  82872. */
  82873. readonly name: string;
  82874. /**
  82875. * Defines whether this extension is enabled.
  82876. */
  82877. enabled: boolean;
  82878. private _loader;
  82879. private _clips;
  82880. private _emitters;
  82881. /** @hidden */
  82882. constructor(loader: GLTFLoader);
  82883. /** @hidden */
  82884. dispose(): void;
  82885. /** @hidden */
  82886. onLoading(): void;
  82887. /** @hidden */
  82888. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82889. /** @hidden */
  82890. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82891. /** @hidden */
  82892. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82893. private _loadClipAsync;
  82894. private _loadEmitterAsync;
  82895. private _getEventAction;
  82896. private _loadAnimationEventAsync;
  82897. }
  82898. }
  82899. declare module BABYLON.GLTF2.Loader.Extensions {
  82900. /**
  82901. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  82902. */
  82903. export class MSFT_lod implements IGLTFLoaderExtension {
  82904. /**
  82905. * The name of this extension.
  82906. */
  82907. readonly name: string;
  82908. /**
  82909. * Defines whether this extension is enabled.
  82910. */
  82911. enabled: boolean;
  82912. /**
  82913. * Defines a number that determines the order the extensions are applied.
  82914. */
  82915. order: number;
  82916. /**
  82917. * Maximum number of LODs to load, starting from the lowest LOD.
  82918. */
  82919. maxLODsToLoad: number;
  82920. /**
  82921. * Observable raised when all node LODs of one level are loaded.
  82922. * The event data is the index of the loaded LOD starting from zero.
  82923. * Dispose the loader to cancel the loading of the next level of LODs.
  82924. */
  82925. onNodeLODsLoadedObservable: Observable<number>;
  82926. /**
  82927. * Observable raised when all material LODs of one level are loaded.
  82928. * The event data is the index of the loaded LOD starting from zero.
  82929. * Dispose the loader to cancel the loading of the next level of LODs.
  82930. */
  82931. onMaterialLODsLoadedObservable: Observable<number>;
  82932. private _loader;
  82933. private _bufferLODs;
  82934. private _nodeIndexLOD;
  82935. private _nodeSignalLODs;
  82936. private _nodePromiseLODs;
  82937. private _nodeBufferLODs;
  82938. private _materialIndexLOD;
  82939. private _materialSignalLODs;
  82940. private _materialPromiseLODs;
  82941. private _materialBufferLODs;
  82942. /** @hidden */
  82943. constructor(loader: GLTFLoader);
  82944. /** @hidden */
  82945. dispose(): void;
  82946. /** @hidden */
  82947. onReady(): void;
  82948. /** @hidden */
  82949. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82950. /** @hidden */
  82951. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82952. /** @hidden */
  82953. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  82954. /** @hidden */
  82955. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  82956. /** @hidden */
  82957. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  82958. private _loadBufferLOD;
  82959. /**
  82960. * Gets an array of LOD properties from lowest to highest.
  82961. */
  82962. private _getLODs;
  82963. private _disposeTransformNode;
  82964. private _disposeMaterials;
  82965. }
  82966. }
  82967. declare module BABYLON.GLTF2.Loader.Extensions {
  82968. /** @hidden */
  82969. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  82970. readonly name: string;
  82971. enabled: boolean;
  82972. private _loader;
  82973. constructor(loader: GLTFLoader);
  82974. dispose(): void;
  82975. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82976. }
  82977. }
  82978. declare module BABYLON.GLTF2.Loader.Extensions {
  82979. /** @hidden */
  82980. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  82981. readonly name: string;
  82982. enabled: boolean;
  82983. private _loader;
  82984. constructor(loader: GLTFLoader);
  82985. dispose(): void;
  82986. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82987. }
  82988. }
  82989. declare module BABYLON.GLTF2.Loader.Extensions {
  82990. /**
  82991. * Store glTF extras (if present) in BJS objects' metadata
  82992. */
  82993. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  82994. /**
  82995. * The name of this extension.
  82996. */
  82997. readonly name: string;
  82998. /**
  82999. * Defines whether this extension is enabled.
  83000. */
  83001. enabled: boolean;
  83002. private _loader;
  83003. private _assignExtras;
  83004. /** @hidden */
  83005. constructor(loader: GLTFLoader);
  83006. /** @hidden */
  83007. dispose(): void;
  83008. /** @hidden */
  83009. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83010. /** @hidden */
  83011. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  83012. /** @hidden */
  83013. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  83014. }
  83015. }
  83016. declare module BABYLON {
  83017. /**
  83018. * Class reading and parsing the MTL file bundled with the obj file.
  83019. */
  83020. export class MTLFileLoader {
  83021. /**
  83022. * Invert Y-Axis of referenced textures on load
  83023. */
  83024. static INVERT_TEXTURE_Y: boolean;
  83025. /**
  83026. * All material loaded from the mtl will be set here
  83027. */
  83028. materials: StandardMaterial[];
  83029. /**
  83030. * This function will read the mtl file and create each material described inside
  83031. * This function could be improve by adding :
  83032. * -some component missing (Ni, Tf...)
  83033. * -including the specific options available
  83034. *
  83035. * @param scene defines the scene the material will be created in
  83036. * @param data defines the mtl data to parse
  83037. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  83038. * @param forAssetContainer defines if the material should be registered in the scene
  83039. */
  83040. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  83041. /**
  83042. * Gets the texture for the material.
  83043. *
  83044. * If the material is imported from input file,
  83045. * We sanitize the url to ensure it takes the textre from aside the material.
  83046. *
  83047. * @param rootUrl The root url to load from
  83048. * @param value The value stored in the mtl
  83049. * @return The Texture
  83050. */
  83051. private static _getTexture;
  83052. }
  83053. }
  83054. declare module BABYLON {
  83055. /**
  83056. * Options for loading OBJ/MTL files
  83057. */
  83058. type MeshLoadOptions = {
  83059. /**
  83060. * Defines if UVs are optimized by default during load.
  83061. */
  83062. OptimizeWithUV: boolean;
  83063. /**
  83064. * Defines custom scaling of UV coordinates of loaded meshes.
  83065. */
  83066. UVScaling: Vector2;
  83067. /**
  83068. * Invert model on y-axis (does a model scaling inversion)
  83069. */
  83070. InvertY: boolean;
  83071. /**
  83072. * Invert Y-Axis of referenced textures on load
  83073. */
  83074. InvertTextureY: boolean;
  83075. /**
  83076. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  83077. */
  83078. ImportVertexColors: boolean;
  83079. /**
  83080. * Compute the normals for the model, even if normals are present in the file.
  83081. */
  83082. ComputeNormals: boolean;
  83083. /**
  83084. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  83085. */
  83086. SkipMaterials: boolean;
  83087. /**
  83088. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  83089. */
  83090. MaterialLoadingFailsSilently: boolean;
  83091. };
  83092. /**
  83093. * OBJ file type loader.
  83094. * This is a babylon scene loader plugin.
  83095. */
  83096. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  83097. /**
  83098. * Defines if UVs are optimized by default during load.
  83099. */
  83100. static OPTIMIZE_WITH_UV: boolean;
  83101. /**
  83102. * Invert model on y-axis (does a model scaling inversion)
  83103. */
  83104. static INVERT_Y: boolean;
  83105. /**
  83106. * Invert Y-Axis of referenced textures on load
  83107. */
  83108. static get INVERT_TEXTURE_Y(): boolean;
  83109. static set INVERT_TEXTURE_Y(value: boolean);
  83110. /**
  83111. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  83112. */
  83113. static IMPORT_VERTEX_COLORS: boolean;
  83114. /**
  83115. * Compute the normals for the model, even if normals are present in the file.
  83116. */
  83117. static COMPUTE_NORMALS: boolean;
  83118. /**
  83119. * Defines custom scaling of UV coordinates of loaded meshes.
  83120. */
  83121. static UV_SCALING: Vector2;
  83122. /**
  83123. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  83124. */
  83125. static SKIP_MATERIALS: boolean;
  83126. /**
  83127. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  83128. *
  83129. * Defaults to true for backwards compatibility.
  83130. */
  83131. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  83132. /**
  83133. * Defines the name of the plugin.
  83134. */
  83135. name: string;
  83136. /**
  83137. * Defines the extension the plugin is able to load.
  83138. */
  83139. extensions: string;
  83140. /** @hidden */
  83141. obj: RegExp;
  83142. /** @hidden */
  83143. group: RegExp;
  83144. /** @hidden */
  83145. mtllib: RegExp;
  83146. /** @hidden */
  83147. usemtl: RegExp;
  83148. /** @hidden */
  83149. smooth: RegExp;
  83150. /** @hidden */
  83151. vertexPattern: RegExp;
  83152. /** @hidden */
  83153. normalPattern: RegExp;
  83154. /** @hidden */
  83155. uvPattern: RegExp;
  83156. /** @hidden */
  83157. facePattern1: RegExp;
  83158. /** @hidden */
  83159. facePattern2: RegExp;
  83160. /** @hidden */
  83161. facePattern3: RegExp;
  83162. /** @hidden */
  83163. facePattern4: RegExp;
  83164. /** @hidden */
  83165. facePattern5: RegExp;
  83166. private _forAssetContainer;
  83167. private _meshLoadOptions;
  83168. /**
  83169. * Creates loader for .OBJ files
  83170. *
  83171. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  83172. */
  83173. constructor(meshLoadOptions?: MeshLoadOptions);
  83174. private static get currentMeshLoadOptions();
  83175. /**
  83176. * Calls synchronously the MTL file attached to this obj.
  83177. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  83178. * Without this function materials are not displayed in the first frame (but displayed after).
  83179. * In consequence it is impossible to get material information in your HTML file
  83180. *
  83181. * @param url The URL of the MTL file
  83182. * @param rootUrl
  83183. * @param onSuccess Callback function to be called when the MTL file is loaded
  83184. * @private
  83185. */
  83186. private _loadMTL;
  83187. /**
  83188. * Instantiates a OBJ file loader plugin.
  83189. * @returns the created plugin
  83190. */
  83191. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  83192. /**
  83193. * If the data string can be loaded directly.
  83194. *
  83195. * @param data string containing the file data
  83196. * @returns if the data can be loaded directly
  83197. */
  83198. canDirectLoad(data: string): boolean;
  83199. /**
  83200. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  83201. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  83202. * @param scene the scene the meshes should be added to
  83203. * @param data the OBJ data to load
  83204. * @param rootUrl root url to load from
  83205. * @param onProgress event that fires when loading progress has occured
  83206. * @param fileName Defines the name of the file to load
  83207. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  83208. */
  83209. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  83210. meshes: AbstractMesh[];
  83211. particleSystems: IParticleSystem[];
  83212. skeletons: Skeleton[];
  83213. animationGroups: AnimationGroup[];
  83214. }>;
  83215. /**
  83216. * Imports all objects from the loaded OBJ data and adds them to the scene
  83217. * @param scene the scene the objects should be added to
  83218. * @param data the OBJ data to load
  83219. * @param rootUrl root url to load from
  83220. * @param onProgress event that fires when loading progress has occured
  83221. * @param fileName Defines the name of the file to load
  83222. * @returns a promise which completes when objects have been loaded to the scene
  83223. */
  83224. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83225. /**
  83226. * Load into an asset container.
  83227. * @param scene The scene to load into
  83228. * @param data The data to import
  83229. * @param rootUrl The root url for scene and resources
  83230. * @param onProgress The callback when the load progresses
  83231. * @param fileName Defines the name of the file to load
  83232. * @returns The loaded asset container
  83233. */
  83234. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  83235. /**
  83236. * Read the OBJ file and create an Array of meshes.
  83237. * Each mesh contains all information given by the OBJ and the MTL file.
  83238. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  83239. *
  83240. * @param meshesNames
  83241. * @param scene Scene The scene where are displayed the data
  83242. * @param data String The content of the obj file
  83243. * @param rootUrl String The path to the folder
  83244. * @returns Array<AbstractMesh>
  83245. * @private
  83246. */
  83247. private _parseSolid;
  83248. }
  83249. }
  83250. declare module BABYLON {
  83251. /**
  83252. * STL file type loader.
  83253. * This is a babylon scene loader plugin.
  83254. */
  83255. export class STLFileLoader implements ISceneLoaderPlugin {
  83256. /** @hidden */
  83257. solidPattern: RegExp;
  83258. /** @hidden */
  83259. facetsPattern: RegExp;
  83260. /** @hidden */
  83261. normalPattern: RegExp;
  83262. /** @hidden */
  83263. vertexPattern: RegExp;
  83264. /**
  83265. * Defines the name of the plugin.
  83266. */
  83267. name: string;
  83268. /**
  83269. * Defines the extensions the stl loader is able to load.
  83270. * force data to come in as an ArrayBuffer
  83271. * we'll convert to string if it looks like it's an ASCII .stl
  83272. */
  83273. extensions: ISceneLoaderPluginExtensions;
  83274. /**
  83275. * Import meshes into a scene.
  83276. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  83277. * @param scene The scene to import into
  83278. * @param data The data to import
  83279. * @param rootUrl The root url for scene and resources
  83280. * @param meshes The meshes array to import into
  83281. * @param particleSystems The particle systems array to import into
  83282. * @param skeletons The skeletons array to import into
  83283. * @param onError The callback when import fails
  83284. * @returns True if successful or false otherwise
  83285. */
  83286. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  83287. /**
  83288. * Load into a scene.
  83289. * @param scene The scene to load into
  83290. * @param data The data to import
  83291. * @param rootUrl The root url for scene and resources
  83292. * @param onError The callback when import fails
  83293. * @returns true if successful or false otherwise
  83294. */
  83295. load(scene: Scene, data: any, rootUrl: string): boolean;
  83296. /**
  83297. * Load into an asset container.
  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 The loaded asset container
  83303. */
  83304. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  83305. private _isBinary;
  83306. private _parseBinary;
  83307. private _parseASCII;
  83308. }
  83309. }
  83310. declare module BABYLON {
  83311. /**
  83312. * Class for generating OBJ data from a Babylon scene.
  83313. */
  83314. export class OBJExport {
  83315. /**
  83316. * Exports the geometry of a Mesh array in .OBJ file format (text)
  83317. * @param mesh defines the list of meshes to serialize
  83318. * @param materials defines if materials should be exported
  83319. * @param matlibname defines the name of the associated mtl file
  83320. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  83321. * @returns the OBJ content
  83322. */
  83323. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  83324. /**
  83325. * Exports the material(s) of a mesh in .MTL file format (text)
  83326. * @param mesh defines the mesh to extract the material from
  83327. * @returns the mtl content
  83328. */
  83329. static MTL(mesh: Mesh): string;
  83330. }
  83331. }
  83332. declare module BABYLON {
  83333. /** @hidden */
  83334. export var __IGLTFExporterExtension: number;
  83335. /**
  83336. * Interface for extending the exporter
  83337. * @hidden
  83338. */
  83339. export interface IGLTFExporterExtension {
  83340. /**
  83341. * The name of this extension
  83342. */
  83343. readonly name: string;
  83344. /**
  83345. * Defines whether this extension is enabled
  83346. */
  83347. enabled: boolean;
  83348. /**
  83349. * Defines whether this extension is required
  83350. */
  83351. required: boolean;
  83352. }
  83353. }
  83354. declare module BABYLON.GLTF2.Exporter {
  83355. /** @hidden */
  83356. export var __IGLTFExporterExtensionV2: number;
  83357. /**
  83358. * Interface for a glTF exporter extension
  83359. * @hidden
  83360. */
  83361. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  83362. /**
  83363. * Define this method to modify the default behavior before exporting a texture
  83364. * @param context The context when loading the asset
  83365. * @param babylonTexture The Babylon.js texture
  83366. * @param mimeType The mime-type of the generated image
  83367. * @returns A promise that resolves with the exported texture
  83368. */
  83369. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  83370. /**
  83371. * Define this method to get notified when a texture info is created
  83372. * @param context The context when loading the asset
  83373. * @param textureInfo The glTF texture info
  83374. * @param babylonTexture The Babylon.js texture
  83375. */
  83376. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  83377. /**
  83378. * Define this method to modify the default behavior when exporting texture info
  83379. * @param context The context when loading the asset
  83380. * @param meshPrimitive glTF mesh primitive
  83381. * @param babylonSubMesh Babylon submesh
  83382. * @param binaryWriter glTF serializer binary writer instance
  83383. * @returns nullable IMeshPrimitive promise
  83384. */
  83385. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  83386. /**
  83387. * Define this method to modify the default behavior when exporting a node
  83388. * @param context The context when exporting the node
  83389. * @param node glTF node
  83390. * @param babylonNode BabylonJS node
  83391. * @returns nullable INode promise
  83392. */
  83393. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83394. [key: number]: number;
  83395. }): Promise<Nullable<INode>>;
  83396. /**
  83397. * Define this method to modify the default behavior when exporting a material
  83398. * @param material glTF material
  83399. * @param babylonMaterial BabylonJS material
  83400. * @returns nullable IMaterial promise
  83401. */
  83402. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  83403. /**
  83404. * Define this method to return additional textures to export from a material
  83405. * @param material glTF material
  83406. * @param babylonMaterial BabylonJS material
  83407. * @returns List of textures
  83408. */
  83409. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  83410. /** Gets a boolean indicating that this extension was used */
  83411. wasUsed: boolean;
  83412. /** Gets a boolean indicating that this extension is required for the file to work */
  83413. required: boolean;
  83414. /**
  83415. * Called after the exporter state changes to EXPORTING
  83416. */
  83417. onExporting?(): void;
  83418. }
  83419. }
  83420. declare module BABYLON.GLTF2.Exporter {
  83421. /**
  83422. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  83423. * @hidden
  83424. */
  83425. export class _GLTFMaterialExporter {
  83426. /**
  83427. * Represents the dielectric specular values for R, G and B
  83428. */
  83429. private static readonly _DielectricSpecular;
  83430. /**
  83431. * Allows the maximum specular power to be defined for material calculations
  83432. */
  83433. private static readonly _MaxSpecularPower;
  83434. /**
  83435. * Mapping to store textures
  83436. */
  83437. private _textureMap;
  83438. /**
  83439. * Numeric tolerance value
  83440. */
  83441. private static readonly _Epsilon;
  83442. /**
  83443. * Reference to the glTF Exporter
  83444. */
  83445. private _exporter;
  83446. constructor(exporter: _Exporter);
  83447. /**
  83448. * Specifies if two colors are approximately equal in value
  83449. * @param color1 first color to compare to
  83450. * @param color2 second color to compare to
  83451. * @param epsilon threshold value
  83452. */
  83453. private static FuzzyEquals;
  83454. /**
  83455. * Gets the materials from a Babylon scene and converts them to glTF materials
  83456. * @param scene babylonjs scene
  83457. * @param mimeType texture mime type
  83458. * @param images array of images
  83459. * @param textures array of textures
  83460. * @param materials array of materials
  83461. * @param imageData mapping of texture names to base64 textures
  83462. * @param hasTextureCoords specifies if texture coordinates are present on the material
  83463. */
  83464. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  83465. /**
  83466. * Makes a copy of the glTF material without the texture parameters
  83467. * @param originalMaterial original glTF material
  83468. * @returns glTF material without texture parameters
  83469. */
  83470. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  83471. /**
  83472. * Specifies if the material has any texture parameters present
  83473. * @param material glTF Material
  83474. * @returns boolean specifying if texture parameters are present
  83475. */
  83476. _hasTexturesPresent(material: IMaterial): boolean;
  83477. /**
  83478. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  83479. * @param babylonStandardMaterial
  83480. * @returns glTF Metallic Roughness Material representation
  83481. */
  83482. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  83483. /**
  83484. * Computes the metallic factor
  83485. * @param diffuse diffused value
  83486. * @param specular specular value
  83487. * @param oneMinusSpecularStrength one minus the specular strength
  83488. * @returns metallic value
  83489. */
  83490. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  83491. /**
  83492. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  83493. * @param glTFMaterial glTF material
  83494. * @param babylonMaterial Babylon material
  83495. */
  83496. private static _SetAlphaMode;
  83497. /**
  83498. * Converts a Babylon Standard Material to a glTF Material
  83499. * @param babylonStandardMaterial BJS Standard Material
  83500. * @param mimeType mime type to use for the textures
  83501. * @param images array of glTF image interfaces
  83502. * @param textures array of glTF texture interfaces
  83503. * @param materials array of glTF material interfaces
  83504. * @param imageData map of image file name to data
  83505. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83506. */
  83507. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83508. private _finishMaterial;
  83509. /**
  83510. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  83511. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  83512. * @param mimeType mime type to use for the textures
  83513. * @param images array of glTF image interfaces
  83514. * @param textures array of glTF texture interfaces
  83515. * @param materials array of glTF material interfaces
  83516. * @param imageData map of image file name to data
  83517. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83518. */
  83519. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83520. /**
  83521. * Converts an image typed array buffer to a base64 image
  83522. * @param buffer typed array buffer
  83523. * @param width width of the image
  83524. * @param height height of the image
  83525. * @param mimeType mimetype of the image
  83526. * @returns base64 image string
  83527. */
  83528. private _createBase64FromCanvasAsync;
  83529. /**
  83530. * Generates a white texture based on the specified width and height
  83531. * @param width width of the texture in pixels
  83532. * @param height height of the texture in pixels
  83533. * @param scene babylonjs scene
  83534. * @returns white texture
  83535. */
  83536. private _createWhiteTexture;
  83537. /**
  83538. * 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
  83539. * @param texture1 first texture to resize
  83540. * @param texture2 second texture to resize
  83541. * @param scene babylonjs scene
  83542. * @returns resized textures or null
  83543. */
  83544. private _resizeTexturesToSameDimensions;
  83545. /**
  83546. * Converts an array of pixels to a Float32Array
  83547. * Throws an error if the pixel format is not supported
  83548. * @param pixels - array buffer containing pixel values
  83549. * @returns Float32 of pixels
  83550. */
  83551. private _convertPixelArrayToFloat32;
  83552. /**
  83553. * Convert Specular Glossiness Textures to Metallic Roughness
  83554. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  83555. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  83556. * @param diffuseTexture texture used to store diffuse information
  83557. * @param specularGlossinessTexture texture used to store specular and glossiness information
  83558. * @param factors specular glossiness material factors
  83559. * @param mimeType the mime type to use for the texture
  83560. * @returns pbr metallic roughness interface or null
  83561. */
  83562. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  83563. /**
  83564. * Converts specular glossiness material properties to metallic roughness
  83565. * @param specularGlossiness interface with specular glossiness material properties
  83566. * @returns interface with metallic roughness material properties
  83567. */
  83568. private _convertSpecularGlossinessToMetallicRoughness;
  83569. /**
  83570. * Calculates the surface reflectance, independent of lighting conditions
  83571. * @param color Color source to calculate brightness from
  83572. * @returns number representing the perceived brightness, or zero if color is undefined
  83573. */
  83574. private _getPerceivedBrightness;
  83575. /**
  83576. * Returns the maximum color component value
  83577. * @param color
  83578. * @returns maximum color component value, or zero if color is null or undefined
  83579. */
  83580. private _getMaxComponent;
  83581. /**
  83582. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  83583. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83584. * @param mimeType mime type to use for the textures
  83585. * @param images array of glTF image interfaces
  83586. * @param textures array of glTF texture interfaces
  83587. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  83588. * @param imageData map of image file name to data
  83589. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83590. * @returns glTF PBR Metallic Roughness factors
  83591. */
  83592. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  83593. private _getGLTFTextureSampler;
  83594. private _getGLTFTextureWrapMode;
  83595. private _getGLTFTextureWrapModesSampler;
  83596. /**
  83597. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  83598. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83599. * @param mimeType mime type to use for the textures
  83600. * @param images array of glTF image interfaces
  83601. * @param textures array of glTF texture interfaces
  83602. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  83603. * @param imageData map of image file name to data
  83604. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83605. * @returns glTF PBR Metallic Roughness factors
  83606. */
  83607. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  83608. /**
  83609. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  83610. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83611. * @param mimeType mime type to use for the textures
  83612. * @param images array of glTF image interfaces
  83613. * @param textures array of glTF texture interfaces
  83614. * @param materials array of glTF material interfaces
  83615. * @param imageData map of image file name to data
  83616. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83617. */
  83618. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83619. private setMetallicRoughnessPbrMaterial;
  83620. private getPixelsFromTexture;
  83621. /**
  83622. * Extracts a texture from a Babylon texture into file data and glTF data
  83623. * @param babylonTexture Babylon texture to extract
  83624. * @param mimeType Mime Type of the babylonTexture
  83625. * @return glTF texture info, or null if the texture format is not supported
  83626. */
  83627. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  83628. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  83629. /**
  83630. * Builds a texture from base64 string
  83631. * @param base64Texture base64 texture string
  83632. * @param baseTextureName Name to use for the texture
  83633. * @param mimeType image mime type for the texture
  83634. * @param images array of images
  83635. * @param textures array of textures
  83636. * @param imageData map of image data
  83637. * @returns glTF texture info, or null if the texture format is not supported
  83638. */
  83639. private _getTextureInfoFromBase64;
  83640. }
  83641. }
  83642. declare module BABYLON {
  83643. /**
  83644. * Class for holding and downloading glTF file data
  83645. */
  83646. export class GLTFData {
  83647. /**
  83648. * Object which contains the file name as the key and its data as the value
  83649. */
  83650. glTFFiles: {
  83651. [fileName: string]: string | Blob;
  83652. };
  83653. /**
  83654. * Initializes the glTF file object
  83655. */
  83656. constructor();
  83657. /**
  83658. * Downloads the glTF data as files based on their names and data
  83659. */
  83660. downloadFiles(): void;
  83661. }
  83662. }
  83663. declare module BABYLON {
  83664. /**
  83665. * Holds a collection of exporter options and parameters
  83666. */
  83667. export interface IExportOptions {
  83668. /**
  83669. * Function which indicates whether a babylon node should be exported or not
  83670. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  83671. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  83672. */
  83673. shouldExportNode?(node: Node): boolean;
  83674. /**
  83675. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  83676. * @param metadata source metadata to read from
  83677. * @returns the data to store to glTF node extras
  83678. */
  83679. metadataSelector?(metadata: any): any;
  83680. /**
  83681. * The sample rate to bake animation curves
  83682. */
  83683. animationSampleRate?: number;
  83684. /**
  83685. * Begin serialization without waiting for the scene to be ready
  83686. */
  83687. exportWithoutWaitingForScene?: boolean;
  83688. /**
  83689. * Indicates if coordinate system swapping root nodes should be included in export
  83690. */
  83691. includeCoordinateSystemConversionNodes?: boolean;
  83692. }
  83693. /**
  83694. * Class for generating glTF data from a Babylon scene.
  83695. */
  83696. export class GLTF2Export {
  83697. /**
  83698. * Exports the geometry of the scene to .gltf file format asynchronously
  83699. * @param scene Babylon scene with scene hierarchy information
  83700. * @param filePrefix File prefix to use when generating the glTF file
  83701. * @param options Exporter options
  83702. * @returns Returns an object with a .gltf file and associates texture names
  83703. * as keys and their data and paths as values
  83704. */
  83705. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  83706. private static _PreExportAsync;
  83707. private static _PostExportAsync;
  83708. /**
  83709. * Exports the geometry of the scene to .glb file format asychronously
  83710. * @param scene Babylon scene with scene hierarchy information
  83711. * @param filePrefix File prefix to use when generating glb file
  83712. * @param options Exporter options
  83713. * @returns Returns an object with a .glb filename as key and data as value
  83714. */
  83715. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  83716. }
  83717. }
  83718. declare module BABYLON.GLTF2.Exporter {
  83719. /**
  83720. * @hidden
  83721. */
  83722. export class _GLTFUtilities {
  83723. /**
  83724. * Creates a buffer view based on the supplied arguments
  83725. * @param bufferIndex index value of the specified buffer
  83726. * @param byteOffset byte offset value
  83727. * @param byteLength byte length of the bufferView
  83728. * @param byteStride byte distance between conequential elements
  83729. * @param name name of the buffer view
  83730. * @returns bufferView for glTF
  83731. */
  83732. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  83733. /**
  83734. * Creates an accessor based on the supplied arguments
  83735. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  83736. * @param name The name of the accessor
  83737. * @param type The type of the accessor
  83738. * @param componentType The datatype of components in the attribute
  83739. * @param count The number of attributes referenced by this accessor
  83740. * @param byteOffset The offset relative to the start of the bufferView in bytes
  83741. * @param min Minimum value of each component in this attribute
  83742. * @param max Maximum value of each component in this attribute
  83743. * @returns accessor for glTF
  83744. */
  83745. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  83746. /**
  83747. * Calculates the minimum and maximum values of an array of position floats
  83748. * @param positions Positions array of a mesh
  83749. * @param vertexStart Starting vertex offset to calculate min and max values
  83750. * @param vertexCount Number of vertices to check for min and max values
  83751. * @returns min number array and max number array
  83752. */
  83753. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  83754. min: number[];
  83755. max: number[];
  83756. };
  83757. /**
  83758. * Converts a new right-handed Vector3
  83759. * @param vector vector3 array
  83760. * @returns right-handed Vector3
  83761. */
  83762. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  83763. /**
  83764. * Converts a Vector3 to right-handed
  83765. * @param vector Vector3 to convert to right-handed
  83766. */
  83767. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  83768. /**
  83769. * Converts a three element number array to right-handed
  83770. * @param vector number array to convert to right-handed
  83771. */
  83772. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  83773. /**
  83774. * Converts a new right-handed Vector3
  83775. * @param vector vector3 array
  83776. * @returns right-handed Vector3
  83777. */
  83778. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  83779. /**
  83780. * Converts a Vector3 to right-handed
  83781. * @param vector Vector3 to convert to right-handed
  83782. */
  83783. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  83784. /**
  83785. * Converts a three element number array to right-handed
  83786. * @param vector number array to convert to right-handed
  83787. */
  83788. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  83789. /**
  83790. * Converts a Vector4 to right-handed
  83791. * @param vector Vector4 to convert to right-handed
  83792. */
  83793. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  83794. /**
  83795. * Converts a Vector4 to right-handed
  83796. * @param vector Vector4 to convert to right-handed
  83797. */
  83798. static _GetRightHandedArray4FromRef(vector: number[]): void;
  83799. /**
  83800. * Converts a Quaternion to right-handed
  83801. * @param quaternion Source quaternion to convert to right-handed
  83802. */
  83803. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  83804. /**
  83805. * Converts a Quaternion to right-handed
  83806. * @param quaternion Source quaternion to convert to right-handed
  83807. */
  83808. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  83809. static _NormalizeTangentFromRef(tangent: Vector4): void;
  83810. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  83811. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  83812. }
  83813. }
  83814. declare module BABYLON.GLTF2.Exporter {
  83815. /**
  83816. * Converts Babylon Scene into glTF 2.0.
  83817. * @hidden
  83818. */
  83819. export class _Exporter {
  83820. /**
  83821. * Stores the glTF to export
  83822. */
  83823. _glTF: IGLTF;
  83824. /**
  83825. * Stores all generated buffer views, which represents views into the main glTF buffer data
  83826. */
  83827. _bufferViews: IBufferView[];
  83828. /**
  83829. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  83830. */
  83831. _accessors: IAccessor[];
  83832. /**
  83833. * Stores all the generated nodes, which contains transform and/or mesh information per node
  83834. */
  83835. _nodes: INode[];
  83836. /**
  83837. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  83838. */
  83839. private _scenes;
  83840. /**
  83841. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  83842. */
  83843. private _meshes;
  83844. /**
  83845. * Stores all the generated material information, which represents the appearance of each primitive
  83846. */
  83847. _materials: IMaterial[];
  83848. _materialMap: {
  83849. [materialID: number]: number;
  83850. };
  83851. /**
  83852. * Stores all the generated texture information, which is referenced by glTF materials
  83853. */
  83854. _textures: ITexture[];
  83855. /**
  83856. * Stores all the generated image information, which is referenced by glTF textures
  83857. */
  83858. _images: IImage[];
  83859. /**
  83860. * Stores all the texture samplers
  83861. */
  83862. _samplers: ISampler[];
  83863. /**
  83864. * Stores all the generated glTF skins
  83865. */
  83866. _skins: ISkin[];
  83867. /**
  83868. * Stores all the generated animation samplers, which is referenced by glTF animations
  83869. */
  83870. /**
  83871. * Stores the animations for glTF models
  83872. */
  83873. private _animations;
  83874. /**
  83875. * Stores the total amount of bytes stored in the glTF buffer
  83876. */
  83877. private _totalByteLength;
  83878. /**
  83879. * Stores a reference to the Babylon scene containing the source geometry and material information
  83880. */
  83881. _babylonScene: Scene;
  83882. /**
  83883. * Stores a map of the image data, where the key is the file name and the value
  83884. * is the image data
  83885. */
  83886. _imageData: {
  83887. [fileName: string]: {
  83888. data: Uint8Array;
  83889. mimeType: ImageMimeType;
  83890. };
  83891. };
  83892. protected _orderedImageData: Array<{
  83893. data: Uint8Array;
  83894. mimeType: ImageMimeType;
  83895. }>;
  83896. /**
  83897. * Stores a map of the unique id of a node to its index in the node array
  83898. */
  83899. _nodeMap: {
  83900. [key: number]: number;
  83901. };
  83902. /**
  83903. * Specifies if the source Babylon scene was left handed, and needed conversion.
  83904. */
  83905. _convertToRightHandedSystem: boolean;
  83906. /**
  83907. * Specifies if a Babylon node should be converted to right-handed on export
  83908. */
  83909. _convertToRightHandedSystemMap: {
  83910. [nodeId: number]: boolean;
  83911. };
  83912. _includeCoordinateSystemConversionNodes: boolean;
  83913. /**
  83914. * Baked animation sample rate
  83915. */
  83916. private _animationSampleRate;
  83917. private _options;
  83918. private _localEngine;
  83919. _glTFMaterialExporter: _GLTFMaterialExporter;
  83920. private _extensions;
  83921. private static _ExtensionNames;
  83922. private static _ExtensionFactories;
  83923. private _applyExtension;
  83924. private _applyExtensions;
  83925. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  83926. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  83927. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83928. [key: number]: number;
  83929. }): Promise<Nullable<INode>>;
  83930. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  83931. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  83932. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  83933. private _forEachExtensions;
  83934. private _extensionsOnExporting;
  83935. /**
  83936. * Load glTF serializer extensions
  83937. */
  83938. private _loadExtensions;
  83939. /**
  83940. * Creates a glTF Exporter instance, which can accept optional exporter options
  83941. * @param babylonScene Babylon scene object
  83942. * @param options Options to modify the behavior of the exporter
  83943. */
  83944. constructor(babylonScene: Scene, options?: IExportOptions);
  83945. dispose(): void;
  83946. /**
  83947. * Registers a glTF exporter extension
  83948. * @param name Name of the extension to export
  83949. * @param factory The factory function that creates the exporter extension
  83950. */
  83951. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  83952. /**
  83953. * Un-registers an exporter extension
  83954. * @param name The name fo the exporter extension
  83955. * @returns A boolean indicating whether the extension has been un-registered
  83956. */
  83957. static UnregisterExtension(name: string): boolean;
  83958. /**
  83959. * Lazy load a local engine
  83960. */
  83961. _getLocalEngine(): Engine;
  83962. private reorderIndicesBasedOnPrimitiveMode;
  83963. /**
  83964. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  83965. * clock-wise during export to glTF
  83966. * @param submesh BabylonJS submesh
  83967. * @param primitiveMode Primitive mode of the mesh
  83968. * @param sideOrientation the winding order of the submesh
  83969. * @param vertexBufferKind The type of vertex attribute
  83970. * @param meshAttributeArray The vertex attribute data
  83971. * @param byteOffset The offset to the binary data
  83972. * @param binaryWriter The binary data for the glTF file
  83973. * @param convertToRightHandedSystem Converts the values to right-handed
  83974. */
  83975. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  83976. /**
  83977. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  83978. * clock-wise during export to glTF
  83979. * @param submesh BabylonJS submesh
  83980. * @param primitiveMode Primitive mode of the mesh
  83981. * @param sideOrientation the winding order of the submesh
  83982. * @param vertexBufferKind The type of vertex attribute
  83983. * @param meshAttributeArray The vertex attribute data
  83984. * @param byteOffset The offset to the binary data
  83985. * @param binaryWriter The binary data for the glTF file
  83986. * @param convertToRightHandedSystem Converts the values to right-handed
  83987. */
  83988. private reorderTriangleFillMode;
  83989. /**
  83990. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  83991. * clock-wise during export to glTF
  83992. * @param submesh BabylonJS submesh
  83993. * @param primitiveMode Primitive mode of the mesh
  83994. * @param sideOrientation the winding order of the submesh
  83995. * @param vertexBufferKind The type of vertex attribute
  83996. * @param meshAttributeArray The vertex attribute data
  83997. * @param byteOffset The offset to the binary data
  83998. * @param binaryWriter The binary data for the glTF file
  83999. * @param convertToRightHandedSystem Converts the values to right-handed
  84000. */
  84001. private reorderTriangleStripDrawMode;
  84002. /**
  84003. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  84004. * clock-wise during export to glTF
  84005. * @param submesh BabylonJS submesh
  84006. * @param primitiveMode Primitive mode of the mesh
  84007. * @param sideOrientation the winding order of the submesh
  84008. * @param vertexBufferKind The type of vertex attribute
  84009. * @param meshAttributeArray The vertex attribute data
  84010. * @param byteOffset The offset to the binary data
  84011. * @param binaryWriter The binary data for the glTF file
  84012. * @param convertToRightHandedSystem Converts the values to right-handed
  84013. */
  84014. private reorderTriangleFanMode;
  84015. /**
  84016. * Writes the vertex attribute data to binary
  84017. * @param vertices The vertices to write to the binary writer
  84018. * @param byteOffset The offset into the binary writer to overwrite binary data
  84019. * @param vertexAttributeKind The vertex attribute type
  84020. * @param meshAttributeArray The vertex attribute data
  84021. * @param binaryWriter The writer containing the binary data
  84022. * @param convertToRightHandedSystem Converts the values to right-handed
  84023. */
  84024. private writeVertexAttributeData;
  84025. /**
  84026. * Writes mesh attribute data to a data buffer
  84027. * Returns the bytelength of the data
  84028. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84029. * @param meshAttributeArray Array containing the attribute data
  84030. * @param byteStride Specifies the space between data
  84031. * @param binaryWriter The buffer to write the binary data to
  84032. * @param convertToRightHandedSystem Converts the values to right-handed
  84033. */
  84034. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  84035. /**
  84036. * Writes mesh attribute data to a data buffer
  84037. * Returns the bytelength of the data
  84038. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84039. * @param meshAttributeArray Array containing the attribute data
  84040. * @param byteStride Specifies the space between data
  84041. * @param binaryWriter The buffer to write the binary data to
  84042. * @param convertToRightHandedSystem Converts the values to right-handed
  84043. */
  84044. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  84045. /**
  84046. * Generates glTF json data
  84047. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  84048. * @param glTFPrefix Text to use when prefixing a glTF file
  84049. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  84050. * @returns json data as string
  84051. */
  84052. private generateJSON;
  84053. /**
  84054. * Generates data for .gltf and .bin files based on the glTF prefix string
  84055. * @param glTFPrefix Text to use when prefixing a glTF file
  84056. * @param dispose Dispose the exporter
  84057. * @returns GLTFData with glTF file data
  84058. */
  84059. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84060. /**
  84061. * Creates a binary buffer for glTF
  84062. * @returns array buffer for binary data
  84063. */
  84064. private _generateBinaryAsync;
  84065. /**
  84066. * Pads the number to a multiple of 4
  84067. * @param num number to pad
  84068. * @returns padded number
  84069. */
  84070. private _getPadding;
  84071. /**
  84072. * @hidden
  84073. */
  84074. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84075. /**
  84076. * Sets the TRS for each node
  84077. * @param node glTF Node for storing the transformation data
  84078. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  84079. * @param convertToRightHandedSystem Converts the values to right-handed
  84080. */
  84081. private setNodeTransformation;
  84082. private getVertexBufferFromMesh;
  84083. /**
  84084. * Creates a bufferview based on the vertices type for the Babylon mesh
  84085. * @param kind Indicates the type of vertices data
  84086. * @param componentType Indicates the numerical type used to store the data
  84087. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  84088. * @param binaryWriter The buffer to write the bufferview data to
  84089. * @param convertToRightHandedSystem Converts the values to right-handed
  84090. */
  84091. private createBufferViewKind;
  84092. /**
  84093. * Creates a bufferview based on the vertices type for the Babylon mesh
  84094. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  84095. * @param babylonMorphTarget the morph target to be exported
  84096. * @param binaryWriter The buffer to write the bufferview data to
  84097. * @param convertToRightHandedSystem Converts the values to right-handed
  84098. */
  84099. private setMorphTargetAttributes;
  84100. /**
  84101. * The primitive mode of the Babylon mesh
  84102. * @param babylonMesh The BabylonJS mesh
  84103. */
  84104. private getMeshPrimitiveMode;
  84105. /**
  84106. * Sets the primitive mode of the glTF mesh primitive
  84107. * @param meshPrimitive glTF mesh primitive
  84108. * @param primitiveMode The primitive mode
  84109. */
  84110. private setPrimitiveMode;
  84111. /**
  84112. * Sets the vertex attribute accessor based of the glTF mesh primitive
  84113. * @param meshPrimitive glTF mesh primitive
  84114. * @param attributeKind vertex attribute
  84115. * @returns boolean specifying if uv coordinates are present
  84116. */
  84117. private setAttributeKind;
  84118. /**
  84119. * Sets data for the primitive attributes of each submesh
  84120. * @param mesh glTF Mesh object to store the primitive attribute information
  84121. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  84122. * @param binaryWriter Buffer to write the attribute data to
  84123. * @param convertToRightHandedSystem Converts the values to right-handed
  84124. */
  84125. private setPrimitiveAttributesAsync;
  84126. /**
  84127. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  84128. * @param node The node to check
  84129. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  84130. */
  84131. private isBabylonCoordinateSystemConvertingNode;
  84132. /**
  84133. * Creates a glTF scene based on the array of meshes
  84134. * Returns the the total byte offset
  84135. * @param babylonScene Babylon scene to get the mesh data from
  84136. * @param binaryWriter Buffer to write binary data to
  84137. */
  84138. private createSceneAsync;
  84139. /**
  84140. * Creates a mapping of Node unique id to node index and handles animations
  84141. * @param babylonScene Babylon Scene
  84142. * @param nodes Babylon transform nodes
  84143. * @param binaryWriter Buffer to write binary data to
  84144. * @returns Node mapping of unique id to index
  84145. */
  84146. private createNodeMapAndAnimationsAsync;
  84147. /**
  84148. * Creates a glTF node from a Babylon mesh
  84149. * @param babylonMesh Source Babylon mesh
  84150. * @param binaryWriter Buffer for storing geometry data
  84151. * @param convertToRightHandedSystem Converts the values to right-handed
  84152. * @param nodeMap Node mapping of unique id to glTF node index
  84153. * @returns glTF node
  84154. */
  84155. private createNodeAsync;
  84156. /**
  84157. * Creates a glTF skin from a Babylon skeleton
  84158. * @param babylonScene Babylon Scene
  84159. * @param nodes Babylon transform nodes
  84160. * @param binaryWriter Buffer to write binary data to
  84161. * @returns Node mapping of unique id to index
  84162. */
  84163. private createSkinsAsync;
  84164. }
  84165. /**
  84166. * @hidden
  84167. *
  84168. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  84169. */
  84170. export class _BinaryWriter {
  84171. /**
  84172. * Array buffer which stores all binary data
  84173. */
  84174. private _arrayBuffer;
  84175. /**
  84176. * View of the array buffer
  84177. */
  84178. private _dataView;
  84179. /**
  84180. * byte offset of data in array buffer
  84181. */
  84182. private _byteOffset;
  84183. /**
  84184. * Initialize binary writer with an initial byte length
  84185. * @param byteLength Initial byte length of the array buffer
  84186. */
  84187. constructor(byteLength: number);
  84188. /**
  84189. * Resize the array buffer to the specified byte length
  84190. * @param byteLength
  84191. */
  84192. private resizeBuffer;
  84193. /**
  84194. * Get an array buffer with the length of the byte offset
  84195. * @returns ArrayBuffer resized to the byte offset
  84196. */
  84197. getArrayBuffer(): ArrayBuffer;
  84198. /**
  84199. * Get the byte offset of the array buffer
  84200. * @returns byte offset
  84201. */
  84202. getByteOffset(): number;
  84203. /**
  84204. * Stores an UInt8 in the array buffer
  84205. * @param entry
  84206. * @param byteOffset If defined, specifies where to set the value as an offset.
  84207. */
  84208. setUInt8(entry: number, byteOffset?: number): void;
  84209. /**
  84210. * Stores an UInt16 in the array buffer
  84211. * @param entry
  84212. * @param byteOffset If defined, specifies where to set the value as an offset.
  84213. */
  84214. setUInt16(entry: number, byteOffset?: number): void;
  84215. /**
  84216. * Gets an UInt32 in the array buffer
  84217. * @param entry
  84218. * @param byteOffset If defined, specifies where to set the value as an offset.
  84219. */
  84220. getUInt32(byteOffset: number): number;
  84221. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  84222. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  84223. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  84224. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  84225. /**
  84226. * Stores a Float32 in the array buffer
  84227. * @param entry
  84228. */
  84229. setFloat32(entry: number, byteOffset?: number): void;
  84230. /**
  84231. * Stores an UInt32 in the array buffer
  84232. * @param entry
  84233. * @param byteOffset If defined, specifies where to set the value as an offset.
  84234. */
  84235. setUInt32(entry: number, byteOffset?: number): void;
  84236. }
  84237. }
  84238. declare module BABYLON.GLTF2.Exporter {
  84239. /**
  84240. * @hidden
  84241. * Interface to store animation data.
  84242. */
  84243. export interface _IAnimationData {
  84244. /**
  84245. * Keyframe data.
  84246. */
  84247. inputs: number[];
  84248. /**
  84249. * Value data.
  84250. */
  84251. outputs: number[][];
  84252. /**
  84253. * Animation interpolation data.
  84254. */
  84255. samplerInterpolation: AnimationSamplerInterpolation;
  84256. /**
  84257. * Minimum keyframe value.
  84258. */
  84259. inputsMin: number;
  84260. /**
  84261. * Maximum keyframe value.
  84262. */
  84263. inputsMax: number;
  84264. }
  84265. /**
  84266. * @hidden
  84267. */
  84268. export interface _IAnimationInfo {
  84269. /**
  84270. * The target channel for the animation
  84271. */
  84272. animationChannelTargetPath: AnimationChannelTargetPath;
  84273. /**
  84274. * The glTF accessor type for the data.
  84275. */
  84276. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  84277. /**
  84278. * Specifies if quaternions should be used.
  84279. */
  84280. useQuaternion: boolean;
  84281. }
  84282. /**
  84283. * @hidden
  84284. * Utility class for generating glTF animation data from BabylonJS.
  84285. */
  84286. export class _GLTFAnimation {
  84287. /**
  84288. * @ignore
  84289. *
  84290. * Creates glTF channel animation from BabylonJS animation.
  84291. * @param babylonTransformNode - BabylonJS mesh.
  84292. * @param animation - animation.
  84293. * @param animationChannelTargetPath - The target animation channel.
  84294. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  84295. * @param useQuaternion - Specifies if quaternions are used.
  84296. * @returns nullable IAnimationData
  84297. */
  84298. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  84299. private static _DeduceAnimationInfo;
  84300. /**
  84301. * @ignore
  84302. * Create node animations from the transform node animations
  84303. * @param babylonNode
  84304. * @param runtimeGLTFAnimation
  84305. * @param idleGLTFAnimations
  84306. * @param nodeMap
  84307. * @param nodes
  84308. * @param binaryWriter
  84309. * @param bufferViews
  84310. * @param accessors
  84311. * @param convertToRightHandedSystem
  84312. * @param animationSampleRate
  84313. */
  84314. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  84315. [key: number]: number;
  84316. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  84317. /**
  84318. * @ignore
  84319. * Create individual morph animations from the mesh's morph target animation tracks
  84320. * @param babylonNode
  84321. * @param runtimeGLTFAnimation
  84322. * @param idleGLTFAnimations
  84323. * @param nodeMap
  84324. * @param nodes
  84325. * @param binaryWriter
  84326. * @param bufferViews
  84327. * @param accessors
  84328. * @param convertToRightHandedSystem
  84329. * @param animationSampleRate
  84330. */
  84331. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  84332. [key: number]: number;
  84333. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  84334. /**
  84335. * @ignore
  84336. * Create node and morph animations from the animation groups
  84337. * @param babylonScene
  84338. * @param glTFAnimations
  84339. * @param nodeMap
  84340. * @param nodes
  84341. * @param binaryWriter
  84342. * @param bufferViews
  84343. * @param accessors
  84344. * @param convertToRightHandedSystemMap
  84345. * @param animationSampleRate
  84346. */
  84347. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  84348. [key: number]: number;
  84349. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  84350. [nodeId: number]: boolean;
  84351. }, animationSampleRate: number): void;
  84352. private static AddAnimation;
  84353. /**
  84354. * Create a baked animation
  84355. * @param babylonTransformNode BabylonJS mesh
  84356. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  84357. * @param animationChannelTargetPath animation target channel
  84358. * @param minFrame minimum animation frame
  84359. * @param maxFrame maximum animation frame
  84360. * @param fps frames per second of the animation
  84361. * @param inputs input key frames of the animation
  84362. * @param outputs output key frame data of the animation
  84363. * @param convertToRightHandedSystem converts the values to right-handed
  84364. * @param useQuaternion specifies if quaternions should be used
  84365. */
  84366. private static _CreateBakedAnimation;
  84367. private static _ConvertFactorToVector3OrQuaternion;
  84368. private static _SetInterpolatedValue;
  84369. /**
  84370. * Creates linear animation from the animation key frames
  84371. * @param babylonTransformNode BabylonJS mesh
  84372. * @param animation BabylonJS animation
  84373. * @param animationChannelTargetPath The target animation channel
  84374. * @param frameDelta The difference between the last and first frame of the animation
  84375. * @param inputs Array to store the key frame times
  84376. * @param outputs Array to store the key frame data
  84377. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84378. * @param useQuaternion Specifies if quaternions are used in the animation
  84379. */
  84380. private static _CreateLinearOrStepAnimation;
  84381. /**
  84382. * Creates cubic spline animation from the animation key frames
  84383. * @param babylonTransformNode BabylonJS mesh
  84384. * @param animation BabylonJS animation
  84385. * @param animationChannelTargetPath The target animation channel
  84386. * @param frameDelta The difference between the last and first frame of the animation
  84387. * @param inputs Array to store the key frame times
  84388. * @param outputs Array to store the key frame data
  84389. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84390. * @param useQuaternion Specifies if quaternions are used in the animation
  84391. */
  84392. private static _CreateCubicSplineAnimation;
  84393. private static _GetBasePositionRotationOrScale;
  84394. /**
  84395. * Adds a key frame value
  84396. * @param keyFrame
  84397. * @param animation
  84398. * @param outputs
  84399. * @param animationChannelTargetPath
  84400. * @param basePositionRotationOrScale
  84401. * @param convertToRightHandedSystem
  84402. * @param useQuaternion
  84403. */
  84404. private static _AddKeyframeValue;
  84405. /**
  84406. * Determine the interpolation based on the key frames
  84407. * @param keyFrames
  84408. * @param animationChannelTargetPath
  84409. * @param useQuaternion
  84410. */
  84411. private static _DeduceInterpolation;
  84412. /**
  84413. * Adds an input tangent or output tangent to the output data
  84414. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  84415. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  84416. * @param outputs The animation data by keyframe
  84417. * @param animationChannelTargetPath The target animation channel
  84418. * @param interpolation The interpolation type
  84419. * @param keyFrame The key frame with the animation data
  84420. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  84421. * @param useQuaternion Specifies if quaternions are used
  84422. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  84423. */
  84424. private static AddSplineTangent;
  84425. /**
  84426. * Get the minimum and maximum key frames' frame values
  84427. * @param keyFrames animation key frames
  84428. * @returns the minimum and maximum key frame value
  84429. */
  84430. private static calculateMinMaxKeyFrames;
  84431. }
  84432. }
  84433. declare module BABYLON.GLTF2.Exporter {
  84434. /** @hidden */
  84435. export var textureTransformPixelShader: {
  84436. name: string;
  84437. shader: string;
  84438. };
  84439. }
  84440. declare module BABYLON.GLTF2.Exporter.Extensions {
  84441. /**
  84442. * @hidden
  84443. */
  84444. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  84445. private _recordedTextures;
  84446. /** Name of this extension */
  84447. readonly name: string;
  84448. /** Defines whether this extension is enabled */
  84449. enabled: boolean;
  84450. /** Defines whether this extension is required */
  84451. required: boolean;
  84452. /** Reference to the glTF exporter */
  84453. private _wasUsed;
  84454. constructor(exporter: _Exporter);
  84455. dispose(): void;
  84456. /** @hidden */
  84457. get wasUsed(): boolean;
  84458. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  84459. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  84460. /**
  84461. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  84462. * @param babylonTexture
  84463. * @param offset
  84464. * @param rotation
  84465. * @param scale
  84466. * @param scene
  84467. */
  84468. private _textureTransformTextureAsync;
  84469. }
  84470. }
  84471. declare module BABYLON.GLTF2.Exporter.Extensions {
  84472. /**
  84473. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  84474. */
  84475. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  84476. /** The name of this extension. */
  84477. readonly name: string;
  84478. /** Defines whether this extension is enabled. */
  84479. enabled: boolean;
  84480. /** Defines whether this extension is required */
  84481. required: boolean;
  84482. /** Reference to the glTF exporter */
  84483. private _exporter;
  84484. private _lights;
  84485. /** @hidden */
  84486. constructor(exporter: _Exporter);
  84487. /** @hidden */
  84488. dispose(): void;
  84489. /** @hidden */
  84490. get wasUsed(): boolean;
  84491. /** @hidden */
  84492. onExporting(): void;
  84493. /**
  84494. * Define this method to modify the default behavior when exporting a node
  84495. * @param context The context when exporting the node
  84496. * @param node glTF node
  84497. * @param babylonNode BabylonJS node
  84498. * @param nodeMap Node mapping of unique id to glTF node index
  84499. * @returns nullable INode promise
  84500. */
  84501. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84502. [key: number]: number;
  84503. }): Promise<Nullable<INode>>;
  84504. }
  84505. }
  84506. declare module BABYLON.GLTF2.Exporter.Extensions {
  84507. /**
  84508. * @hidden
  84509. */
  84510. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  84511. /** Name of this extension */
  84512. readonly name: string;
  84513. /** Defines whether this extension is enabled */
  84514. enabled: boolean;
  84515. /** Defines whether this extension is required */
  84516. required: boolean;
  84517. /** Reference to the glTF exporter */
  84518. private _textureInfos;
  84519. private _exportedTextures;
  84520. private _wasUsed;
  84521. constructor(exporter: _Exporter);
  84522. dispose(): void;
  84523. /** @hidden */
  84524. get wasUsed(): boolean;
  84525. private _getTextureIndex;
  84526. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  84527. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84528. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  84529. }
  84530. }
  84531. declare module BABYLON.GLTF2.Exporter.Extensions {
  84532. /**
  84533. * @hidden
  84534. */
  84535. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  84536. /** Name of this extension */
  84537. readonly name: string;
  84538. /** Defines whether this extension is enabled */
  84539. enabled: boolean;
  84540. /** Defines whether this extension is required */
  84541. required: boolean;
  84542. private _wasUsed;
  84543. constructor(exporter: _Exporter);
  84544. /** @hidden */
  84545. get wasUsed(): boolean;
  84546. dispose(): void;
  84547. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  84548. }
  84549. }
  84550. declare module BABYLON {
  84551. /**
  84552. * Class for generating STL data from a Babylon scene.
  84553. */
  84554. export class STLExport {
  84555. /**
  84556. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  84557. * @param meshes list defines the mesh to serialize
  84558. * @param download triggers the automatic download of the file.
  84559. * @param fileName changes the downloads fileName.
  84560. * @param binary changes the STL to a binary type.
  84561. * @param isLittleEndian toggle for binary type exporter.
  84562. * @returns the STL as UTF8 string
  84563. */
  84564. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  84565. }
  84566. }
  84567. declare module "babylonjs-gltf2interface" {
  84568. export = BABYLON.GLTF2;
  84569. }
  84570. /**
  84571. * Module for glTF 2.0 Interface
  84572. */
  84573. declare module BABYLON.GLTF2 {
  84574. /**
  84575. * The datatype of the components in the attribute
  84576. */
  84577. const enum AccessorComponentType {
  84578. /**
  84579. * Byte
  84580. */
  84581. BYTE = 5120,
  84582. /**
  84583. * Unsigned Byte
  84584. */
  84585. UNSIGNED_BYTE = 5121,
  84586. /**
  84587. * Short
  84588. */
  84589. SHORT = 5122,
  84590. /**
  84591. * Unsigned Short
  84592. */
  84593. UNSIGNED_SHORT = 5123,
  84594. /**
  84595. * Unsigned Int
  84596. */
  84597. UNSIGNED_INT = 5125,
  84598. /**
  84599. * Float
  84600. */
  84601. FLOAT = 5126,
  84602. }
  84603. /**
  84604. * Specifies if the attirbute is a scalar, vector, or matrix
  84605. */
  84606. const enum AccessorType {
  84607. /**
  84608. * Scalar
  84609. */
  84610. SCALAR = "SCALAR",
  84611. /**
  84612. * Vector2
  84613. */
  84614. VEC2 = "VEC2",
  84615. /**
  84616. * Vector3
  84617. */
  84618. VEC3 = "VEC3",
  84619. /**
  84620. * Vector4
  84621. */
  84622. VEC4 = "VEC4",
  84623. /**
  84624. * Matrix2x2
  84625. */
  84626. MAT2 = "MAT2",
  84627. /**
  84628. * Matrix3x3
  84629. */
  84630. MAT3 = "MAT3",
  84631. /**
  84632. * Matrix4x4
  84633. */
  84634. MAT4 = "MAT4",
  84635. }
  84636. /**
  84637. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  84638. */
  84639. const enum AnimationChannelTargetPath {
  84640. /**
  84641. * Translation
  84642. */
  84643. TRANSLATION = "translation",
  84644. /**
  84645. * Rotation
  84646. */
  84647. ROTATION = "rotation",
  84648. /**
  84649. * Scale
  84650. */
  84651. SCALE = "scale",
  84652. /**
  84653. * Weights
  84654. */
  84655. WEIGHTS = "weights",
  84656. }
  84657. /**
  84658. * Interpolation algorithm
  84659. */
  84660. const enum AnimationSamplerInterpolation {
  84661. /**
  84662. * The animated values are linearly interpolated between keyframes
  84663. */
  84664. LINEAR = "LINEAR",
  84665. /**
  84666. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  84667. */
  84668. STEP = "STEP",
  84669. /**
  84670. * The animation's interpolation is computed using a cubic spline with specified tangents
  84671. */
  84672. CUBICSPLINE = "CUBICSPLINE",
  84673. }
  84674. /**
  84675. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  84676. */
  84677. const enum CameraType {
  84678. /**
  84679. * A perspective camera containing properties to create a perspective projection matrix
  84680. */
  84681. PERSPECTIVE = "perspective",
  84682. /**
  84683. * An orthographic camera containing properties to create an orthographic projection matrix
  84684. */
  84685. ORTHOGRAPHIC = "orthographic",
  84686. }
  84687. /**
  84688. * The mime-type of the image
  84689. */
  84690. const enum ImageMimeType {
  84691. /**
  84692. * JPEG Mime-type
  84693. */
  84694. JPEG = "image/jpeg",
  84695. /**
  84696. * PNG Mime-type
  84697. */
  84698. PNG = "image/png",
  84699. }
  84700. /**
  84701. * The alpha rendering mode of the material
  84702. */
  84703. const enum MaterialAlphaMode {
  84704. /**
  84705. * The alpha value is ignored and the rendered output is fully opaque
  84706. */
  84707. OPAQUE = "OPAQUE",
  84708. /**
  84709. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  84710. */
  84711. MASK = "MASK",
  84712. /**
  84713. * 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)
  84714. */
  84715. BLEND = "BLEND",
  84716. }
  84717. /**
  84718. * The type of the primitives to render
  84719. */
  84720. const enum MeshPrimitiveMode {
  84721. /**
  84722. * Points
  84723. */
  84724. POINTS = 0,
  84725. /**
  84726. * Lines
  84727. */
  84728. LINES = 1,
  84729. /**
  84730. * Line Loop
  84731. */
  84732. LINE_LOOP = 2,
  84733. /**
  84734. * Line Strip
  84735. */
  84736. LINE_STRIP = 3,
  84737. /**
  84738. * Triangles
  84739. */
  84740. TRIANGLES = 4,
  84741. /**
  84742. * Triangle Strip
  84743. */
  84744. TRIANGLE_STRIP = 5,
  84745. /**
  84746. * Triangle Fan
  84747. */
  84748. TRIANGLE_FAN = 6,
  84749. }
  84750. /**
  84751. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  84752. */
  84753. const enum TextureMagFilter {
  84754. /**
  84755. * Nearest
  84756. */
  84757. NEAREST = 9728,
  84758. /**
  84759. * Linear
  84760. */
  84761. LINEAR = 9729,
  84762. }
  84763. /**
  84764. * Minification filter. All valid values correspond to WebGL enums
  84765. */
  84766. const enum TextureMinFilter {
  84767. /**
  84768. * Nearest
  84769. */
  84770. NEAREST = 9728,
  84771. /**
  84772. * Linear
  84773. */
  84774. LINEAR = 9729,
  84775. /**
  84776. * Nearest Mip-Map Nearest
  84777. */
  84778. NEAREST_MIPMAP_NEAREST = 9984,
  84779. /**
  84780. * Linear Mipmap Nearest
  84781. */
  84782. LINEAR_MIPMAP_NEAREST = 9985,
  84783. /**
  84784. * Nearest Mipmap Linear
  84785. */
  84786. NEAREST_MIPMAP_LINEAR = 9986,
  84787. /**
  84788. * Linear Mipmap Linear
  84789. */
  84790. LINEAR_MIPMAP_LINEAR = 9987,
  84791. }
  84792. /**
  84793. * S (U) wrapping mode. All valid values correspond to WebGL enums
  84794. */
  84795. const enum TextureWrapMode {
  84796. /**
  84797. * Clamp to Edge
  84798. */
  84799. CLAMP_TO_EDGE = 33071,
  84800. /**
  84801. * Mirrored Repeat
  84802. */
  84803. MIRRORED_REPEAT = 33648,
  84804. /**
  84805. * Repeat
  84806. */
  84807. REPEAT = 10497,
  84808. }
  84809. /**
  84810. * glTF Property
  84811. */
  84812. interface IProperty {
  84813. /**
  84814. * Dictionary object with extension-specific objects
  84815. */
  84816. extensions?: {
  84817. [key: string]: any;
  84818. };
  84819. /**
  84820. * Application-Specific data
  84821. */
  84822. extras?: any;
  84823. }
  84824. /**
  84825. * glTF Child of Root Property
  84826. */
  84827. interface IChildRootProperty extends IProperty {
  84828. /**
  84829. * The user-defined name of this object
  84830. */
  84831. name?: string;
  84832. }
  84833. /**
  84834. * Indices of those attributes that deviate from their initialization value
  84835. */
  84836. interface IAccessorSparseIndices extends IProperty {
  84837. /**
  84838. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  84839. */
  84840. bufferView: number;
  84841. /**
  84842. * The offset relative to the start of the bufferView in bytes. Must be aligned
  84843. */
  84844. byteOffset?: number;
  84845. /**
  84846. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  84847. */
  84848. componentType: AccessorComponentType;
  84849. }
  84850. /**
  84851. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  84852. */
  84853. interface IAccessorSparseValues extends IProperty {
  84854. /**
  84855. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  84856. */
  84857. bufferView: number;
  84858. /**
  84859. * The offset relative to the start of the bufferView in bytes. Must be aligned
  84860. */
  84861. byteOffset?: number;
  84862. }
  84863. /**
  84864. * Sparse storage of attributes that deviate from their initialization value
  84865. */
  84866. interface IAccessorSparse extends IProperty {
  84867. /**
  84868. * The number of attributes encoded in this sparse accessor
  84869. */
  84870. count: number;
  84871. /**
  84872. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  84873. */
  84874. indices: IAccessorSparseIndices;
  84875. /**
  84876. * 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
  84877. */
  84878. values: IAccessorSparseValues;
  84879. }
  84880. /**
  84881. * 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
  84882. */
  84883. interface IAccessor extends IChildRootProperty {
  84884. /**
  84885. * The index of the bufferview
  84886. */
  84887. bufferView?: number;
  84888. /**
  84889. * The offset relative to the start of the bufferView in bytes
  84890. */
  84891. byteOffset?: number;
  84892. /**
  84893. * The datatype of components in the attribute
  84894. */
  84895. componentType: AccessorComponentType;
  84896. /**
  84897. * Specifies whether integer data values should be normalized
  84898. */
  84899. normalized?: boolean;
  84900. /**
  84901. * The number of attributes referenced by this accessor
  84902. */
  84903. count: number;
  84904. /**
  84905. * Specifies if the attribute is a scalar, vector, or matrix
  84906. */
  84907. type: AccessorType;
  84908. /**
  84909. * Maximum value of each component in this attribute
  84910. */
  84911. max?: number[];
  84912. /**
  84913. * Minimum value of each component in this attribute
  84914. */
  84915. min?: number[];
  84916. /**
  84917. * Sparse storage of attributes that deviate from their initialization value
  84918. */
  84919. sparse?: IAccessorSparse;
  84920. }
  84921. /**
  84922. * Targets an animation's sampler at a node's property
  84923. */
  84924. interface IAnimationChannel extends IProperty {
  84925. /**
  84926. * The index of a sampler in this animation used to compute the value for the target
  84927. */
  84928. sampler: number;
  84929. /**
  84930. * The index of the node and TRS property to target
  84931. */
  84932. target: IAnimationChannelTarget;
  84933. }
  84934. /**
  84935. * The index of the node and TRS property that an animation channel targets
  84936. */
  84937. interface IAnimationChannelTarget extends IProperty {
  84938. /**
  84939. * The index of the node to target
  84940. */
  84941. node: number;
  84942. /**
  84943. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  84944. */
  84945. path: AnimationChannelTargetPath;
  84946. }
  84947. /**
  84948. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  84949. */
  84950. interface IAnimationSampler extends IProperty {
  84951. /**
  84952. * The index of an accessor containing keyframe input values, e.g., time
  84953. */
  84954. input: number;
  84955. /**
  84956. * Interpolation algorithm
  84957. */
  84958. interpolation?: AnimationSamplerInterpolation;
  84959. /**
  84960. * The index of an accessor, containing keyframe output values
  84961. */
  84962. output: number;
  84963. }
  84964. /**
  84965. * A keyframe animation
  84966. */
  84967. interface IAnimation extends IChildRootProperty {
  84968. /**
  84969. * An array of channels, each of which targets an animation's sampler at a node's property
  84970. */
  84971. channels: IAnimationChannel[];
  84972. /**
  84973. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  84974. */
  84975. samplers: IAnimationSampler[];
  84976. }
  84977. /**
  84978. * Metadata about the glTF asset
  84979. */
  84980. interface IAsset extends IChildRootProperty {
  84981. /**
  84982. * A copyright message suitable for display to credit the content creator
  84983. */
  84984. copyright?: string;
  84985. /**
  84986. * Tool that generated this glTF model. Useful for debugging
  84987. */
  84988. generator?: string;
  84989. /**
  84990. * The glTF version that this asset targets
  84991. */
  84992. version: string;
  84993. /**
  84994. * The minimum glTF version that this asset targets
  84995. */
  84996. minVersion?: string;
  84997. }
  84998. /**
  84999. * A buffer points to binary geometry, animation, or skins
  85000. */
  85001. interface IBuffer extends IChildRootProperty {
  85002. /**
  85003. * 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
  85004. */
  85005. uri?: string;
  85006. /**
  85007. * The length of the buffer in bytes
  85008. */
  85009. byteLength: number;
  85010. }
  85011. /**
  85012. * A view into a buffer generally representing a subset of the buffer
  85013. */
  85014. interface IBufferView extends IChildRootProperty {
  85015. /**
  85016. * The index of the buffer
  85017. */
  85018. buffer: number;
  85019. /**
  85020. * The offset into the buffer in bytes
  85021. */
  85022. byteOffset?: number;
  85023. /**
  85024. * The lenth of the bufferView in bytes
  85025. */
  85026. byteLength: number;
  85027. /**
  85028. * The stride, in bytes
  85029. */
  85030. byteStride?: number;
  85031. }
  85032. /**
  85033. * An orthographic camera containing properties to create an orthographic projection matrix
  85034. */
  85035. interface ICameraOrthographic extends IProperty {
  85036. /**
  85037. * The floating-point horizontal magnification of the view. Must not be zero
  85038. */
  85039. xmag: number;
  85040. /**
  85041. * The floating-point vertical magnification of the view. Must not be zero
  85042. */
  85043. ymag: number;
  85044. /**
  85045. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  85046. */
  85047. zfar: number;
  85048. /**
  85049. * The floating-point distance to the near clipping plane
  85050. */
  85051. znear: number;
  85052. }
  85053. /**
  85054. * A perspective camera containing properties to create a perspective projection matrix
  85055. */
  85056. interface ICameraPerspective extends IProperty {
  85057. /**
  85058. * The floating-point aspect ratio of the field of view
  85059. */
  85060. aspectRatio?: number;
  85061. /**
  85062. * The floating-point vertical field of view in radians
  85063. */
  85064. yfov: number;
  85065. /**
  85066. * The floating-point distance to the far clipping plane
  85067. */
  85068. zfar?: number;
  85069. /**
  85070. * The floating-point distance to the near clipping plane
  85071. */
  85072. znear: number;
  85073. }
  85074. /**
  85075. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85076. */
  85077. interface ICamera extends IChildRootProperty {
  85078. /**
  85079. * An orthographic camera containing properties to create an orthographic projection matrix
  85080. */
  85081. orthographic?: ICameraOrthographic;
  85082. /**
  85083. * A perspective camera containing properties to create a perspective projection matrix
  85084. */
  85085. perspective?: ICameraPerspective;
  85086. /**
  85087. * Specifies if the camera uses a perspective or orthographic projection
  85088. */
  85089. type: CameraType;
  85090. }
  85091. /**
  85092. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  85093. */
  85094. interface IImage extends IChildRootProperty {
  85095. /**
  85096. * 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
  85097. */
  85098. uri?: string;
  85099. /**
  85100. * The image's MIME type
  85101. */
  85102. mimeType?: ImageMimeType;
  85103. /**
  85104. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  85105. */
  85106. bufferView?: number;
  85107. }
  85108. /**
  85109. * Material Normal Texture Info
  85110. */
  85111. interface IMaterialNormalTextureInfo extends ITextureInfo {
  85112. /**
  85113. * The scalar multiplier applied to each normal vector of the normal texture
  85114. */
  85115. scale?: number;
  85116. }
  85117. /**
  85118. * Material Occlusion Texture Info
  85119. */
  85120. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  85121. /**
  85122. * A scalar multiplier controlling the amount of occlusion applied
  85123. */
  85124. strength?: number;
  85125. }
  85126. /**
  85127. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  85128. */
  85129. interface IMaterialPbrMetallicRoughness {
  85130. /**
  85131. * The material's base color factor
  85132. */
  85133. baseColorFactor?: number[];
  85134. /**
  85135. * The base color texture
  85136. */
  85137. baseColorTexture?: ITextureInfo;
  85138. /**
  85139. * The metalness of the material
  85140. */
  85141. metallicFactor?: number;
  85142. /**
  85143. * The roughness of the material
  85144. */
  85145. roughnessFactor?: number;
  85146. /**
  85147. * The metallic-roughness texture
  85148. */
  85149. metallicRoughnessTexture?: ITextureInfo;
  85150. }
  85151. /**
  85152. * The material appearance of a primitive
  85153. */
  85154. interface IMaterial extends IChildRootProperty {
  85155. /**
  85156. * 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
  85157. */
  85158. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  85159. /**
  85160. * The normal map texture
  85161. */
  85162. normalTexture?: IMaterialNormalTextureInfo;
  85163. /**
  85164. * The occlusion map texture
  85165. */
  85166. occlusionTexture?: IMaterialOcclusionTextureInfo;
  85167. /**
  85168. * The emissive map texture
  85169. */
  85170. emissiveTexture?: ITextureInfo;
  85171. /**
  85172. * 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
  85173. */
  85174. emissiveFactor?: number[];
  85175. /**
  85176. * The alpha rendering mode of the material
  85177. */
  85178. alphaMode?: MaterialAlphaMode;
  85179. /**
  85180. * The alpha cutoff value of the material
  85181. */
  85182. alphaCutoff?: number;
  85183. /**
  85184. * Specifies whether the material is double sided
  85185. */
  85186. doubleSided?: boolean;
  85187. }
  85188. /**
  85189. * Geometry to be rendered with the given material
  85190. */
  85191. interface IMeshPrimitive extends IProperty {
  85192. /**
  85193. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  85194. */
  85195. attributes: {
  85196. [name: string]: number;
  85197. };
  85198. /**
  85199. * The index of the accessor that contains the indices
  85200. */
  85201. indices?: number;
  85202. /**
  85203. * The index of the material to apply to this primitive when rendering
  85204. */
  85205. material?: number;
  85206. /**
  85207. * The type of primitives to render. All valid values correspond to WebGL enums
  85208. */
  85209. mode?: MeshPrimitiveMode;
  85210. /**
  85211. * 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
  85212. */
  85213. targets?: {
  85214. [name: string]: number;
  85215. }[];
  85216. }
  85217. /**
  85218. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  85219. */
  85220. interface IMesh extends IChildRootProperty {
  85221. /**
  85222. * An array of primitives, each defining geometry to be rendered with a material
  85223. */
  85224. primitives: IMeshPrimitive[];
  85225. /**
  85226. * Array of weights to be applied to the Morph Targets
  85227. */
  85228. weights?: number[];
  85229. }
  85230. /**
  85231. * A node in the node hierarchy
  85232. */
  85233. interface INode extends IChildRootProperty {
  85234. /**
  85235. * The index of the camera referenced by this node
  85236. */
  85237. camera?: number;
  85238. /**
  85239. * The indices of this node's children
  85240. */
  85241. children?: number[];
  85242. /**
  85243. * The index of the skin referenced by this node
  85244. */
  85245. skin?: number;
  85246. /**
  85247. * A floating-point 4x4 transformation matrix stored in column-major order
  85248. */
  85249. matrix?: number[];
  85250. /**
  85251. * The index of the mesh in this node
  85252. */
  85253. mesh?: number;
  85254. /**
  85255. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  85256. */
  85257. rotation?: number[];
  85258. /**
  85259. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  85260. */
  85261. scale?: number[];
  85262. /**
  85263. * The node's translation along the x, y, and z axes
  85264. */
  85265. translation?: number[];
  85266. /**
  85267. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  85268. */
  85269. weights?: number[];
  85270. }
  85271. /**
  85272. * Texture sampler properties for filtering and wrapping modes
  85273. */
  85274. interface ISampler extends IChildRootProperty {
  85275. /**
  85276. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85277. */
  85278. magFilter?: TextureMagFilter;
  85279. /**
  85280. * Minification filter. All valid values correspond to WebGL enums
  85281. */
  85282. minFilter?: TextureMinFilter;
  85283. /**
  85284. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85285. */
  85286. wrapS?: TextureWrapMode;
  85287. /**
  85288. * T (V) wrapping mode. All valid values correspond to WebGL enums
  85289. */
  85290. wrapT?: TextureWrapMode;
  85291. }
  85292. /**
  85293. * The root nodes of a scene
  85294. */
  85295. interface IScene extends IChildRootProperty {
  85296. /**
  85297. * The indices of each root node
  85298. */
  85299. nodes: number[];
  85300. }
  85301. /**
  85302. * Joints and matrices defining a skin
  85303. */
  85304. interface ISkin extends IChildRootProperty {
  85305. /**
  85306. * 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
  85307. */
  85308. inverseBindMatrices?: number;
  85309. /**
  85310. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  85311. */
  85312. skeleton?: number;
  85313. /**
  85314. * 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)
  85315. */
  85316. joints: number[];
  85317. }
  85318. /**
  85319. * A texture and its sampler
  85320. */
  85321. interface ITexture extends IChildRootProperty {
  85322. /**
  85323. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  85324. */
  85325. sampler?: number;
  85326. /**
  85327. * The index of the image used by this texture
  85328. */
  85329. source: number;
  85330. }
  85331. /**
  85332. * Reference to a texture
  85333. */
  85334. interface ITextureInfo extends IProperty {
  85335. /**
  85336. * The index of the texture
  85337. */
  85338. index: number;
  85339. /**
  85340. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  85341. */
  85342. texCoord?: number;
  85343. }
  85344. /**
  85345. * The root object for a glTF asset
  85346. */
  85347. interface IGLTF extends IProperty {
  85348. /**
  85349. * An array of accessors. An accessor is a typed view into a bufferView
  85350. */
  85351. accessors?: IAccessor[];
  85352. /**
  85353. * An array of keyframe animations
  85354. */
  85355. animations?: IAnimation[];
  85356. /**
  85357. * Metadata about the glTF asset
  85358. */
  85359. asset: IAsset;
  85360. /**
  85361. * An array of buffers. A buffer points to binary geometry, animation, or skins
  85362. */
  85363. buffers?: IBuffer[];
  85364. /**
  85365. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  85366. */
  85367. bufferViews?: IBufferView[];
  85368. /**
  85369. * An array of cameras
  85370. */
  85371. cameras?: ICamera[];
  85372. /**
  85373. * Names of glTF extensions used somewhere in this asset
  85374. */
  85375. extensionsUsed?: string[];
  85376. /**
  85377. * Names of glTF extensions required to properly load this asset
  85378. */
  85379. extensionsRequired?: string[];
  85380. /**
  85381. * An array of images. An image defines data used to create a texture
  85382. */
  85383. images?: IImage[];
  85384. /**
  85385. * An array of materials. A material defines the appearance of a primitive
  85386. */
  85387. materials?: IMaterial[];
  85388. /**
  85389. * An array of meshes. A mesh is a set of primitives to be rendered
  85390. */
  85391. meshes?: IMesh[];
  85392. /**
  85393. * An array of nodes
  85394. */
  85395. nodes?: INode[];
  85396. /**
  85397. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  85398. */
  85399. samplers?: ISampler[];
  85400. /**
  85401. * The index of the default scene
  85402. */
  85403. scene?: number;
  85404. /**
  85405. * An array of scenes
  85406. */
  85407. scenes?: IScene[];
  85408. /**
  85409. * An array of skins. A skin is defined by joints and matrices
  85410. */
  85411. skins?: ISkin[];
  85412. /**
  85413. * An array of textures
  85414. */
  85415. textures?: ITexture[];
  85416. }
  85417. /**
  85418. * The glTF validation results
  85419. * @ignore
  85420. */
  85421. interface IGLTFValidationResults {
  85422. info: {
  85423. generator: string;
  85424. hasAnimations: boolean;
  85425. hasDefaultScene: boolean;
  85426. hasMaterials: boolean;
  85427. hasMorphTargets: boolean;
  85428. hasSkins: boolean;
  85429. hasTextures: boolean;
  85430. maxAttributesUsed: number;
  85431. primitivesCount: number
  85432. };
  85433. issues: {
  85434. messages: Array<string>;
  85435. numErrors: number;
  85436. numHints: number;
  85437. numInfos: number;
  85438. numWarnings: number;
  85439. truncated: boolean
  85440. };
  85441. mimeType: string;
  85442. uri: string;
  85443. validatedAt: string;
  85444. validatorVersion: string;
  85445. }
  85446. /**
  85447. * The glTF validation options
  85448. */
  85449. interface IGLTFValidationOptions {
  85450. /** Uri to use */
  85451. uri?: string;
  85452. /** Function used to load external resources */
  85453. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  85454. /** Boolean indicating that we need to validate accessor data */
  85455. validateAccessorData?: boolean;
  85456. /** max number of issues allowed */
  85457. maxIssues?: number;
  85458. /** Ignored issues */
  85459. ignoredIssues?: Array<string>;
  85460. /** Value to override severy settings */
  85461. severityOverrides?: Object;
  85462. }
  85463. /**
  85464. * The glTF validator object
  85465. * @ignore
  85466. */
  85467. interface IGLTFValidator {
  85468. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  85469. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  85470. }
  85471. /**
  85472. * Interfaces from the EXT_lights_image_based extension
  85473. */
  85474. /** @hidden */
  85475. interface IEXTLightsImageBased_LightReferenceImageBased {
  85476. light: number;
  85477. }
  85478. /** @hidden */
  85479. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  85480. intensity: number;
  85481. rotation: number[];
  85482. specularImageSize: number;
  85483. specularImages: number[][];
  85484. irradianceCoefficients: number[][];
  85485. }
  85486. /** @hidden */
  85487. interface IEXTLightsImageBased {
  85488. lights: IEXTLightsImageBased_LightImageBased[];
  85489. }
  85490. /**
  85491. * Interfaces from the EXT_mesh_gpu_instancing extension
  85492. * !!! Experimental Extension Subject to Changes !!!
  85493. */
  85494. /** @hidden */
  85495. interface IEXTMeshGpuInstancing {
  85496. mesh?: number;
  85497. attributes: { [name: string]: number };
  85498. }
  85499. /**
  85500. * Interfaces from the KHR_draco_mesh_compression extension
  85501. */
  85502. /** @hidden */
  85503. interface IKHRDracoMeshCompression {
  85504. bufferView: number;
  85505. attributes: { [name: string]: number };
  85506. }
  85507. /**
  85508. * Interfaces from the KHR_lights_punctual extension
  85509. */
  85510. /** @hidden */
  85511. const enum IKHRLightsPunctual_LightType {
  85512. DIRECTIONAL = "directional",
  85513. POINT = "point",
  85514. SPOT = "spot"
  85515. }
  85516. /** @hidden */
  85517. interface IKHRLightsPunctual_LightReference {
  85518. light: number;
  85519. }
  85520. /** @hidden */
  85521. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  85522. type: IKHRLightsPunctual_LightType;
  85523. color?: number[];
  85524. intensity?: number;
  85525. range?: number;
  85526. spot?: {
  85527. innerConeAngle?: number;
  85528. outerConeAngle?: number;
  85529. };
  85530. }
  85531. /** @hidden */
  85532. interface IKHRLightsPunctual {
  85533. lights: IKHRLightsPunctual_Light[];
  85534. }
  85535. /**
  85536. * Interfaces from the KHR_materials_clearcoat extension
  85537. * !!! Experimental Extension Subject to Changes !!!
  85538. */
  85539. /** @hidden */
  85540. interface IKHRMaterialsClearcoat {
  85541. clearcoatFactor: number;
  85542. clearcoatTexture: ITextureInfo;
  85543. clearcoatRoughnessFactor: number;
  85544. clearcoatRoughnessTexture: ITextureInfo;
  85545. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  85546. }
  85547. /**
  85548. * Interfaces from the KHR_materials_ior extension
  85549. * !!! Experimental Extension Subject to Changes !!!
  85550. */
  85551. /** @hidden */
  85552. interface IKHRMaterialsIor {
  85553. ior: number;
  85554. }
  85555. /**
  85556. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  85557. */
  85558. /** @hidden */
  85559. interface IKHRMaterialsPbrSpecularGlossiness {
  85560. diffuseFactor: number[];
  85561. diffuseTexture: ITextureInfo;
  85562. specularFactor: number[];
  85563. glossinessFactor: number;
  85564. specularGlossinessTexture: ITextureInfo;
  85565. }
  85566. /**
  85567. * Interfaces from the KHR_materials_sheen extension
  85568. * !!! Experimental Extension Subject to Changes !!!
  85569. */
  85570. /** @hidden */
  85571. interface IKHRMaterialsSheen {
  85572. sheenColorFactor?: number[];
  85573. sheenTexture?: ITextureInfo;
  85574. sheenRoughnessFactor?: number;
  85575. }
  85576. /**
  85577. * Interfaces from the KHR_materials_specular extension
  85578. * !!! Experimental Extension Subject to Changes !!!
  85579. */
  85580. /** @hidden */
  85581. interface IKHRMaterialsSpecular {
  85582. specularFactor: number;
  85583. specularColorFactor: number[];
  85584. specularTexture: ITextureInfo;
  85585. }
  85586. /**
  85587. * Interfaces from the KHR_materials_transmission extension
  85588. * !!! Experimental Extension Subject to Changes !!!
  85589. */
  85590. /** @hidden */
  85591. interface IKHRMaterialsTransmission {
  85592. transmissionFactor?: number;
  85593. transmissionTexture?: ITextureInfo;
  85594. }
  85595. /**
  85596. * Interfaces from the KHR_materials_variants extension
  85597. * !!! Experimental Extension Subject to Changes !!!
  85598. */
  85599. /** @hidden */
  85600. interface IKHRMaterialVariants_Mapping extends IProperty {
  85601. mappings: Array<{
  85602. variants: number[];
  85603. material: number;
  85604. }>;
  85605. }
  85606. /** @hidden */
  85607. interface IKHRMaterialVariants_Variant extends IProperty {
  85608. name: string;
  85609. }
  85610. /** @hidden */
  85611. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  85612. variants: Array<IKHRMaterialVariants_Variant>;
  85613. }
  85614. /**
  85615. * Interfaces from the KHR_texture_basisu extension
  85616. * !!! Experimental Extension Subject to Changes !!!
  85617. */
  85618. /** @hidden */
  85619. interface IKHRTextureBasisU {
  85620. source: number;
  85621. }
  85622. /**
  85623. * Interfaces from the EXT_texture_webp extension
  85624. */
  85625. /** @hidden */
  85626. interface IEXTTextureWebP {
  85627. source: number;
  85628. }
  85629. /**
  85630. * Interfaces from the KHR_texture_transform extension
  85631. */
  85632. /** @hidden */
  85633. interface IKHRTextureTransform {
  85634. offset?: number[];
  85635. rotation?: number;
  85636. scale?: number[];
  85637. texCoord?: number;
  85638. }
  85639. /**
  85640. * Interfaces from the KHR_xmp extension
  85641. * !!! Experimental Extension Subject to Changes !!!
  85642. */
  85643. /** @hidden */
  85644. interface IKHRXmp_Data {
  85645. [key: string]: unknown;
  85646. }
  85647. /** @hidden */
  85648. interface IKHRXmp_Gltf {
  85649. packets: IKHRXmp_Data[];
  85650. }
  85651. /** @hidden */
  85652. interface IKHRXmp_Node {
  85653. packet: number;
  85654. }
  85655. /**
  85656. * Interfaces from the MSFT_audio_emitter extension
  85657. */
  85658. /** @hidden */
  85659. interface IMSFTAudioEmitter_ClipReference {
  85660. clip: number;
  85661. weight?: number;
  85662. }
  85663. /** @hidden */
  85664. interface IMSFTAudioEmitter_EmittersReference {
  85665. emitters: number[];
  85666. }
  85667. /** @hidden */
  85668. const enum IMSFTAudioEmitter_DistanceModel {
  85669. linear = "linear",
  85670. inverse = "inverse",
  85671. exponential = "exponential",
  85672. }
  85673. /** @hidden */
  85674. interface IMSFTAudioEmitter_Emitter {
  85675. name?: string;
  85676. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  85677. refDistance?: number;
  85678. maxDistance?: number;
  85679. rolloffFactor?: number;
  85680. innerAngle?: number;
  85681. outerAngle?: number;
  85682. loop?: boolean;
  85683. volume?: number;
  85684. clips: IMSFTAudioEmitter_ClipReference[];
  85685. }
  85686. /** @hidden */
  85687. const enum IMSFTAudioEmitter_AudioMimeType {
  85688. WAV = "audio/wav",
  85689. }
  85690. /** @hidden */
  85691. interface IMSFTAudioEmitter_Clip extends IProperty {
  85692. uri?: string;
  85693. bufferView?: number;
  85694. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  85695. }
  85696. /** @hidden */
  85697. const enum IMSFTAudioEmitter_AnimationEventAction {
  85698. play = "play",
  85699. pause = "pause",
  85700. stop = "stop",
  85701. }
  85702. /** @hidden */
  85703. interface IMSFTAudioEmitter_AnimationEvent {
  85704. action: IMSFTAudioEmitter_AnimationEventAction;
  85705. emitter: number;
  85706. time: number;
  85707. startOffset?: number;
  85708. }
  85709. /**
  85710. * Interfaces from the MSFT_lod extension
  85711. */
  85712. /** @hidden */
  85713. interface IMSFTLOD {
  85714. ids: number[];
  85715. }
  85716. }
  85717. declare module BABYLON {
  85718. /** @hidden */
  85719. export var cellPixelShader: {
  85720. name: string;
  85721. shader: string;
  85722. };
  85723. }
  85724. declare module BABYLON {
  85725. /** @hidden */
  85726. export var cellVertexShader: {
  85727. name: string;
  85728. shader: string;
  85729. };
  85730. }
  85731. declare module BABYLON {
  85732. export class CellMaterial extends BABYLON.PushMaterial {
  85733. private _diffuseTexture;
  85734. diffuseTexture: BABYLON.BaseTexture;
  85735. diffuseColor: BABYLON.Color3;
  85736. _computeHighLevel: boolean;
  85737. computeHighLevel: boolean;
  85738. private _disableLighting;
  85739. disableLighting: boolean;
  85740. private _maxSimultaneousLights;
  85741. maxSimultaneousLights: number;
  85742. constructor(name: string, scene: BABYLON.Scene);
  85743. needAlphaBlending(): boolean;
  85744. needAlphaTesting(): boolean;
  85745. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85746. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85747. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85748. getAnimatables(): BABYLON.IAnimatable[];
  85749. getActiveTextures(): BABYLON.BaseTexture[];
  85750. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85751. dispose(forceDisposeEffect?: boolean): void;
  85752. getClassName(): string;
  85753. clone(name: string): CellMaterial;
  85754. serialize(): any;
  85755. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  85756. }
  85757. }
  85758. declare module BABYLON {
  85759. export class CustomShaderStructure {
  85760. FragmentStore: string;
  85761. VertexStore: string;
  85762. constructor();
  85763. }
  85764. export class ShaderSpecialParts {
  85765. constructor();
  85766. Fragment_Begin: string;
  85767. Fragment_Definitions: string;
  85768. Fragment_MainBegin: string;
  85769. Fragment_Custom_Diffuse: string;
  85770. Fragment_Before_Lights: string;
  85771. Fragment_Before_Fog: string;
  85772. Fragment_Custom_Alpha: string;
  85773. Fragment_Before_FragColor: string;
  85774. Vertex_Begin: string;
  85775. Vertex_Definitions: string;
  85776. Vertex_MainBegin: string;
  85777. Vertex_Before_PositionUpdated: string;
  85778. Vertex_Before_NormalUpdated: string;
  85779. Vertex_After_WorldPosComputed: string;
  85780. Vertex_MainEnd: string;
  85781. }
  85782. export class CustomMaterial extends BABYLON.StandardMaterial {
  85783. static ShaderIndexer: number;
  85784. CustomParts: ShaderSpecialParts;
  85785. _isCreatedShader: boolean;
  85786. _createdShaderName: string;
  85787. _customUniform: string[];
  85788. _newUniforms: string[];
  85789. _newUniformInstances: {
  85790. [name: string]: any;
  85791. };
  85792. _newSamplerInstances: {
  85793. [name: string]: BABYLON.Texture;
  85794. };
  85795. _customAttributes: string[];
  85796. FragmentShader: string;
  85797. VertexShader: string;
  85798. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  85799. ReviewUniform(name: string, arr: string[]): string[];
  85800. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  85801. constructor(name: string, scene: BABYLON.Scene);
  85802. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  85803. AddAttribute(name: string): CustomMaterial;
  85804. Fragment_Begin(shaderPart: string): CustomMaterial;
  85805. Fragment_Definitions(shaderPart: string): CustomMaterial;
  85806. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  85807. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  85808. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  85809. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  85810. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  85811. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  85812. Vertex_Begin(shaderPart: string): CustomMaterial;
  85813. Vertex_Definitions(shaderPart: string): CustomMaterial;
  85814. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  85815. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  85816. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  85817. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  85818. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  85819. }
  85820. }
  85821. declare module BABYLON {
  85822. export class ShaderAlebdoParts {
  85823. constructor();
  85824. Fragment_Begin: string;
  85825. Fragment_Definitions: string;
  85826. Fragment_MainBegin: string;
  85827. Fragment_Custom_Albedo: string;
  85828. Fragment_Before_Lights: string;
  85829. Fragment_Custom_MetallicRoughness: string;
  85830. Fragment_Custom_MicroSurface: string;
  85831. Fragment_Before_Fog: string;
  85832. Fragment_Custom_Alpha: string;
  85833. Fragment_Before_FragColor: string;
  85834. Vertex_Begin: string;
  85835. Vertex_Definitions: string;
  85836. Vertex_MainBegin: string;
  85837. Vertex_Before_PositionUpdated: string;
  85838. Vertex_Before_NormalUpdated: string;
  85839. Vertex_After_WorldPosComputed: string;
  85840. Vertex_MainEnd: string;
  85841. }
  85842. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  85843. static ShaderIndexer: number;
  85844. CustomParts: ShaderAlebdoParts;
  85845. _isCreatedShader: boolean;
  85846. _createdShaderName: string;
  85847. _customUniform: string[];
  85848. _newUniforms: string[];
  85849. _newUniformInstances: {
  85850. [name: string]: any;
  85851. };
  85852. _newSamplerInstances: {
  85853. [name: string]: BABYLON.Texture;
  85854. };
  85855. _customAttributes: string[];
  85856. FragmentShader: string;
  85857. VertexShader: string;
  85858. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  85859. ReviewUniform(name: string, arr: string[]): string[];
  85860. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  85861. constructor(name: string, scene: BABYLON.Scene);
  85862. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  85863. AddAttribute(name: string): PBRCustomMaterial;
  85864. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  85865. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  85866. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  85867. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  85868. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  85869. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  85870. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  85871. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  85872. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  85873. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  85874. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  85875. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  85876. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  85877. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  85878. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  85879. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  85880. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  85881. }
  85882. }
  85883. declare module BABYLON {
  85884. /** @hidden */
  85885. export var firePixelShader: {
  85886. name: string;
  85887. shader: string;
  85888. };
  85889. }
  85890. declare module BABYLON {
  85891. /** @hidden */
  85892. export var fireVertexShader: {
  85893. name: string;
  85894. shader: string;
  85895. };
  85896. }
  85897. declare module BABYLON {
  85898. export class FireMaterial extends BABYLON.PushMaterial {
  85899. private _diffuseTexture;
  85900. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85901. private _distortionTexture;
  85902. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85903. private _opacityTexture;
  85904. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85905. diffuseColor: BABYLON.Color3;
  85906. speed: number;
  85907. private _scaledDiffuse;
  85908. private _lastTime;
  85909. constructor(name: string, scene: BABYLON.Scene);
  85910. needAlphaBlending(): boolean;
  85911. needAlphaTesting(): boolean;
  85912. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85913. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85914. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85915. getAnimatables(): BABYLON.IAnimatable[];
  85916. getActiveTextures(): BABYLON.BaseTexture[];
  85917. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85918. getClassName(): string;
  85919. dispose(forceDisposeEffect?: boolean): void;
  85920. clone(name: string): FireMaterial;
  85921. serialize(): any;
  85922. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  85923. }
  85924. }
  85925. declare module BABYLON {
  85926. /** @hidden */
  85927. export var furPixelShader: {
  85928. name: string;
  85929. shader: string;
  85930. };
  85931. }
  85932. declare module BABYLON {
  85933. /** @hidden */
  85934. export var furVertexShader: {
  85935. name: string;
  85936. shader: string;
  85937. };
  85938. }
  85939. declare module BABYLON {
  85940. export class FurMaterial extends BABYLON.PushMaterial {
  85941. private _diffuseTexture;
  85942. diffuseTexture: BABYLON.BaseTexture;
  85943. private _heightTexture;
  85944. heightTexture: BABYLON.BaseTexture;
  85945. diffuseColor: BABYLON.Color3;
  85946. furLength: number;
  85947. furAngle: number;
  85948. furColor: BABYLON.Color3;
  85949. furOffset: number;
  85950. furSpacing: number;
  85951. furGravity: BABYLON.Vector3;
  85952. furSpeed: number;
  85953. furDensity: number;
  85954. furOcclusion: number;
  85955. furTexture: BABYLON.DynamicTexture;
  85956. private _disableLighting;
  85957. disableLighting: boolean;
  85958. private _maxSimultaneousLights;
  85959. maxSimultaneousLights: number;
  85960. highLevelFur: boolean;
  85961. _meshes: BABYLON.AbstractMesh[];
  85962. private _furTime;
  85963. constructor(name: string, scene: BABYLON.Scene);
  85964. get furTime(): number;
  85965. set furTime(furTime: number);
  85966. needAlphaBlending(): boolean;
  85967. needAlphaTesting(): boolean;
  85968. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85969. updateFur(): void;
  85970. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85971. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85972. getAnimatables(): BABYLON.IAnimatable[];
  85973. getActiveTextures(): BABYLON.BaseTexture[];
  85974. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85975. dispose(forceDisposeEffect?: boolean): void;
  85976. clone(name: string): FurMaterial;
  85977. serialize(): any;
  85978. getClassName(): string;
  85979. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  85980. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  85981. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  85982. }
  85983. }
  85984. declare module BABYLON {
  85985. /** @hidden */
  85986. export var gradientPixelShader: {
  85987. name: string;
  85988. shader: string;
  85989. };
  85990. }
  85991. declare module BABYLON {
  85992. /** @hidden */
  85993. export var gradientVertexShader: {
  85994. name: string;
  85995. shader: string;
  85996. };
  85997. }
  85998. declare module BABYLON {
  85999. export class GradientMaterial extends BABYLON.PushMaterial {
  86000. private _maxSimultaneousLights;
  86001. maxSimultaneousLights: number;
  86002. topColor: BABYLON.Color3;
  86003. topColorAlpha: number;
  86004. bottomColor: BABYLON.Color3;
  86005. bottomColorAlpha: number;
  86006. offset: number;
  86007. scale: number;
  86008. smoothness: number;
  86009. private _disableLighting;
  86010. disableLighting: boolean;
  86011. constructor(name: string, scene: BABYLON.Scene);
  86012. needAlphaBlending(): boolean;
  86013. needAlphaTesting(): boolean;
  86014. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86015. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86016. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86017. getAnimatables(): BABYLON.IAnimatable[];
  86018. dispose(forceDisposeEffect?: boolean): void;
  86019. clone(name: string): GradientMaterial;
  86020. serialize(): any;
  86021. getClassName(): string;
  86022. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  86023. }
  86024. }
  86025. declare module BABYLON {
  86026. /** @hidden */
  86027. export var gridPixelShader: {
  86028. name: string;
  86029. shader: string;
  86030. };
  86031. }
  86032. declare module BABYLON {
  86033. /** @hidden */
  86034. export var gridVertexShader: {
  86035. name: string;
  86036. shader: string;
  86037. };
  86038. }
  86039. declare module BABYLON {
  86040. /**
  86041. * The grid materials allows you to wrap any shape with a grid.
  86042. * Colors are customizable.
  86043. */
  86044. export class GridMaterial extends BABYLON.PushMaterial {
  86045. /**
  86046. * Main color of the grid (e.g. between lines)
  86047. */
  86048. mainColor: BABYLON.Color3;
  86049. /**
  86050. * Color of the grid lines.
  86051. */
  86052. lineColor: BABYLON.Color3;
  86053. /**
  86054. * The scale of the grid compared to unit.
  86055. */
  86056. gridRatio: number;
  86057. /**
  86058. * Allows setting an offset for the grid lines.
  86059. */
  86060. gridOffset: BABYLON.Vector3;
  86061. /**
  86062. * The frequency of thicker lines.
  86063. */
  86064. majorUnitFrequency: number;
  86065. /**
  86066. * The visibility of minor units in the grid.
  86067. */
  86068. minorUnitVisibility: number;
  86069. /**
  86070. * The grid opacity outside of the lines.
  86071. */
  86072. opacity: number;
  86073. /**
  86074. * Determine RBG output is premultiplied by alpha value.
  86075. */
  86076. preMultiplyAlpha: boolean;
  86077. private _opacityTexture;
  86078. opacityTexture: BABYLON.BaseTexture;
  86079. private _gridControl;
  86080. /**
  86081. * constructor
  86082. * @param name The name given to the material in order to identify it afterwards.
  86083. * @param scene The scene the material is used in.
  86084. */
  86085. constructor(name: string, scene: BABYLON.Scene);
  86086. /**
  86087. * Returns wehter or not the grid requires alpha blending.
  86088. */
  86089. needAlphaBlending(): boolean;
  86090. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  86091. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86092. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86093. /**
  86094. * Dispose the material and its associated resources.
  86095. * @param forceDisposeEffect will also dispose the used effect when true
  86096. */
  86097. dispose(forceDisposeEffect?: boolean): void;
  86098. clone(name: string): GridMaterial;
  86099. serialize(): any;
  86100. getClassName(): string;
  86101. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  86102. }
  86103. }
  86104. declare module BABYLON {
  86105. /** @hidden */
  86106. export var lavaPixelShader: {
  86107. name: string;
  86108. shader: string;
  86109. };
  86110. }
  86111. declare module BABYLON {
  86112. /** @hidden */
  86113. export var lavaVertexShader: {
  86114. name: string;
  86115. shader: string;
  86116. };
  86117. }
  86118. declare module BABYLON {
  86119. export class LavaMaterial extends BABYLON.PushMaterial {
  86120. private _diffuseTexture;
  86121. diffuseTexture: BABYLON.BaseTexture;
  86122. noiseTexture: BABYLON.BaseTexture;
  86123. fogColor: BABYLON.Color3;
  86124. speed: number;
  86125. movingSpeed: number;
  86126. lowFrequencySpeed: number;
  86127. fogDensity: number;
  86128. private _lastTime;
  86129. diffuseColor: BABYLON.Color3;
  86130. private _disableLighting;
  86131. disableLighting: boolean;
  86132. private _unlit;
  86133. unlit: boolean;
  86134. private _maxSimultaneousLights;
  86135. maxSimultaneousLights: number;
  86136. private _scaledDiffuse;
  86137. constructor(name: string, scene: BABYLON.Scene);
  86138. needAlphaBlending(): boolean;
  86139. needAlphaTesting(): boolean;
  86140. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86141. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86142. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86143. getAnimatables(): BABYLON.IAnimatable[];
  86144. getActiveTextures(): BABYLON.BaseTexture[];
  86145. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86146. dispose(forceDisposeEffect?: boolean): void;
  86147. clone(name: string): LavaMaterial;
  86148. serialize(): any;
  86149. getClassName(): string;
  86150. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  86151. }
  86152. }
  86153. declare module BABYLON {
  86154. /** @hidden */
  86155. export var mixPixelShader: {
  86156. name: string;
  86157. shader: string;
  86158. };
  86159. }
  86160. declare module BABYLON {
  86161. /** @hidden */
  86162. export var mixVertexShader: {
  86163. name: string;
  86164. shader: string;
  86165. };
  86166. }
  86167. declare module BABYLON {
  86168. export class MixMaterial extends BABYLON.PushMaterial {
  86169. /**
  86170. * Mix textures
  86171. */
  86172. private _mixTexture1;
  86173. mixTexture1: BABYLON.BaseTexture;
  86174. private _mixTexture2;
  86175. mixTexture2: BABYLON.BaseTexture;
  86176. /**
  86177. * Diffuse textures
  86178. */
  86179. private _diffuseTexture1;
  86180. diffuseTexture1: BABYLON.Texture;
  86181. private _diffuseTexture2;
  86182. diffuseTexture2: BABYLON.Texture;
  86183. private _diffuseTexture3;
  86184. diffuseTexture3: BABYLON.Texture;
  86185. private _diffuseTexture4;
  86186. diffuseTexture4: BABYLON.Texture;
  86187. private _diffuseTexture5;
  86188. diffuseTexture5: BABYLON.Texture;
  86189. private _diffuseTexture6;
  86190. diffuseTexture6: BABYLON.Texture;
  86191. private _diffuseTexture7;
  86192. diffuseTexture7: BABYLON.Texture;
  86193. private _diffuseTexture8;
  86194. diffuseTexture8: BABYLON.Texture;
  86195. /**
  86196. * Uniforms
  86197. */
  86198. diffuseColor: BABYLON.Color3;
  86199. specularColor: BABYLON.Color3;
  86200. specularPower: number;
  86201. private _disableLighting;
  86202. disableLighting: boolean;
  86203. private _maxSimultaneousLights;
  86204. maxSimultaneousLights: number;
  86205. constructor(name: string, scene: BABYLON.Scene);
  86206. needAlphaBlending(): boolean;
  86207. needAlphaTesting(): boolean;
  86208. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86209. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86210. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86211. getAnimatables(): BABYLON.IAnimatable[];
  86212. getActiveTextures(): BABYLON.BaseTexture[];
  86213. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86214. dispose(forceDisposeEffect?: boolean): void;
  86215. clone(name: string): MixMaterial;
  86216. serialize(): any;
  86217. getClassName(): string;
  86218. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  86219. }
  86220. }
  86221. declare module BABYLON {
  86222. /** @hidden */
  86223. export var normalPixelShader: {
  86224. name: string;
  86225. shader: string;
  86226. };
  86227. }
  86228. declare module BABYLON {
  86229. /** @hidden */
  86230. export var normalVertexShader: {
  86231. name: string;
  86232. shader: string;
  86233. };
  86234. }
  86235. declare module BABYLON {
  86236. export class NormalMaterial extends BABYLON.PushMaterial {
  86237. private _diffuseTexture;
  86238. diffuseTexture: BABYLON.BaseTexture;
  86239. diffuseColor: BABYLON.Color3;
  86240. private _disableLighting;
  86241. disableLighting: boolean;
  86242. private _maxSimultaneousLights;
  86243. maxSimultaneousLights: number;
  86244. constructor(name: string, scene: BABYLON.Scene);
  86245. needAlphaBlending(): boolean;
  86246. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  86247. needAlphaTesting(): boolean;
  86248. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86249. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86250. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86251. getAnimatables(): BABYLON.IAnimatable[];
  86252. getActiveTextures(): BABYLON.BaseTexture[];
  86253. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86254. dispose(forceDisposeEffect?: boolean): void;
  86255. clone(name: string): NormalMaterial;
  86256. serialize(): any;
  86257. getClassName(): string;
  86258. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  86259. }
  86260. }
  86261. declare module BABYLON {
  86262. /** @hidden */
  86263. export var shadowOnlyPixelShader: {
  86264. name: string;
  86265. shader: string;
  86266. };
  86267. }
  86268. declare module BABYLON {
  86269. /** @hidden */
  86270. export var shadowOnlyVertexShader: {
  86271. name: string;
  86272. shader: string;
  86273. };
  86274. }
  86275. declare module BABYLON {
  86276. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  86277. private _activeLight;
  86278. private _needAlphaBlending;
  86279. constructor(name: string, scene: BABYLON.Scene);
  86280. shadowColor: BABYLON.Color3;
  86281. needAlphaBlending(): boolean;
  86282. needAlphaTesting(): boolean;
  86283. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86284. get activeLight(): BABYLON.IShadowLight;
  86285. set activeLight(light: BABYLON.IShadowLight);
  86286. private _getFirstShadowLightForMesh;
  86287. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86288. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86289. clone(name: string): ShadowOnlyMaterial;
  86290. serialize(): any;
  86291. getClassName(): string;
  86292. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  86293. }
  86294. }
  86295. declare module BABYLON {
  86296. /** @hidden */
  86297. export var simplePixelShader: {
  86298. name: string;
  86299. shader: string;
  86300. };
  86301. }
  86302. declare module BABYLON {
  86303. /** @hidden */
  86304. export var simpleVertexShader: {
  86305. name: string;
  86306. shader: string;
  86307. };
  86308. }
  86309. declare module BABYLON {
  86310. export class SimpleMaterial extends BABYLON.PushMaterial {
  86311. private _diffuseTexture;
  86312. diffuseTexture: BABYLON.BaseTexture;
  86313. diffuseColor: BABYLON.Color3;
  86314. private _disableLighting;
  86315. disableLighting: boolean;
  86316. private _maxSimultaneousLights;
  86317. maxSimultaneousLights: number;
  86318. constructor(name: string, scene: BABYLON.Scene);
  86319. needAlphaBlending(): boolean;
  86320. needAlphaTesting(): boolean;
  86321. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86322. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86323. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86324. getAnimatables(): BABYLON.IAnimatable[];
  86325. getActiveTextures(): BABYLON.BaseTexture[];
  86326. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86327. dispose(forceDisposeEffect?: boolean): void;
  86328. clone(name: string): SimpleMaterial;
  86329. serialize(): any;
  86330. getClassName(): string;
  86331. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  86332. }
  86333. }
  86334. declare module BABYLON {
  86335. /** @hidden */
  86336. export var skyPixelShader: {
  86337. name: string;
  86338. shader: string;
  86339. };
  86340. }
  86341. declare module BABYLON {
  86342. /** @hidden */
  86343. export var skyVertexShader: {
  86344. name: string;
  86345. shader: string;
  86346. };
  86347. }
  86348. declare module BABYLON {
  86349. /**
  86350. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  86351. * @see https://doc.babylonjs.com/extensions/sky
  86352. */
  86353. export class SkyMaterial extends BABYLON.PushMaterial {
  86354. /**
  86355. * Defines the overall luminance of sky in interval ]0, 1[.
  86356. */
  86357. luminance: number;
  86358. /**
  86359. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  86360. */
  86361. turbidity: number;
  86362. /**
  86363. * Defines the sky appearance (light intensity).
  86364. */
  86365. rayleigh: number;
  86366. /**
  86367. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  86368. */
  86369. mieCoefficient: number;
  86370. /**
  86371. * Defines the amount of haze particles following the Mie scattering theory.
  86372. */
  86373. mieDirectionalG: number;
  86374. /**
  86375. * Defines the distance of the sun according to the active scene camera.
  86376. */
  86377. distance: number;
  86378. /**
  86379. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  86380. * "inclined".
  86381. */
  86382. inclination: number;
  86383. /**
  86384. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  86385. * an object direction and a reference direction.
  86386. */
  86387. azimuth: number;
  86388. /**
  86389. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  86390. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  86391. */
  86392. sunPosition: BABYLON.Vector3;
  86393. /**
  86394. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  86395. * .sunPosition property.
  86396. */
  86397. useSunPosition: boolean;
  86398. /**
  86399. * Defines an offset vector used to get a horizon offset.
  86400. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  86401. */
  86402. cameraOffset: BABYLON.Vector3;
  86403. private _cameraPosition;
  86404. /**
  86405. * Instantiates a new sky material.
  86406. * This material allows to create dynamic and texture free
  86407. * effects for skyboxes by taking care of the atmosphere state.
  86408. * @see https://doc.babylonjs.com/extensions/sky
  86409. * @param name Define the name of the material in the scene
  86410. * @param scene Define the scene the material belong to
  86411. */
  86412. constructor(name: string, scene: BABYLON.Scene);
  86413. /**
  86414. * Specifies if the material will require alpha blending
  86415. * @returns a boolean specifying if alpha blending is needed
  86416. */
  86417. needAlphaBlending(): boolean;
  86418. /**
  86419. * Specifies if this material should be rendered in alpha test mode
  86420. * @returns false as the sky material doesn't need alpha testing.
  86421. */
  86422. needAlphaTesting(): boolean;
  86423. /**
  86424. * Get the texture used for alpha test purpose.
  86425. * @returns null as the sky material has no texture.
  86426. */
  86427. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86428. /**
  86429. * Get if the submesh is ready to be used and all its information available.
  86430. * Child classes can use it to update shaders
  86431. * @param mesh defines the mesh to check
  86432. * @param subMesh defines which submesh to check
  86433. * @param useInstances specifies that instances should be used
  86434. * @returns a boolean indicating that the submesh is ready or not
  86435. */
  86436. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86437. /**
  86438. * Binds the submesh to this material by preparing the effect and shader to draw
  86439. * @param world defines the world transformation matrix
  86440. * @param mesh defines the mesh containing the submesh
  86441. * @param subMesh defines the submesh to bind the material to
  86442. */
  86443. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86444. /**
  86445. * Get the list of animatables in the material.
  86446. * @returns the list of animatables object used in the material
  86447. */
  86448. getAnimatables(): BABYLON.IAnimatable[];
  86449. /**
  86450. * Disposes the material
  86451. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86452. */
  86453. dispose(forceDisposeEffect?: boolean): void;
  86454. /**
  86455. * Makes a duplicate of the material, and gives it a new name
  86456. * @param name defines the new name for the duplicated material
  86457. * @returns the cloned material
  86458. */
  86459. clone(name: string): SkyMaterial;
  86460. /**
  86461. * Serializes this material in a JSON representation
  86462. * @returns the serialized material object
  86463. */
  86464. serialize(): any;
  86465. /**
  86466. * Gets the current class name of the material e.g. "SkyMaterial"
  86467. * Mainly use in serialization.
  86468. * @returns the class name
  86469. */
  86470. getClassName(): string;
  86471. /**
  86472. * Creates a sky material from parsed material data
  86473. * @param source defines the JSON representation of the material
  86474. * @param scene defines the hosting scene
  86475. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86476. * @returns a new sky material
  86477. */
  86478. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  86479. }
  86480. }
  86481. declare module BABYLON {
  86482. /** @hidden */
  86483. export var terrainPixelShader: {
  86484. name: string;
  86485. shader: string;
  86486. };
  86487. }
  86488. declare module BABYLON {
  86489. /** @hidden */
  86490. export var terrainVertexShader: {
  86491. name: string;
  86492. shader: string;
  86493. };
  86494. }
  86495. declare module BABYLON {
  86496. export class TerrainMaterial extends BABYLON.PushMaterial {
  86497. private _mixTexture;
  86498. mixTexture: BABYLON.BaseTexture;
  86499. private _diffuseTexture1;
  86500. diffuseTexture1: BABYLON.Texture;
  86501. private _diffuseTexture2;
  86502. diffuseTexture2: BABYLON.Texture;
  86503. private _diffuseTexture3;
  86504. diffuseTexture3: BABYLON.Texture;
  86505. private _bumpTexture1;
  86506. bumpTexture1: BABYLON.Texture;
  86507. private _bumpTexture2;
  86508. bumpTexture2: BABYLON.Texture;
  86509. private _bumpTexture3;
  86510. bumpTexture3: BABYLON.Texture;
  86511. diffuseColor: BABYLON.Color3;
  86512. specularColor: BABYLON.Color3;
  86513. specularPower: number;
  86514. private _disableLighting;
  86515. disableLighting: boolean;
  86516. private _maxSimultaneousLights;
  86517. maxSimultaneousLights: number;
  86518. constructor(name: string, scene: BABYLON.Scene);
  86519. needAlphaBlending(): boolean;
  86520. needAlphaTesting(): boolean;
  86521. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86522. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86523. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86524. getAnimatables(): BABYLON.IAnimatable[];
  86525. getActiveTextures(): BABYLON.BaseTexture[];
  86526. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86527. dispose(forceDisposeEffect?: boolean): void;
  86528. clone(name: string): TerrainMaterial;
  86529. serialize(): any;
  86530. getClassName(): string;
  86531. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  86532. }
  86533. }
  86534. declare module BABYLON {
  86535. /** @hidden */
  86536. export var triplanarPixelShader: {
  86537. name: string;
  86538. shader: string;
  86539. };
  86540. }
  86541. declare module BABYLON {
  86542. /** @hidden */
  86543. export var triplanarVertexShader: {
  86544. name: string;
  86545. shader: string;
  86546. };
  86547. }
  86548. declare module BABYLON {
  86549. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  86550. mixTexture: BABYLON.BaseTexture;
  86551. private _diffuseTextureX;
  86552. diffuseTextureX: BABYLON.BaseTexture;
  86553. private _diffuseTextureY;
  86554. diffuseTextureY: BABYLON.BaseTexture;
  86555. private _diffuseTextureZ;
  86556. diffuseTextureZ: BABYLON.BaseTexture;
  86557. private _normalTextureX;
  86558. normalTextureX: BABYLON.BaseTexture;
  86559. private _normalTextureY;
  86560. normalTextureY: BABYLON.BaseTexture;
  86561. private _normalTextureZ;
  86562. normalTextureZ: BABYLON.BaseTexture;
  86563. tileSize: number;
  86564. diffuseColor: BABYLON.Color3;
  86565. specularColor: BABYLON.Color3;
  86566. specularPower: number;
  86567. private _disableLighting;
  86568. disableLighting: boolean;
  86569. private _maxSimultaneousLights;
  86570. maxSimultaneousLights: number;
  86571. constructor(name: string, scene: BABYLON.Scene);
  86572. needAlphaBlending(): boolean;
  86573. needAlphaTesting(): boolean;
  86574. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86575. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86576. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86577. getAnimatables(): BABYLON.IAnimatable[];
  86578. getActiveTextures(): BABYLON.BaseTexture[];
  86579. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86580. dispose(forceDisposeEffect?: boolean): void;
  86581. clone(name: string): TriPlanarMaterial;
  86582. serialize(): any;
  86583. getClassName(): string;
  86584. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  86585. }
  86586. }
  86587. declare module BABYLON {
  86588. /** @hidden */
  86589. export var waterPixelShader: {
  86590. name: string;
  86591. shader: string;
  86592. };
  86593. }
  86594. declare module BABYLON {
  86595. /** @hidden */
  86596. export var waterVertexShader: {
  86597. name: string;
  86598. shader: string;
  86599. };
  86600. }
  86601. declare module BABYLON {
  86602. export class WaterMaterial extends BABYLON.PushMaterial {
  86603. renderTargetSize: BABYLON.Vector2;
  86604. private _bumpTexture;
  86605. bumpTexture: BABYLON.BaseTexture;
  86606. diffuseColor: BABYLON.Color3;
  86607. specularColor: BABYLON.Color3;
  86608. specularPower: number;
  86609. private _disableLighting;
  86610. disableLighting: boolean;
  86611. private _maxSimultaneousLights;
  86612. maxSimultaneousLights: number;
  86613. /**
  86614. * @param {number}: Represents the wind force
  86615. */
  86616. windForce: number;
  86617. /**
  86618. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  86619. */
  86620. windDirection: BABYLON.Vector2;
  86621. /**
  86622. * @param {number}: Wave height, represents the height of the waves
  86623. */
  86624. waveHeight: number;
  86625. /**
  86626. * @param {number}: Bump height, represents the bump height related to the bump map
  86627. */
  86628. bumpHeight: number;
  86629. /**
  86630. * @param {boolean}: Add a smaller moving bump to less steady waves.
  86631. */
  86632. private _bumpSuperimpose;
  86633. bumpSuperimpose: boolean;
  86634. /**
  86635. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  86636. */
  86637. private _fresnelSeparate;
  86638. fresnelSeparate: boolean;
  86639. /**
  86640. * @param {boolean}: bump Waves modify the reflection.
  86641. */
  86642. private _bumpAffectsReflection;
  86643. bumpAffectsReflection: boolean;
  86644. /**
  86645. * @param {number}: The water color blended with the refraction (near)
  86646. */
  86647. waterColor: BABYLON.Color3;
  86648. /**
  86649. * @param {number}: The blend factor related to the water color
  86650. */
  86651. colorBlendFactor: number;
  86652. /**
  86653. * @param {number}: The water color blended with the reflection (far)
  86654. */
  86655. waterColor2: BABYLON.Color3;
  86656. /**
  86657. * @param {number}: The blend factor related to the water color (reflection, far)
  86658. */
  86659. colorBlendFactor2: number;
  86660. /**
  86661. * @param {number}: Represents the maximum length of a wave
  86662. */
  86663. waveLength: number;
  86664. /**
  86665. * @param {number}: Defines the waves speed
  86666. */
  86667. waveSpeed: number;
  86668. /**
  86669. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  86670. * will avoid calculating useless pixels in the pixel shader of the water material.
  86671. */
  86672. disableClipPlane: boolean;
  86673. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  86674. private _mesh;
  86675. private _refractionRTT;
  86676. private _reflectionRTT;
  86677. private _reflectionTransform;
  86678. private _lastTime;
  86679. private _lastDeltaTime;
  86680. private _useLogarithmicDepth;
  86681. private _waitingRenderList;
  86682. private _imageProcessingConfiguration;
  86683. private _imageProcessingObserver;
  86684. /**
  86685. * Gets a boolean indicating that current material needs to register RTT
  86686. */
  86687. get hasRenderTargetTextures(): boolean;
  86688. /**
  86689. * Constructor
  86690. */
  86691. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  86692. get useLogarithmicDepth(): boolean;
  86693. set useLogarithmicDepth(value: boolean);
  86694. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  86695. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  86696. addToRenderList(node: any): void;
  86697. enableRenderTargets(enable: boolean): void;
  86698. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  86699. get renderTargetsEnabled(): boolean;
  86700. needAlphaBlending(): boolean;
  86701. needAlphaTesting(): boolean;
  86702. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86703. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86704. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86705. private _createRenderTargets;
  86706. getAnimatables(): BABYLON.IAnimatable[];
  86707. getActiveTextures(): BABYLON.BaseTexture[];
  86708. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86709. dispose(forceDisposeEffect?: boolean): void;
  86710. clone(name: string): WaterMaterial;
  86711. serialize(): any;
  86712. getClassName(): string;
  86713. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  86714. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  86715. }
  86716. }
  86717. declare module BABYLON {
  86718. /** @hidden */
  86719. export var asciiartPixelShader: {
  86720. name: string;
  86721. shader: string;
  86722. };
  86723. }
  86724. declare module BABYLON {
  86725. /**
  86726. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  86727. *
  86728. * It basically takes care rendering the font front the given font size to a texture.
  86729. * This is used later on in the postprocess.
  86730. */
  86731. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  86732. private _font;
  86733. private _text;
  86734. private _charSize;
  86735. /**
  86736. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  86737. */
  86738. get charSize(): number;
  86739. /**
  86740. * Create a new instance of the Ascii Art FontTexture class
  86741. * @param name the name of the texture
  86742. * @param font the font to use, use the W3C CSS notation
  86743. * @param text the caracter set to use in the rendering.
  86744. * @param scene the scene that owns the texture
  86745. */
  86746. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  86747. /**
  86748. * Gets the max char width of a font.
  86749. * @param font the font to use, use the W3C CSS notation
  86750. * @return the max char width
  86751. */
  86752. private getFontWidth;
  86753. /**
  86754. * Gets the max char height of a font.
  86755. * @param font the font to use, use the W3C CSS notation
  86756. * @return the max char height
  86757. */
  86758. private getFontHeight;
  86759. /**
  86760. * Clones the current AsciiArtTexture.
  86761. * @return the clone of the texture.
  86762. */
  86763. clone(): AsciiArtFontTexture;
  86764. /**
  86765. * Parses a json object representing the texture and returns an instance of it.
  86766. * @param source the source JSON representation
  86767. * @param scene the scene to create the texture for
  86768. * @return the parsed texture
  86769. */
  86770. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  86771. }
  86772. /**
  86773. * Option available in the Ascii Art Post Process.
  86774. */
  86775. export interface IAsciiArtPostProcessOptions {
  86776. /**
  86777. * The font to use following the w3c font definition.
  86778. */
  86779. font?: string;
  86780. /**
  86781. * The character set to use in the postprocess.
  86782. */
  86783. characterSet?: string;
  86784. /**
  86785. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  86786. * This number is defined between 0 and 1;
  86787. */
  86788. mixToTile?: number;
  86789. /**
  86790. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  86791. * This number is defined between 0 and 1;
  86792. */
  86793. mixToNormal?: number;
  86794. }
  86795. /**
  86796. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  86797. *
  86798. * Simmply add it to your scene and let the nerd that lives in you have fun.
  86799. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  86800. */
  86801. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  86802. /**
  86803. * The font texture used to render the char in the post process.
  86804. */
  86805. private _asciiArtFontTexture;
  86806. /**
  86807. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  86808. * This number is defined between 0 and 1;
  86809. */
  86810. mixToTile: number;
  86811. /**
  86812. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  86813. * This number is defined between 0 and 1;
  86814. */
  86815. mixToNormal: number;
  86816. /**
  86817. * Instantiates a new Ascii Art Post Process.
  86818. * @param name the name to give to the postprocess
  86819. * @camera the camera to apply the post process to.
  86820. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  86821. */
  86822. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  86823. }
  86824. }
  86825. declare module BABYLON {
  86826. /** @hidden */
  86827. export var digitalrainPixelShader: {
  86828. name: string;
  86829. shader: string;
  86830. };
  86831. }
  86832. declare module BABYLON {
  86833. /**
  86834. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  86835. *
  86836. * It basically takes care rendering the font front the given font size to a texture.
  86837. * This is used later on in the postprocess.
  86838. */
  86839. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  86840. private _font;
  86841. private _text;
  86842. private _charSize;
  86843. /**
  86844. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  86845. */
  86846. get charSize(): number;
  86847. /**
  86848. * Create a new instance of the Digital Rain FontTexture class
  86849. * @param name the name of the texture
  86850. * @param font the font to use, use the W3C CSS notation
  86851. * @param text the caracter set to use in the rendering.
  86852. * @param scene the scene that owns the texture
  86853. */
  86854. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  86855. /**
  86856. * Gets the max char width of a font.
  86857. * @param font the font to use, use the W3C CSS notation
  86858. * @return the max char width
  86859. */
  86860. private getFontWidth;
  86861. /**
  86862. * Gets the max char height of a font.
  86863. * @param font the font to use, use the W3C CSS notation
  86864. * @return the max char height
  86865. */
  86866. private getFontHeight;
  86867. /**
  86868. * Clones the current DigitalRainFontTexture.
  86869. * @return the clone of the texture.
  86870. */
  86871. clone(): DigitalRainFontTexture;
  86872. /**
  86873. * Parses a json object representing the texture and returns an instance of it.
  86874. * @param source the source JSON representation
  86875. * @param scene the scene to create the texture for
  86876. * @return the parsed texture
  86877. */
  86878. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  86879. }
  86880. /**
  86881. * Option available in the Digital Rain Post Process.
  86882. */
  86883. export interface IDigitalRainPostProcessOptions {
  86884. /**
  86885. * The font to use following the w3c font definition.
  86886. */
  86887. font?: string;
  86888. /**
  86889. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  86890. * This number is defined between 0 and 1;
  86891. */
  86892. mixToTile?: number;
  86893. /**
  86894. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  86895. * This number is defined between 0 and 1;
  86896. */
  86897. mixToNormal?: number;
  86898. }
  86899. /**
  86900. * DigitalRainPostProcess helps rendering everithing in digital rain.
  86901. *
  86902. * Simmply add it to your scene and let the nerd that lives in you have fun.
  86903. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  86904. */
  86905. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  86906. /**
  86907. * The font texture used to render the char in the post process.
  86908. */
  86909. private _digitalRainFontTexture;
  86910. /**
  86911. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  86912. * This number is defined between 0 and 1;
  86913. */
  86914. mixToTile: number;
  86915. /**
  86916. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  86917. * This number is defined between 0 and 1;
  86918. */
  86919. mixToNormal: number;
  86920. /**
  86921. * Instantiates a new Digital Rain Post Process.
  86922. * @param name the name to give to the postprocess
  86923. * @camera the camera to apply the post process to.
  86924. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  86925. */
  86926. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  86927. }
  86928. }
  86929. declare module BABYLON {
  86930. /** @hidden */
  86931. export var brickProceduralTexturePixelShader: {
  86932. name: string;
  86933. shader: string;
  86934. };
  86935. }
  86936. declare module BABYLON {
  86937. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  86938. private _numberOfBricksHeight;
  86939. private _numberOfBricksWidth;
  86940. private _jointColor;
  86941. private _brickColor;
  86942. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86943. updateShaderUniforms(): void;
  86944. get numberOfBricksHeight(): number;
  86945. set numberOfBricksHeight(value: number);
  86946. get numberOfBricksWidth(): number;
  86947. set numberOfBricksWidth(value: number);
  86948. get jointColor(): BABYLON.Color3;
  86949. set jointColor(value: BABYLON.Color3);
  86950. get brickColor(): BABYLON.Color3;
  86951. set brickColor(value: BABYLON.Color3);
  86952. /**
  86953. * Serializes this brick procedural texture
  86954. * @returns a serialized brick procedural texture object
  86955. */
  86956. serialize(): any;
  86957. /**
  86958. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  86959. * @param parsedTexture defines parsed texture data
  86960. * @param scene defines the current scene
  86961. * @param rootUrl defines the root URL containing brick procedural texture information
  86962. * @returns a parsed Brick Procedural BABYLON.Texture
  86963. */
  86964. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  86965. }
  86966. }
  86967. declare module BABYLON {
  86968. /** @hidden */
  86969. export var cloudProceduralTexturePixelShader: {
  86970. name: string;
  86971. shader: string;
  86972. };
  86973. }
  86974. declare module BABYLON {
  86975. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  86976. private _skyColor;
  86977. private _cloudColor;
  86978. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86979. updateShaderUniforms(): void;
  86980. get skyColor(): BABYLON.Color4;
  86981. set skyColor(value: BABYLON.Color4);
  86982. get cloudColor(): BABYLON.Color4;
  86983. set cloudColor(value: BABYLON.Color4);
  86984. /**
  86985. * Serializes this cloud procedural texture
  86986. * @returns a serialized cloud procedural texture object
  86987. */
  86988. serialize(): any;
  86989. /**
  86990. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  86991. * @param parsedTexture defines parsed texture data
  86992. * @param scene defines the current scene
  86993. * @param rootUrl defines the root URL containing cloud procedural texture information
  86994. * @returns a parsed Cloud Procedural BABYLON.Texture
  86995. */
  86996. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  86997. }
  86998. }
  86999. declare module BABYLON {
  87000. /** @hidden */
  87001. export var fireProceduralTexturePixelShader: {
  87002. name: string;
  87003. shader: string;
  87004. };
  87005. }
  87006. declare module BABYLON {
  87007. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  87008. private _time;
  87009. private _speed;
  87010. private _autoGenerateTime;
  87011. private _fireColors;
  87012. private _alphaThreshold;
  87013. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87014. updateShaderUniforms(): void;
  87015. render(useCameraPostProcess?: boolean): void;
  87016. static get PurpleFireColors(): BABYLON.Color3[];
  87017. static get GreenFireColors(): BABYLON.Color3[];
  87018. static get RedFireColors(): BABYLON.Color3[];
  87019. static get BlueFireColors(): BABYLON.Color3[];
  87020. get autoGenerateTime(): boolean;
  87021. set autoGenerateTime(value: boolean);
  87022. get fireColors(): BABYLON.Color3[];
  87023. set fireColors(value: BABYLON.Color3[]);
  87024. get time(): number;
  87025. set time(value: number);
  87026. get speed(): BABYLON.Vector2;
  87027. set speed(value: BABYLON.Vector2);
  87028. get alphaThreshold(): number;
  87029. set alphaThreshold(value: number);
  87030. /**
  87031. * Serializes this fire procedural texture
  87032. * @returns a serialized fire procedural texture object
  87033. */
  87034. serialize(): any;
  87035. /**
  87036. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  87037. * @param parsedTexture defines parsed texture data
  87038. * @param scene defines the current scene
  87039. * @param rootUrl defines the root URL containing fire procedural texture information
  87040. * @returns a parsed Fire Procedural BABYLON.Texture
  87041. */
  87042. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  87043. }
  87044. }
  87045. declare module BABYLON {
  87046. /** @hidden */
  87047. export var grassProceduralTexturePixelShader: {
  87048. name: string;
  87049. shader: string;
  87050. };
  87051. }
  87052. declare module BABYLON {
  87053. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  87054. private _grassColors;
  87055. private _groundColor;
  87056. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87057. updateShaderUniforms(): void;
  87058. get grassColors(): BABYLON.Color3[];
  87059. set grassColors(value: BABYLON.Color3[]);
  87060. get groundColor(): BABYLON.Color3;
  87061. set groundColor(value: BABYLON.Color3);
  87062. /**
  87063. * Serializes this grass procedural texture
  87064. * @returns a serialized grass procedural texture object
  87065. */
  87066. serialize(): any;
  87067. /**
  87068. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  87069. * @param parsedTexture defines parsed texture data
  87070. * @param scene defines the current scene
  87071. * @param rootUrl defines the root URL containing grass procedural texture information
  87072. * @returns a parsed Grass Procedural BABYLON.Texture
  87073. */
  87074. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  87075. }
  87076. }
  87077. declare module BABYLON {
  87078. /** @hidden */
  87079. export var marbleProceduralTexturePixelShader: {
  87080. name: string;
  87081. shader: string;
  87082. };
  87083. }
  87084. declare module BABYLON {
  87085. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  87086. private _numberOfTilesHeight;
  87087. private _numberOfTilesWidth;
  87088. private _amplitude;
  87089. private _jointColor;
  87090. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87091. updateShaderUniforms(): void;
  87092. get numberOfTilesHeight(): number;
  87093. set numberOfTilesHeight(value: number);
  87094. get amplitude(): number;
  87095. set amplitude(value: number);
  87096. get numberOfTilesWidth(): number;
  87097. set numberOfTilesWidth(value: number);
  87098. get jointColor(): BABYLON.Color3;
  87099. set jointColor(value: BABYLON.Color3);
  87100. /**
  87101. * Serializes this marble procedural texture
  87102. * @returns a serialized marble procedural texture object
  87103. */
  87104. serialize(): any;
  87105. /**
  87106. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  87107. * @param parsedTexture defines parsed texture data
  87108. * @param scene defines the current scene
  87109. * @param rootUrl defines the root URL containing marble procedural texture information
  87110. * @returns a parsed Marble Procedural BABYLON.Texture
  87111. */
  87112. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  87113. }
  87114. }
  87115. declare module BABYLON {
  87116. /** @hidden */
  87117. export var normalMapProceduralTexturePixelShader: {
  87118. name: string;
  87119. shader: string;
  87120. };
  87121. }
  87122. declare module BABYLON {
  87123. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  87124. private _baseTexture;
  87125. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87126. updateShaderUniforms(): void;
  87127. render(useCameraPostProcess?: boolean): void;
  87128. resize(size: any, generateMipMaps: any): void;
  87129. get baseTexture(): BABYLON.Texture;
  87130. set baseTexture(texture: BABYLON.Texture);
  87131. /**
  87132. * Serializes this normal map procedural texture
  87133. * @returns a serialized normal map procedural texture object
  87134. */
  87135. serialize(): any;
  87136. /**
  87137. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  87138. * @param parsedTexture defines parsed texture data
  87139. * @param scene defines the current scene
  87140. * @param rootUrl defines the root URL containing normal map procedural texture information
  87141. * @returns a parsed Normal Map Procedural BABYLON.Texture
  87142. */
  87143. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  87144. }
  87145. }
  87146. declare module BABYLON {
  87147. /** @hidden */
  87148. export var perlinNoiseProceduralTexturePixelShader: {
  87149. name: string;
  87150. shader: string;
  87151. };
  87152. }
  87153. declare module BABYLON {
  87154. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  87155. time: number;
  87156. timeScale: number;
  87157. translationSpeed: number;
  87158. private _currentTranslation;
  87159. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87160. updateShaderUniforms(): void;
  87161. render(useCameraPostProcess?: boolean): void;
  87162. resize(size: any, generateMipMaps: any): void;
  87163. /**
  87164. * Serializes this perlin noise procedural texture
  87165. * @returns a serialized perlin noise procedural texture object
  87166. */
  87167. serialize(): any;
  87168. /**
  87169. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  87170. * @param parsedTexture defines parsed texture data
  87171. * @param scene defines the current scene
  87172. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  87173. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  87174. */
  87175. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  87176. }
  87177. }
  87178. declare module BABYLON {
  87179. /** @hidden */
  87180. export var roadProceduralTexturePixelShader: {
  87181. name: string;
  87182. shader: string;
  87183. };
  87184. }
  87185. declare module BABYLON {
  87186. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  87187. private _roadColor;
  87188. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87189. updateShaderUniforms(): void;
  87190. get roadColor(): BABYLON.Color3;
  87191. set roadColor(value: BABYLON.Color3);
  87192. /**
  87193. * Serializes this road procedural texture
  87194. * @returns a serialized road procedural texture object
  87195. */
  87196. serialize(): any;
  87197. /**
  87198. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  87199. * @param parsedTexture defines parsed texture data
  87200. * @param scene defines the current scene
  87201. * @param rootUrl defines the root URL containing road procedural texture information
  87202. * @returns a parsed Road Procedural BABYLON.Texture
  87203. */
  87204. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  87205. }
  87206. }
  87207. declare module BABYLON {
  87208. /** @hidden */
  87209. export var starfieldProceduralTexturePixelShader: {
  87210. name: string;
  87211. shader: string;
  87212. };
  87213. }
  87214. declare module BABYLON {
  87215. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  87216. private _time;
  87217. private _alpha;
  87218. private _beta;
  87219. private _zoom;
  87220. private _formuparam;
  87221. private _stepsize;
  87222. private _tile;
  87223. private _brightness;
  87224. private _darkmatter;
  87225. private _distfading;
  87226. private _saturation;
  87227. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87228. updateShaderUniforms(): void;
  87229. get time(): number;
  87230. set time(value: number);
  87231. get alpha(): number;
  87232. set alpha(value: number);
  87233. get beta(): number;
  87234. set beta(value: number);
  87235. get formuparam(): number;
  87236. set formuparam(value: number);
  87237. get stepsize(): number;
  87238. set stepsize(value: number);
  87239. get zoom(): number;
  87240. set zoom(value: number);
  87241. get tile(): number;
  87242. set tile(value: number);
  87243. get brightness(): number;
  87244. set brightness(value: number);
  87245. get darkmatter(): number;
  87246. set darkmatter(value: number);
  87247. get distfading(): number;
  87248. set distfading(value: number);
  87249. get saturation(): number;
  87250. set saturation(value: number);
  87251. /**
  87252. * Serializes this starfield procedural texture
  87253. * @returns a serialized starfield procedural texture object
  87254. */
  87255. serialize(): any;
  87256. /**
  87257. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  87258. * @param parsedTexture defines parsed texture data
  87259. * @param scene defines the current scene
  87260. * @param rootUrl defines the root URL containing startfield procedural texture information
  87261. * @returns a parsed Starfield Procedural BABYLON.Texture
  87262. */
  87263. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  87264. }
  87265. }
  87266. declare module BABYLON {
  87267. /** @hidden */
  87268. export var woodProceduralTexturePixelShader: {
  87269. name: string;
  87270. shader: string;
  87271. };
  87272. }
  87273. declare module BABYLON {
  87274. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  87275. private _ampScale;
  87276. private _woodColor;
  87277. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87278. updateShaderUniforms(): void;
  87279. get ampScale(): number;
  87280. set ampScale(value: number);
  87281. get woodColor(): BABYLON.Color3;
  87282. set woodColor(value: BABYLON.Color3);
  87283. /**
  87284. * Serializes this wood procedural texture
  87285. * @returns a serialized wood procedural texture object
  87286. */
  87287. serialize(): any;
  87288. /**
  87289. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  87290. * @param parsedTexture defines parsed texture data
  87291. * @param scene defines the current scene
  87292. * @param rootUrl defines the root URL containing wood procedural texture information
  87293. * @returns a parsed Wood Procedural BABYLON.Texture
  87294. */
  87295. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  87296. }
  87297. }